Skip to content

Commit 949da5c

Browse files
committed
Initial commit.
0 parents  commit 949da5c

File tree

138 files changed

+8045
-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.

138 files changed

+8045
-0
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.resharper
2+
*.cache
3+
*.suo
4+
*.user

Editor.meta

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/CustomEditorBase.cs

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
4+
using UnityEditor;
5+
6+
using UnityEngine;
7+
using UnityEngine.PlayerLoop;
8+
9+
namespace cmdwtf.UnityTools.Editor
10+
{
11+
public abstract class CustomEditorBase : UnityEditor.Editor
12+
{
13+
private List<IEnumerator> _runningCoroutines = new List<IEnumerator>();
14+
private string ObjectName => target == null ? string.Empty : target.name;
15+
16+
protected CustomEditorBase()
17+
{
18+
EditorApplication.update += Update;
19+
}
20+
21+
private void Update()
22+
{
23+
if (_runningCoroutines.Count <= 0)
24+
{
25+
return;
26+
}
27+
28+
int index = _runningCoroutines.Count - 1;
29+
30+
Debug.Log($"{ObjectName}: Executing Coroutine {index}");
31+
32+
bool coroutineFinished = !_runningCoroutines[index].MoveNext();
33+
34+
if (coroutineFinished)
35+
{
36+
Debug.Log($"{ObjectName}: Finished Coroutine {index}");
37+
_runningCoroutines.RemoveAt(index);
38+
}
39+
}
40+
41+
protected void DoChildEditor(Component child, bool recurse = true)
42+
{
43+
if (child == null)
44+
{
45+
return;
46+
}
47+
48+
var serialized = new SerializedObject(child);
49+
SerializedProperty prop = serialized.GetIterator();
50+
prop.NextVisible(true);
51+
52+
while (prop.NextVisible(recurse))
53+
{
54+
if (prop.name != "m_Script") // && prop.name.StartsWith("m_"))
55+
{
56+
EditorGUILayout.PropertyField(prop);
57+
}
58+
}
59+
60+
prop.Reset();
61+
62+
serialized.ApplyModifiedProperties();
63+
}
64+
65+
protected void StartCoroutine(IEnumerator cr)
66+
{
67+
_runningCoroutines.Add(cr);
68+
}
69+
}
70+
}

Editor/CustomEditorBase.cs.meta

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/CustomPropertyDrawerBase.cs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using cmdwtf.UnityTools.Attributes;
2+
3+
using UnityEditor;
4+
5+
using UnityEngine;
6+
7+
namespace cmdwtf.UnityTools.Editor
8+
{
9+
public class CustomPropertyDrawerBase : PropertyDrawer
10+
{
11+
protected int PropertyLineCount { get; set; } = 1;
12+
13+
protected virtual int GetPropertyLineCount(SerializedProperty property, GUIContent label) => 1;
14+
15+
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
16+
{
17+
PropertyLineCount = GetPropertyLineCount(property, label);
18+
float lineHeights = EditorGUIUtility.singleLineHeight * PropertyLineCount;
19+
float paddingHeights = EditorGUIUtility.standardVerticalSpacing * PropertyLineCount;
20+
return lineHeights + paddingHeights;
21+
}
22+
}
23+
}

Editor/CustomPropertyDrawerBase.cs.meta

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)