-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
- Loading branch information
There are no files selected for viewing
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(); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,8 @@ | ||
{ | ||
"name": "QHierarchyNullable", | ||
"references": [], | ||
"optionalUnityReferences": [], | ||
"includePlatforms": [], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false | ||
} |
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,6 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class QHierarchyNullableAttribute: PropertyAttribute { | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,15 @@ | ||
{ | ||
"name": "QHierarchyEditor", | ||
"references": [ | ||
"QHierarchyNullable", | ||
"QHierarchyRuntime", | ||
"Virtuesky.Sunflower.DataStorage.Editor", | ||
"VirtueSky.Sunflower.Inspector" | ||
], | ||
"optionalUnityReferences": [], | ||
"includePlatforms": [ | ||
"Editor" | ||
], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,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(); | ||
} | ||
} | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.