浏览代码

Folder Icons in Hierarchy

/main
Thomas ICHÉ 5 年前
当前提交
8cb570dd
共有 8 个文件被更改,包括 135 次插入7 次删除
  1. 1
      CHANGELOG.md
  2. 38
      Editor/HierarchyHints/HierarchyHints.cs
  3. 8
      Editor/CustomInspectors.meta
  4. 27
      Runtime/Ingredients/Folder.cs
  5. 11
      Runtime/Ingredients/Folder.cs.meta
  6. 46
      Editor/CustomInspectors/FolderEditor.cs
  7. 11
      Editor/CustomInspectors/FolderEditor.cs.meta

1
CHANGELOG.md


#### Added
* **Call Tree Explorer :** Using Window/Gameplay Ingredients/Call Tree Explorer , opens a window that lists the tree of Events, Logic and Actions, State Machines and Event Calling Actions
* **Folders:** In the Game Object creation Menu, Select folder to add a folder in the hierarchy. Automatically adds Static Game Objects with colored icon (Displayed using Advanced Hierarchy View)
* Added option in GameplayIngredientsSettings to disable visibility of Callable[] bound to Update Loops.
* Added OnUpdate Event : Perform calls every update
* Added OnColider Event : Perform calls upon collisions

38
Editor/HierarchyHints/HierarchyHints.cs


static Dictionary<Type, string> s_Definitions = new Dictionary<Type, string>()
{
{ typeof(Folder), "Folder Icon"},
{ typeof(MonoBehaviour), "cs Script Icon"},
{ typeof(Camera), "Camera Icon"},
{ typeof(MeshRenderer), "MeshRenderer Icon"},

if (o == null) return;
var c = GUI.color;
if (o.isStatic)
{
GUI.Label(fullRect, " S");
EditorGUI.DrawRect(fullRect, Colors.dimGray);
}
bool isFolder = o.GetComponent<Folder>() != null;
foreach(var type in s_Definitions.Keys)
if(isFolder)
if (o.GetComponents(type).Length > 0) selectionRect = DrawIcon(selectionRect, Contents.GetContent(type), Color.white);
fullRect.xMin += 28 + 14 * GetObjectDepth(o.transform);
fullRect.width = 16;
EditorGUI.DrawRect(fullRect, EditorGUIUtility.isProSkin? Styles.proBackground : Styles.personalBackground);
DrawIcon(fullRect, Contents.GetContent(typeof(Folder)), o.GetComponent<Folder>().Color);
else
{
if (o.isStatic)
{
GUI.Label(fullRect, " S");
EditorGUI.DrawRect(fullRect, Colors.dimGray);
}
foreach (var type in s_Definitions.Keys)
{
if (o.GetComponents(type).Length > 0) selectionRect = DrawIcon(selectionRect, Contents.GetContent(type), Color.white);
}
}
}
static int GetObjectDepth(Transform t, int depth=0)
{
if (t.parent == null)
return depth;
else
return GetObjectDepth(t.parent, depth + 1);
}

{
public static GUIStyle rightLabel;
public static GUIStyle icon;
public static Color proBackground = new Color(0.25f, 0.25f, 0.25f, 1.0f);
public static Color personalBackground = new Color(0.75f, 0.75f, 0.75f, 1.0f);
static Styles()
{

8
Editor/CustomInspectors.meta


fileFormatVersion: 2
guid: b3467fc18385f3f41a4050759dc020e7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

27
Runtime/Ingredients/Folder.cs


using UnityEngine;
namespace GameplayIngredients
{
[ExecuteAlways]
public class Folder : MonoBehaviour
{
public Color Color = Color.yellow;
private void Awake()
{
Reset();
}
private void Reset()
{
gameObject.isStatic = true;
transform.localPosition = Vector3.zero;
transform.localRotation = Quaternion.identity;
transform.localScale = Vector3.one;
if(Application.isPlaying)
{
Destroy(this);
}
}
}
}

11
Runtime/Ingredients/Folder.cs.meta


fileFormatVersion: 2
guid: 40ebf4fc729b9924e85bf13fdbf9a6c3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: -1463847995985908582, guid: 0000000000000000d000000000000000, type: 0}
userData:
assetBundleName:
assetBundleVariant:

46
Editor/CustomInspectors/FolderEditor.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace GameplayIngredients.Editor
{
[CustomEditor(typeof(Folder))]
public class FolderEditor : UnityEditor.Editor
{
[MenuItem("GameObject/Folder", false, 10)]
static void CreateFolder()
{
var go = new GameObject("Folder", typeof(Folder));
if(Selection.activeGameObject != null && Selection.activeGameObject.scene != null)
{
go.transform.parent = Selection.activeGameObject.transform;
}
}
SerializedProperty m_Color;
private void OnEnable()
{
m_Color = serializedObject.FindProperty("Color");
}
public override bool HasPreviewGUI()
{
return false;
}
public override void OnInspectorGUI()
{
EditorGUI.BeginChangeCheck();
var color = EditorGUILayout.ColorField("Folder Color", m_Color.colorValue);
if(EditorGUI.EndChangeCheck())
{
m_Color.colorValue = color;
serializedObject.ApplyModifiedProperties();
}
}
}
}

11
Editor/CustomInspectors/FolderEditor.cs.meta


fileFormatVersion: 2
guid: 474b95a56281dc44483708a7186ba29d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存