Skip to content

Commit

Permalink
CustomIcon
Browse files Browse the repository at this point in the history
  • Loading branch information
pandrabox committed Sep 16, 2024
1 parent 707a3e7 commit 3b29aa3
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 8 deletions.
10 changes: 10 additions & 0 deletions Editor/EmoteManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ public static TransitionInfo ForceExitTransitionInfo(int n)
return EmoteProperty(n).ForceExitTransitionInfo;
}

/// <summary>
/// アイコン
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
public static Texture2D Icon(int n)
{
return EmotePrefab(n).Icon;
}

/// <summary>
/// 現行のHumanoidClip
/// </summary>
Expand Down
38 changes: 38 additions & 0 deletions Editor/EmotePrefabEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Xml.Linq;
using com.github.pandrabox.emoteprefab.editor;
using com.github.pandrabox.emoteprefab.runtime;
using nadena.dev.modular_avatar.core;
using nadena.dev.modular_avatar.core.editor;
using nadena.dev.ndmf;
using Newtonsoft.Json.Linq;
using UnityEditor;
using UnityEditor.Animations;
using UnityEngine;
Expand All @@ -25,11 +28,46 @@ public override void OnInspectorGUI()
serializedObject.Update();

var nowInstance = (EmotePrefab)target;


EditorGUILayout.BeginHorizontal();

EditorGUILayout.BeginVertical();

nowInstance.Motion = (AnimationClip)EditorGUILayout.ObjectField("Motion", nowInstance.Motion, typeof(AnimationClip), false);
nowInstance.Name = EditorGUILayout.TextField("Name", nowInstance.Name);
EditorGUILayout.PropertyField(serializedObject.FindProperty("IsOneShot"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("IsEmote"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("IsAFK"));
var spIcon = serializedObject.FindProperty("Icon");
EditorGUILayout.PropertyField(spIcon);

EditorGUILayout.EndVertical();

if (spIcon != null)
{
var tex = spIcon.objectReferenceValue as Texture2D;
if (tex != null && !spIcon.hasMultipleDifferentValues)
{
var size = EditorGUIUtility.singleLineHeight * 5;
var margin = 4;
var withMargin = new Vector2(margin + size, margin + size);

var rect = GUILayoutUtility.GetRect(withMargin.x, withMargin.y, GUILayout.ExpandWidth(false),
GUILayout.ExpandHeight(true));
rect.x += margin;
rect.y = rect.y + rect.height / 2 - size / 2;
rect.width = size;
rect.height = size;

GUI.Box(rect, new GUIContent(), "flow node 1");
GUI.DrawTexture(rect, tex);
}
}

EditorGUILayout.EndHorizontal();



var spViewAdvancedOptions = serializedObject.FindProperty("ViewAdvancedOptions");
EditorGUILayout.PropertyField(spViewAdvancedOptions);
Expand Down
10 changes: 2 additions & 8 deletions Editor/ExpressionCreater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,8 @@ private void CreateUnitMenu(int eI)
var unitMenu = obj.AddComponent<ModularAvatarMenuItem>();
unitMenu.Control.parameter = new VRC.SDK3.Avatars.ScriptableObjects.VRCExpressionsMenu.Control.Parameter() { name = "VRCEmote" };
unitMenu.Control.value = EmoteManager.ID(eI);
//if (EmoteManager.IsOneShot(eI))
//{
// unitMenu.Control.type = VRC.SDK3.Avatars.ScriptableObjects.VRCExpressionsMenu.Control.ControlType.Button;
//}
//else
//{
unitMenu.Control.type = VRC.SDK3.Avatars.ScriptableObjects.VRCExpressionsMenu.Control.ControlType.Toggle;
//}
unitMenu.Control.type = VRC.SDK3.Avatars.ScriptableObjects.VRCExpressionsMenu.Control.ControlType.Toggle;
unitMenu.Control.icon = EmoteManager.Icon(eI);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions Runtime/EmotePrefab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class EmotePrefab : MonoBehaviour, VRC.SDKBase.IEditorOnly
public bool IsOneShot;
public bool IsEmote;
public bool IsAFK;
public Texture2D Icon;
public bool ViewAdvancedOptions;
public bool AnimateAllPhysBones;
public List<VRCPhysBone> AnimatePhysBones;
Expand Down

1 comment on commit 3b29aa3

@pandrabox
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

close #20

Please sign in to comment.