Skip to content

Commit b877ec1

Browse files
committed
Init
1 parent 3065c99 commit b877ec1

33 files changed

Lines changed: 2581 additions & 0 deletions

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
################################################################################
2+
# 此 .gitignore 文件已由 Microsoft(R) Visual Studio 自动创建。
3+
################################################################################
4+
5+
/UnityProject/Library
6+
/UnityProject/Temp
7+
/UnityProject/UnityProject.CSharp.csproj
8+
/UnityProject/UnityProject.CSharp.Editor.csproj
9+
/UnityProject/UnityProject.CSharp.Editor.csproj.DotSettings
10+
/UnityProject/UnityProject.sln
11+
/UnityProject/UnityProject.v12.suo

UnityProject/Assets/ComponentFind.meta

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

UnityProject/Assets/ComponentFind/Editor.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
using UnityEditor;
2+
using UnityEngine;
3+
using UnityTable;
4+
5+
namespace ComponentFind
6+
{
7+
public class ComponentFindWindow : EditorWindow
8+
{
9+
[MenuItem("Tools/Windows/ComponentFindWindow")]
10+
public static void Open()
11+
{
12+
GetWindow<ComponentFindWindow>();
13+
}
14+
15+
private SerializedPropertyTable m_table;
16+
17+
public void OnGUI()
18+
{
19+
using (new EditorGUILayout.VerticalScope())
20+
{
21+
if (m_table != null)
22+
{
23+
m_table.OnGUI();
24+
}
25+
}
26+
}
27+
28+
public void OnEnable()
29+
{
30+
m_table = new SerializedPropertyTable("Table", FindObjects, CreateCameraColumn);
31+
}
32+
33+
private Camera[] FindObjects()
34+
{
35+
return FindObjectsOfType<Camera>();
36+
}
37+
38+
39+
private SerializedPropertyTreeView.Column[] CreateCameraColumn(out string[] propnames)
40+
{
41+
propnames = new string[3];
42+
var columns = new SerializedPropertyTreeView.Column[3];
43+
columns[0] = new SerializedPropertyTreeView.Column
44+
{
45+
headerContent = new GUIContent("Name"),
46+
headerTextAlignment = TextAlignment.Left,
47+
sortedAscending = true,
48+
sortingArrowAlignment = TextAlignment.Center,
49+
width = 200,
50+
minWidth = 25f,
51+
maxWidth = 400,
52+
autoResize = false,
53+
allowToggleVisibility = true,
54+
propertyName = null,
55+
dependencyIndices = null,
56+
compareDelegate = SerializedPropertyTreeView.DefaultDelegates.s_CompareName,
57+
drawDelegate = SerializedPropertyTreeView.DefaultDelegates.s_DrawName,
58+
filter = new SerializedPropertyFilters.Name()
59+
};
60+
columns[1] = new SerializedPropertyTreeView.Column
61+
{
62+
headerContent = new GUIContent("On"),
63+
headerTextAlignment = TextAlignment.Left,
64+
sortedAscending = true,
65+
sortingArrowAlignment = TextAlignment.Center,
66+
width = 25,
67+
autoResize = false,
68+
allowToggleVisibility = true,
69+
propertyName = "m_Enabled",
70+
dependencyIndices = null,
71+
compareDelegate = SerializedPropertyTreeView.DefaultDelegates.s_CompareCheckbox,
72+
drawDelegate = SerializedPropertyTreeView.DefaultDelegates.s_DrawCheckbox,
73+
};
74+
75+
columns[2] = new SerializedPropertyTreeView.Column
76+
{
77+
headerContent = new GUIContent("Mask"),
78+
headerTextAlignment = TextAlignment.Left,
79+
sortedAscending = true,
80+
sortingArrowAlignment = TextAlignment.Center,
81+
width = 200,
82+
minWidth = 25f,
83+
maxWidth = 400,
84+
autoResize = false,
85+
allowToggleVisibility = true,
86+
propertyName = "m_CullingMask",
87+
dependencyIndices = null,
88+
compareDelegate = SerializedPropertyTreeView.DefaultDelegates.s_CompareInt,
89+
drawDelegate = SerializedPropertyTreeView.DefaultDelegates.s_DrawDefault,
90+
filter = new SerializedPropertyFilters.Name()
91+
};
92+
for (var i = 0; i < columns.Length; i++)
93+
{
94+
var column = columns[i];
95+
propnames[i] = column.propertyName;
96+
}
97+
98+
return columns;
99+
}
100+
}
101+
}

UnityProject/Assets/ComponentFind/Editor/ComponentFindWindow.cs.meta

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

UnityProject/Assets/UnityTable.meta

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

UnityProject/Assets/UnityTable/Editor.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
using System.Collections.Generic;
2+
using UnityEditor;
3+
using UnityEngine;
4+
using UnityEngine.Profiling;
5+
6+
namespace UnityTable
7+
{
8+
internal class SerializedPropertyDataStore
9+
{
10+
private Data[] m_elements;
11+
12+
private readonly GatherDelegate m_gatherDel;
13+
14+
private Object[] m_objects;
15+
16+
private readonly string[] m_propNames;
17+
18+
public SerializedPropertyDataStore(string[] propNames, GatherDelegate gatherDel)
19+
{
20+
m_propNames = propNames;
21+
m_gatherDel = gatherDel;
22+
Repopulate();
23+
}
24+
25+
public Data[] GetElements()
26+
{
27+
return m_elements;
28+
}
29+
30+
~SerializedPropertyDataStore()
31+
{
32+
Clear();
33+
}
34+
35+
public bool Repopulate()
36+
{
37+
Profiler.BeginSample("SerializedPropertyDataStore.Repopulate.GatherDelegate");
38+
var array = m_gatherDel();
39+
Profiler.EndSample();
40+
if (m_objects != null)
41+
{
42+
if (array.Length == m_objects.Length &&
43+
ArrayUtility.ArrayReferenceEquals(array, m_objects))
44+
{
45+
return false;
46+
}
47+
Clear();
48+
}
49+
m_objects = array;
50+
m_elements = new Data[array.Length];
51+
for (var i = 0; i < array.Length; i++)
52+
m_elements[i] = new Data(array[i], m_propNames);
53+
return true;
54+
}
55+
56+
private void Clear()
57+
{
58+
foreach (var t in m_elements)
59+
t.Dispose();
60+
m_objects = null;
61+
m_elements = null;
62+
}
63+
64+
internal class Data
65+
{
66+
private Object m_object;
67+
68+
public Data(Object obj, IList<string> props)
69+
{
70+
m_object = obj;
71+
SerializedObject = new SerializedObject(obj);
72+
Properties = new SerializedProperty[props.Count];
73+
for (var i = 0; i < props.Count; i++)
74+
Properties[i] = SerializedObject.FindProperty(props[i]);
75+
}
76+
77+
public string Name
78+
{
79+
get { return !(m_object != null) ? string.Empty : m_object.name; }
80+
}
81+
82+
public SerializedObject SerializedObject { get; private set; }
83+
84+
public SerializedProperty[] Properties { get; private set; }
85+
86+
public int ObjectId
87+
{
88+
get
89+
{
90+
int result;
91+
if (!m_object)
92+
{
93+
result = 0;
94+
}
95+
else
96+
{
97+
var component = m_object as Component;
98+
result = !(component != null)
99+
? m_object.GetInstanceID()
100+
: component.gameObject.GetInstanceID();
101+
}
102+
return result;
103+
}
104+
}
105+
106+
public void Dispose()
107+
{
108+
var serializedProperties = Properties;
109+
for (var i = 0; i < serializedProperties.Length; i++)
110+
{
111+
var serializedProperty = serializedProperties[i];
112+
if (serializedProperty != null)
113+
serializedProperty.Dispose();
114+
}
115+
SerializedObject.Dispose();
116+
m_object = null;
117+
SerializedObject = null;
118+
Properties = null;
119+
}
120+
121+
public bool Update()
122+
{
123+
return m_object != null && SerializedObject.UpdateIfRequiredOrScript();
124+
}
125+
126+
public void Store()
127+
{
128+
if (m_object != null)
129+
SerializedObject.ApplyModifiedProperties();
130+
}
131+
}
132+
133+
internal delegate Object[] GatherDelegate();
134+
}
135+
}

UnityProject/Assets/UnityTable/Editor/SerializedPropertyDataStore.cs.meta

Lines changed: 12 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)