Skip to content

Commit

Permalink
add Q hierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
GrayWolf52 committed Jan 22, 2024
1 parent d64ca20 commit f451ec9
Show file tree
Hide file tree
Showing 84 changed files with 6,194 additions and 1 deletion.
24 changes: 24 additions & 0 deletions VirtueSky/ControlPanel/CPQHierarchyDrawer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using qtools.qhierarchy.phierarchy;
using UnityEditor;
using UnityEngine;


namespace VirtueSky.ControlPanel.Editor
{
public class CPQHierarchyDrawer
{
public static void OnDrawQHierarchyEvent()
{
GUILayout.Space(10);
GUILayout.BeginVertical();
GUILayout.Label("Q-HIERARCHY", EditorStyles.boldLabel);
GUILayout.Space(10);
if (GUILayout.Button("Open QHierarchy Settings"))
{
QHierarchySettingsWindow.ShowWindow();
}

GUILayout.EndVertical();
}
}
}
3 changes: 3 additions & 0 deletions VirtueSky/ControlPanel/CPQHierarchyDrawer.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions VirtueSky/ControlPanel/ControlPanelWindowEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ void DrawButton()
statePanelControl = StatePanelControl.LevelEditor;
}

if (GUILayout.Button("QHierarchy"))
{
statePanelControl = StatePanelControl.QHierarchy;
}

if (GUILayout.Button("Notifications Chanel"))
{
statePanelControl = StatePanelControl.NotificationsChanel;
Expand Down Expand Up @@ -159,6 +164,9 @@ void DrawContent()
case StatePanelControl.RegisterPackage:
CPRegisterPackageDrawer.OnDrawRegisterPackageByManifest(position);
break;
case StatePanelControl.QHierarchy:
CPQHierarchyDrawer.OnDrawQHierarchyEvent();
break;
case StatePanelControl.About:
CPAboutDrawer.OnDrawAbout(position, () => { OnSettingColorTheme(); });
break;
Expand Down Expand Up @@ -234,6 +242,7 @@ public enum StatePanelControl
SO_Variable,
ScriptDefineSymbols,
RegisterPackage,
QHierarchy,
About,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"GUID:c904f6d969e991d459a0843b71c22ec5",
"GUID:324caed91501a9c47a04ebfd87b68794",
"GUID:32dbaa332e571bf429b7de517f75f074",
"GUID:0b6289df6f84a6f4b982ff72d23e0273"
"GUID:0b6289df6f84a6f4b982ff72d23e0273",
"GUID:49674d15b25185649b7ec8ac5d378747"
],
"includePlatforms": [
"Editor"
Expand Down
8 changes: 8 additions & 0 deletions VirtueSky/QHierarchy.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions VirtueSky/QHierarchy/Attribute.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions VirtueSky/QHierarchy/Attribute/QHierarchyNullable.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "QHierarchyNullable",
"references": [],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false
}
7 changes: 7 additions & 0 deletions VirtueSky/QHierarchy/Attribute/QHierarchyNullable.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions VirtueSky/QHierarchy/Attribute/QHierarchyNullable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class QHierarchyNullableAttribute: PropertyAttribute {
}
11 changes: 11 additions & 0 deletions VirtueSky/QHierarchy/Attribute/QHierarchyNullable.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions VirtueSky/QHierarchy/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions VirtueSky/QHierarchy/Editor/QHierarchyEditor.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "QHierarchyEditor",
"references": [
"QHierarchyNullable",
"QHierarchyRuntime",
"Virtuesky.Sunflower.DataStorage.Editor",
"VirtueSky.Sunflower.Inspector"
],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false
}
7 changes: 7 additions & 0 deletions VirtueSky/QHierarchy/Editor/QHierarchyEditor.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions VirtueSky/QHierarchy/Editor/Scripts.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions VirtueSky/QHierarchy/Editor/Scripts/QHierarchyInitializer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using UnityEngine;
using UnityEditor;
using System;
using System.Collections.Generic;
using qtools.qhierarchy.pdata;
using qtools.qhierarchy.phierarchy;
using UnityEditor.Callbacks;
using qtools.qhierarchy.phelper;

namespace qtools.qhierarchy
{
[InitializeOnLoad]
public class QHierarchyInitializer
{
private static QHierarchy hierarchy;

static QHierarchyInitializer()
{
EditorApplication.update -= update;
EditorApplication.update += update;

EditorApplication.hierarchyWindowItemOnGUI -= hierarchyWindowItemOnGUIHandler;
EditorApplication.hierarchyWindowItemOnGUI += hierarchyWindowItemOnGUIHandler;

EditorApplication.hierarchyChanged -= hierarchyWindowChanged;
EditorApplication.hierarchyChanged += hierarchyWindowChanged;

Undo.undoRedoPerformed -= undoRedoPerformed;
Undo.undoRedoPerformed += undoRedoPerformed;
}

static void undoRedoPerformed()
{
EditorApplication.RepaintHierarchyWindow();
}

static void init()
{
hierarchy = new QHierarchy();
}

static void update()
{
if (hierarchy == null) init();
QObjectListManager.getInstance().update();
}

static void hierarchyWindowItemOnGUIHandler(int instanceId, Rect selectionRect)
{
if (hierarchy == null) init();
hierarchy.hierarchyWindowItemOnGUIHandler(instanceId, selectionRect);
}

static void hierarchyWindowChanged()
{
if (hierarchy == null) init();
QObjectListManager.getInstance().validate();
}
}
}

12 changes: 12 additions & 0 deletions VirtueSky/QHierarchy/Editor/Scripts/QHierarchyInitializer.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions VirtueSky/QHierarchy/Editor/Scripts/pcomponent.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using qtools.qhierarchy.pcomponent.pbase;
using qtools.qhierarchy.phierarchy;
using qtools.qhierarchy.phelper;
using qtools.qhierarchy.pdata;

namespace qtools.qhierarchy.pcomponent
{
public class QChildrenCountComponent: QBaseComponent
{
// PRIVATE
private GUIStyle labelStyle;

// CONSTRUCTOR
public QChildrenCountComponent ()
{
labelStyle = new GUIStyle();
labelStyle.fontSize = 9;
labelStyle.clipping = TextClipping.Clip;
labelStyle.alignment = TextAnchor.MiddleRight;

rect.width = 22;
rect.height = 16;

QSettings.getInstance().addEventListener(QSetting.ChildrenCountShow , settingsChanged);
QSettings.getInstance().addEventListener(QSetting.ChildrenCountShowDuringPlayMode, settingsChanged);
QSettings.getInstance().addEventListener(QSetting.ChildrenCountLabelSize , settingsChanged);
QSettings.getInstance().addEventListener(QSetting.ChildrenCountLabelColor , settingsChanged);
settingsChanged();
}

// PRIVATE
private void settingsChanged()
{
enabled = QSettings.getInstance().get<bool>(QSetting.ChildrenCountShow);
showComponentDuringPlayMode = QSettings.getInstance().get<bool>(QSetting.ChildrenCountShowDuringPlayMode);
QHierarchySize labelSize = (QHierarchySize)QSettings.getInstance().get<int>(QSetting.ChildrenCountLabelSize);
labelStyle.normal.textColor = QSettings.getInstance().getColor(QSetting.ChildrenCountLabelColor);
labelStyle.fontSize = labelSize == QHierarchySize.Normal ? 8 : 9;
rect.width = labelSize == QHierarchySize.Normal ? 17 : 22;
}

// DRAW
public override QLayoutStatus layout(GameObject gameObject, QObjectList objectList, Rect selectionRect, ref Rect curRect, float maxWidth)
{
if (maxWidth < rect.width)
{
return QLayoutStatus.Failed;
}
else
{
curRect.x -= rect.width + 2;
rect.x = curRect.x;
rect.y = curRect.y;
rect.y += (EditorGUIUtility.singleLineHeight - rect.height) * 0.5f;
rect.height = EditorGUIUtility.singleLineHeight;
return QLayoutStatus.Success;
}
}

public override void draw(GameObject gameObject, QObjectList objectList, Rect selectionRect)
{
int childrenCount = gameObject.transform.childCount;
if (childrenCount > 0) GUI.Label(rect, childrenCount.ToString(), labelStyle);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f451ec9

Please sign in to comment.