Skip to content

Commit dc2441c

Browse files
committed
Create repository
0 parents  commit dc2441c

File tree

336 files changed

+17302
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

336 files changed

+17302
-0
lines changed

.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# ====== #
2+
# Custom #
3+
# ====== #
4+
.UnityProject
5+
6+
# =============== #
7+
# Unity generated #
8+
# =============== #
9+
#UnityProject/Temp
10+
#UnityProject/Library
11+
#UnityProject/Logs
12+
#UnityProject/ProjectSettings
13+
#UnityProject/Packages
14+
15+
# ============= #
16+
# IDE generated #
17+
# ============= #
18+
#UnityProject/[Oo]bj
19+
*.userprefs
20+
*.csproj
21+
*.pidb
22+
*.suo
23+
*.sln
24+
*.user
25+
*.unityproj
26+
*.booproj
27+
*.idc
28+
*.vs
29+
30+
# ============ #
31+
# OS generated #
32+
# ============ #
33+
.DS_Store*
34+
._*
35+
.Spotlight-V100
36+
.Trashes
37+
ehthumbs.db
38+
[Tt]humbs.db

Editor.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.

Editor/Drawers.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.

Editor/Drawers/BitArrayMaskDrawer.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using UU.Collections;
2+
using UnityEditor;
3+
using UnityEngine;
4+
using UUEditor.Windows;
5+
6+
namespace UUEditor.Drawers
7+
{
8+
internal abstract class BitArrayMaskWindow : EditorWindow
9+
{
10+
public abstract void SetUp(object param);
11+
12+
public static T Create<T>() where T : BitArrayMaskWindow
13+
{
14+
return GetWindow(typeof(T), true, "Bit Array Mask Values") as T;
15+
}
16+
}
17+
18+
[CustomPropertyDrawer(typeof(BitArrayMask))]
19+
internal class BitArrayMaskDrawer : PropertyDrawer
20+
{
21+
private SimpleBitArrayMaskWindow m_win;
22+
23+
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
24+
{
25+
Draw(position, label, ref m_win, property);
26+
}
27+
28+
internal static void Draw<T>(Rect position, GUIContent label, ref T popup, object popupParam) where T : BitArrayMaskWindow
29+
{
30+
position.size = new Vector2(position.size.x, EditorGUIUtility.singleLineHeight);
31+
Rect rect = EditorGUI.PrefixLabel(position, label);
32+
if (GUI.Button(rect, "Edit values"))
33+
if (popup == null)
34+
(popup = BitArrayMaskWindow.Create<T>()).SetUp(popupParam);
35+
else
36+
popup.Focus();
37+
}
38+
}
39+
}

Editor/Drawers/BitArrayMaskDrawer.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: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
using System;
2+
using UnityEngine;
3+
using UnityEditor;
4+
using UU.Collections;
5+
using UUEditor.Windows;
6+
7+
namespace UUEditor.Drawers
8+
{
9+
[CustomPropertyDrawer(typeof(BitMaskEnumFlagsAttribute))]
10+
internal class BitMaskEnumFlagsDrawer : PropertyDrawer
11+
{
12+
private class Data
13+
{
14+
private readonly string m_error;
15+
16+
private readonly GUIContent m_label;
17+
private readonly string[] m_names;
18+
private readonly bool m_array;
19+
20+
private EnumBitArrayMaskWindow m_win;
21+
22+
public Data(SerializedProperty property, PropertyDrawer drawer)
23+
{
24+
Array values;
25+
26+
if (drawer.fieldInfo.FieldType == typeof(BitArrayMask))
27+
{
28+
m_label = new GUIContent(property.displayName);
29+
values = Enum.GetValues((drawer.attribute as BitMaskEnumFlagsAttribute).EnumType);
30+
m_array = true;
31+
}
32+
else if (drawer.fieldInfo.FieldType.Is(TypeCode.Int32))
33+
{
34+
values = Enum.GetValues((drawer.attribute as BitMaskEnumFlagsAttribute).EnumType);
35+
36+
if (values.Length > BitMaskExtensions.SIZE)
37+
{
38+
m_error = "Enum values amount cannot be more than " + BitMaskExtensions.SIZE.ToString();
39+
return;
40+
}
41+
42+
m_label = new GUIContent(property.displayName);
43+
}
44+
else
45+
{
46+
m_error = "Use BitMaskEnumFlags with BitMask or BitArrayMask.";
47+
return;
48+
}
49+
50+
Enum lastElement = values.GetValue(values.Length - 1) as Enum;
51+
m_names = new string[lastElement.ToInteger() + 1];
52+
53+
foreach (Enum item in values)
54+
{
55+
m_names[item.ToInteger()] = item.GetName();
56+
}
57+
58+
if (m_array)
59+
{
60+
EnumBitArrayMaskWindow.CheckArray(property, m_names);
61+
property.serializedObject.ApplyModifiedProperties();
62+
}
63+
}
64+
65+
public void Draw(Rect position, SerializedProperty property, GUIContent label)
66+
{
67+
if (m_error != null)
68+
{
69+
EditorScriptUtility.DrawWrongTypeMessage(position, label, m_error);
70+
return;
71+
}
72+
73+
if (m_array)
74+
BitArrayMaskDrawer.Draw(position, m_label, ref m_win, Tuple.Create(property, m_names));
75+
else
76+
property.intValue = EditorGUI.MaskField(position, m_label, property.intValue, m_names);
77+
}
78+
}
79+
80+
private Data m_data;
81+
82+
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
83+
{
84+
if (m_data == null)
85+
m_data = new Data(property, this);
86+
87+
m_data.Draw(position, property, label);
88+
}
89+
}
90+
}

Editor/Drawers/BitMaskEnumFlagsDrawer.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.

Editor/Drawers/BytesDrawer.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using UU;
2+
using UU.MathExt;
3+
using UnityEditor;
4+
using UnityEngine;
5+
6+
namespace UUEditor.Drawers
7+
{
8+
[CustomPropertyDrawer(typeof(Bytes))]
9+
internal class BytesDrawer : PropertyDrawer
10+
{
11+
private bool m_inited;
12+
private GUIContent[] m_labels;
13+
private int[] m_values;
14+
15+
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
16+
{
17+
if (!m_inited)
18+
{
19+
var lbl = new GUIContent();
20+
m_labels = new GUIContent[Bytes.SIZE];
21+
for (int i = 0; i < Bytes.SIZE; i++)
22+
m_labels[i] = lbl;
23+
24+
m_values = new int[Bytes.SIZE];
25+
26+
m_inited = true;
27+
}
28+
29+
SerializedProperty field = property.FindPropertyRelative(Bytes.SerFieldName);
30+
Bytes value = field.intValue;
31+
32+
for (int i = 0; i < Bytes.SIZE; i++)
33+
m_values[i] = value[i];
34+
35+
Rect rect = EditorGUI.PrefixLabel(position, label);
36+
EditorGUI.MultiIntField(rect, m_labels, m_values);
37+
38+
for (int i = 0; i < Bytes.SIZE; i++)
39+
value[i] = (byte)m_values[i].Clamp(0, byte.MaxValue);
40+
41+
field.intValue = (int)value;
42+
}
43+
}
44+
}

Editor/Drawers/BytesDrawer.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.

Editor/Drawers/DrawSOFieldsDrawer.cs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using UnityObject = UnityEngine.Object;
2+
using UnityEngine;
3+
using UU;
4+
using UnityEditor;
5+
6+
namespace UUEditor.Drawers
7+
{
8+
[CustomPropertyDrawer(typeof(DrawSOFieldsAttribute))]
9+
public class DrawSOFieldsDrawer : PropertyDrawer
10+
{
11+
private float m_height = EditorGUIUtility.singleLineHeight;
12+
13+
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
14+
{
15+
position.height = m_height = EditorGUIUtility.singleLineHeight;
16+
17+
if (!fieldInfo.FieldType.IsSubclassOf(typeof(ScriptableObject)))
18+
{
19+
EditorScriptUtility.DrawWrongTypeMessage(position, label, "Use DrawSOFields with ScriptableObject.");
20+
return;
21+
}
22+
23+
Rect foldPos = position;
24+
foldPos.width -= EditorGUI.PrefixLabel(position, label).width;
25+
property.isExpanded = EditorGUI.BeginFoldoutHeaderGroup(foldPos, property.isExpanded, string.Empty);
26+
27+
EditorGUI.PropertyField(position, property);
28+
29+
if (property.objectReferenceValue == null)
30+
return;
31+
32+
if (property.isExpanded)
33+
{
34+
SerializedObject serObject = new SerializedObject(property.objectReferenceValue);
35+
SerializedProperty iterator = serObject.GetIterator();
36+
37+
Rect rect = position;
38+
rect.y += EditorGUIUtility.singleLineHeight;
39+
40+
EditorGUI.indentLevel++;
41+
42+
for (bool enterChildren = true; iterator.NextVisible(enterChildren); enterChildren = false)
43+
{
44+
if (iterator.propertyPath == "m_Script")
45+
continue;
46+
47+
EditorGUI.PropertyField(rect, iterator, true);
48+
float shift = EditorGUI.GetPropertyHeight(iterator);
49+
rect.y += shift;
50+
m_height += shift;
51+
}
52+
53+
EditorGUI.indentLevel--;
54+
serObject.ApplyModifiedProperties();
55+
}
56+
57+
EditorGUI.EndFoldoutHeaderGroup();
58+
}
59+
60+
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
61+
{
62+
return m_height;
63+
}
64+
}
65+
}

Editor/Drawers/DrawSOFieldsDrawer.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.

Editor/Drawers/PercentDrawer.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using UnityEngine;
2+
using UnityEditor;
3+
using UU;
4+
5+
namespace UUEditor.Drawers
6+
{
7+
[CustomPropertyDrawer(typeof(Percent))]
8+
internal class PercentDrawer : PropertyDrawer
9+
{
10+
private string m_name;
11+
12+
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
13+
{
14+
if (m_name == null)
15+
{
16+
m_name = property.displayName + " (%)";
17+
}
18+
19+
SerializedProperty field = property.FindPropertyRelative(Percent.SerFieldName);
20+
field.floatValue = EditorGUI.FloatField(position, m_name, field.floatValue / Percent.PERCENT_2_RATIO) * Percent.PERCENT_2_RATIO;
21+
}
22+
}
23+
}

Editor/Drawers/PercentDrawer.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.

0 commit comments

Comments
 (0)