Skip to content

Commit 0650592

Browse files
authored
Merge pull request #16 from VirtueSky/dev
Dev
2 parents 6b38e3c + 0d3e35f commit 0650592

16 files changed

+669
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
### 1: Download the repo and drop it into folder `Assets`
2424
### 2: Add the line below to `Packages/manifest.json`
2525

26-
for version `3.0.0`
26+
for version `3.0.1`
2727
```csharp
28-
"com.virtuesky.sunflower":"https://github.com/VirtueSky/sunflower.git#3.0.0",
28+
"com.virtuesky.sunflower":"https://github.com/VirtueSky/sunflower.git#3.0.1",
2929
```
3030

3131
## Includes modules

VirtueSky/ControlPanel/ConstantPackage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
public class ConstantPackage
44
{
5-
public const string VersionSunflower = "3.0.0";
5+
public const string VersionSunflower = "3.0.1";
66
public const string PackageNameInAppPurchase = "com.unity.purchasing";
77
public const string MaxVersionInAppPurchase = "4.12.2";
88
public const string PackageNameNewtonsoftJson = "com.unity.nuget.newtonsoft-json";

VirtueSky/Hierarchy/Editor/HierarchyEditor.asmdef

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"Virtuesky.Sunflower.DataStorage.Editor",
66
"VirtueSky.Sunflower.Inspector",
77
"HierarchyNullable",
8-
"HierarchyRuntime"
8+
"HierarchyRuntime",
9+
"Virtuesky.Sunflower.UtilsEdtitor"
910
],
1011
"includePlatforms": [
1112
"Editor"

VirtueSky/Hierarchy/FolderHierarchy.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using UnityEngine;
2+
using VirtueSky.Inspector;
3+
4+
namespace VirtueSky.Hierarchy
5+
{
6+
[ExecuteInEditMode]
7+
[EditorIcon("icon_hierarchy"), HideMonoScript]
8+
public class HeaderHierarchy : MonoBehaviour
9+
{
10+
#region Variables
11+
12+
public enum TextAlignment
13+
{
14+
Left,
15+
Center
16+
}
17+
18+
[TitleColor("Text", CustomColor.Gold, CustomColor.Aqua)] [SerializeField]
19+
public bool customText;
20+
21+
[ShowIf(nameof(customText)), SerializeField]
22+
public Color32 textColor = InspectorUtility.textNormalColor;
23+
24+
[Space] [SerializeField] public FontStyle textStyle = FontStyle.BoldAndItalic;
25+
26+
[SerializeField] public TextAlignment textAlignment = TextAlignment.Left;
27+
28+
[TitleColor("Highlight", CustomColor.Coral, CustomColor.Lime)] [Space, SerializeField]
29+
public bool customHighlight;
30+
31+
[ShowIf(nameof(customHighlight)), SerializeField]
32+
public Color32 highlightColor = InspectorUtility.cyanColor;
33+
34+
#endregion
35+
} // class end
36+
}

VirtueSky/Hierarchy/FolderHierarchy/HeaderHierarchy.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
#if UNITY_EDITOR
2+
using System.Linq;
3+
using UnityEditor;
4+
using UnityEngine;
5+
using VirtueSky.UtilsEditor;
6+
7+
namespace VirtueSky.Hierarchy
8+
{
9+
[InitializeOnLoad]
10+
public class HeaderHierarchyIcon
11+
{
12+
#region Static Variables
13+
14+
// icons
15+
private static string assetPath = "/VirtueSky/Hierarchy/Icons";
16+
private static Texture2D icon_HierarchyHighlight;
17+
18+
#endregion
19+
20+
//----------------------------------------------------------------------------------------------------
21+
22+
#region Contructors
23+
24+
static HeaderHierarchyIcon()
25+
{
26+
// subscribe to inspector updates
27+
EditorApplication.hierarchyWindowItemOnGUI += EditorApplication_hierarchyWindowItemOnGUI;
28+
}
29+
30+
#endregion
31+
32+
//----------------------------------------------------------------------------------------------------
33+
34+
#region Private Functions
35+
36+
private static void CreateHierarchyIcon_Highlight()
37+
{
38+
icon_HierarchyHighlight = FileExtension.FindAssetWithPath<Texture2D>("HierarchyHighlight.png", assetPath);
39+
}
40+
41+
private static void EditorApplication_hierarchyWindowItemOnGUI(int instanceID, Rect position)
42+
{
43+
// check for valid draw
44+
if (Event.current.type != EventType.Repaint)
45+
{
46+
return;
47+
}
48+
49+
GameObject gameObject = EditorUtility.InstanceIDToObject(instanceID) as GameObject;
50+
if (gameObject != null)
51+
{
52+
HeaderHierarchy component = gameObject.GetComponent<HeaderHierarchy>();
53+
if (component != null)
54+
{
55+
// cache values
56+
int hierarchyPixelHeight = 16;
57+
bool isSelected = Selection.instanceIDs.Contains(instanceID);
58+
bool isActive = component.isActiveAndEnabled;
59+
Color32 defaultContentColor = GUI.contentColor;
60+
Color32 textColor;
61+
Color32 backgroundColor;
62+
63+
if (isActive || isSelected)
64+
{
65+
// text
66+
if (component.customText)
67+
{
68+
textColor = component.textColor;
69+
}
70+
else
71+
{
72+
textColor = InspectorUtility.textNormalColor;
73+
}
74+
}
75+
else
76+
{
77+
// text
78+
if (component.customText)
79+
{
80+
textColor = (Color)component.textColor * 0.6f;
81+
}
82+
else
83+
{
84+
textColor = InspectorUtility.textDisabledColor;
85+
}
86+
}
87+
88+
// draw background
89+
if (isSelected)
90+
{
91+
backgroundColor = InspectorUtility.backgroundActiveColor;
92+
}
93+
else
94+
{
95+
backgroundColor = InspectorUtility.backgroundNormalColorLight;
96+
}
97+
98+
Rect backgroundPosition = new Rect(position.xMin, position.yMin, position.width + hierarchyPixelHeight, position.height);
99+
EditorGUI.DrawRect(backgroundPosition, backgroundColor);
100+
101+
// check icon exists
102+
if (!icon_HierarchyHighlight)
103+
{
104+
CreateHierarchyIcon_Highlight();
105+
}
106+
107+
// draw highlight
108+
if (component.customHighlight)
109+
{
110+
GUI.contentColor = component.highlightColor;
111+
Rect iconPosition = new Rect(position.xMin, position.yMin, icon_HierarchyHighlight.width, icon_HierarchyHighlight.height);
112+
GUIContent iconGUIContent = new GUIContent(icon_HierarchyHighlight);
113+
EditorGUI.LabelField(iconPosition, iconGUIContent);
114+
GUI.contentColor = defaultContentColor;
115+
}
116+
117+
// draw text
118+
GUIStyle hierarchyText = new GUIStyle() { };
119+
hierarchyText.normal = new GUIStyleState() { textColor = textColor };
120+
hierarchyText.fontStyle = component.textStyle;
121+
int offsetX;
122+
if (component.textAlignment == HeaderHierarchy.TextAlignment.Center)
123+
{
124+
hierarchyText.alignment = TextAnchor.MiddleCenter;
125+
offsetX = 0;
126+
}
127+
else
128+
{
129+
hierarchyText.alignment = TextAnchor.MiddleLeft;
130+
offsetX = hierarchyPixelHeight + 2;
131+
}
132+
133+
Rect textOffset = new Rect(position.xMin + offsetX, position.yMin, position.width, position.height);
134+
EditorGUI.LabelField(textOffset, component.name, hierarchyText);
135+
}
136+
}
137+
}
138+
139+
#endregion
140+
} // class end
141+
}
142+
#endif

VirtueSky/Hierarchy/FolderHierarchy/HeaderHierarchyIcon.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "HierarchyHeader",
3+
"rootNamespace": "",
4+
"references": [
5+
"GUID:324caed91501a9c47a04ebfd87b68794",
6+
"GUID:c904f6d969e991d459a0843b71c22ec5"
7+
],
8+
"includePlatforms": [],
9+
"excludePlatforms": [],
10+
"allowUnsafeCode": false,
11+
"overrideReferences": false,
12+
"precompiledReferences": [],
13+
"autoReferenced": true,
14+
"defineConstraints": [],
15+
"versionDefines": [],
16+
"noEngineReferences": false
17+
}

VirtueSky/Hierarchy/FolderHierarchy/HierarchyHeader.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)