16 [CanEditMultipleObjects]
17 [CustomEditor(typeof(LeapGraphic), editorForChildClasses:
true, isFallback =
true)]
24 private SerializedProperty _featureList;
25 private SerializedProperty _featureTable;
37 _featureList = serializedObject.FindProperty(
"_featureData");
47 if (
targets.Query().All(g => g.isAttachedToGroup)) {
48 var mainRenderer =
targets[0].attachedGroup.renderer;
49 if (
targets.Query().All(g => g.attachedGroup.renderer == mainRenderer)) {
50 mainGroup =
targets[0].attachedGroup;
51 if (
targets.Query().All(g => g.attachedGroup == mainGroup)) {
52 sharedGroup = mainGroup;
59 base.OnInspectorGUI();
65 using (
new GUILayout.HorizontalScope()) {
68 Color originalColor = GUI.color;
71 if (!
targets.Query().All(g => g.attachedGroup == mainGroup)) {
73 }
else if (mainGroup ==
null) {
75 GUI.color =
Color.yellow;
77 buttonText = mainGroup.
name;
84 if (GUILayout.Button(buttonText, EditorStyles.miniButton, GUILayout.Width(60))) {
85 GenericMenu groupMenu =
new GenericMenu();
86 groupMenu.AddItem(
new GUIContent(
"None"),
false, () => {
87 foreach (var graphic
in targets) {
88 serializedObject.ApplyModifiedProperties();
91 EditorUtility.SetDirty(graphic);
93 serializedObject.SetIsDifferentCacheDirty();
94 serializedObject.Update();
98 if (renderer !=
null) {
100 foreach (var group
in renderer.groups.Query().Where(g => g.renderingMethod.IsValidGraphic(
targets[0]))) {
101 groupMenu.AddItem(
new GUIContent(index.ToString() +
": " + group.name),
false, () => {
103 bool areFeaturesUnequal = false;
104 var typesA = group.features.Query().Select(f => f.GetType()).ToList();
105 foreach (var graphic in targets) {
106 if (!graphic.isAttachedToGroup) {
110 var typesB = graphic.attachedGroup.features.Query().Select(f => f.GetType()).ToList();
111 if (!Utils.AreEqualUnordered(typesA, typesB)) {
112 areFeaturesUnequal = true;
118 if (!EditorUtility.DisplayDialog(
"Features Are Different!",
119 "The group you are moving to has a different feature set than the current group, " +
120 "this can result in data loss! Are you sure you want to change group?",
127 foreach (var graphic
in targets) {
128 serializedObject.ApplyModifiedProperties();
130 if (graphic.isAttachedToGroup) {
131 if (graphic.TryDetach()) {
132 group.TryAddGraphic(graphic);
135 group.TryAddGraphic(graphic);
138 EditorUtility.SetDirty(graphic);
139 EditorUtility.SetDirty(renderer);
141 serializedObject.SetIsDifferentCacheDirty();
142 serializedObject.Update();
145 renderer.editor.ScheduleRebuild();
151 groupMenu.ShowAsContext();
154 GUI.color = originalColor;
161 if (targets.Length == 0)
return;
162 var mainGraphic = targets[0];
164 if (mainGraphic.featureData.Count == 0) {
168 if (mainGraphic.attachedGroup !=
null) {
169 SpriteAtlasUtil.ShowInvalidSpriteWarning(mainGraphic.attachedGroup.features);
173 if (targets.Query().Any(e => e.attachedGroup !=
null && e.attachedGroup.graphics.IndexOf(e) >= maxGraphics)) {
174 string noun = targets.Length == 1 ?
"This graphic" :
"Some of these graphics";
175 string rendererName = targets.Length == 1 ?
"its renderer" :
"their renderers";
176 EditorGUILayout.HelpBox(noun +
" may not be properly displayed because there are too many graphics on " + rendererName +
". " +
177 "Either lower the number of graphics or increase the maximum graphic count by visiting " +
178 "Edit->Preferences.", MessageType.Warning);
182 if (!targets.Query().Select(g => g.attachedGroup).AllEqual()) {
186 EditorGUILayout.Space();
188 using (
new GUILayout.HorizontalScope()) {
189 EditorGUILayout.LabelField(
"Feature Data: ", EditorStyles.boldLabel);
191 if (sharedGroup !=
null) {
193 if (meshRendering !=
null && meshRendering.IsAtlasDirty && !EditorApplication.isPlaying) {
194 if (GUILayout.Button(
"Refresh Atlas", GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight))) {
196 sharedGroup.
renderer.editor.ScheduleRebuild();
202 for (
int i = 0; i < _featureTable.arraySize; i++) {
203 var idIndex = _featureTable.GetArrayElementAtIndex(i);
207 if (mainGraphic.attachedGroup !=
null) {
208 currentFeature = mainGraphic.attachedGroup.features[i];
211 EditorGUI.indentLevel++;
213 EditorGUILayout.PropertyField(dataProp, includeChildren:
true);
215 EditorGUI.indentLevel--;
217 currentFeature =
null;
220 serializedObject.ApplyModifiedProperties();
225 return targets.Query().
226 Any(t => t.editor.pickingMesh !=
null);
230 return targets.Query().
231 Select(e => e.editor.pickingMesh).
233 Select(m => m.bounds).
void dontShowScriptField()
void hideField(string propertyName)
void drawScriptField(bool disable=true)
void drawFeatureData(LeapGraphicGroup sharedGroup)
void drawScriptAndGroupGui(LeapGraphicGroup mainGroup)
override void OnInspectorGUI()
static LeapGraphicFeatureBase currentFeature
Bounds OnGetFrameBounds()
LeapRenderingMethod renderingMethod
Gets the rendering method used for this group. This can only be changed at edit time using either the...
LeapGraphicRenderer renderer
Gets the renderer this group is attached to.
static bool promptWhenGroupChange
static string GetTagName(Type type)
This class allows you to easily give feedback of an action as it completes.
A utility struct for ease of use when you want to wrap a piece of code in a Profiler....