protected void ModifierGUI() { GUIContent[] con = new GUIContent[attrList.Count]; for (int i = 0; i < con.Length; i++) { con[i] = new GUIContent(attrList[i].Name); } int index = EditorGUILayout.Popup(new GUIContent("Modifier Type"), selectedId, con); if (selectedId != index) { selectedId = index; foreach (var item in targets) { DestroyImmediate((item as ProceduralImage).GetComponent <ProceduralImageModifier>(), true); (item as ProceduralImage).ModifierType = ModifierUtility.GetTypeWithId(attrList[selectedId].Name); MoveComponentBehind((item as ProceduralImage), (item as ProceduralImage).GetComponent <ProceduralImageModifier>()); } //Exit GUI prevents Unity from trying to draw destroyed components editor; EditorGUIUtility.ExitGUI(); } }
protected void ModifierGUI() { GUIContent[] con = new GUIContent[attrList.Count]; for (int i = 0; i < con.Length; i++) { con[i] = new GUIContent(attrList[i].Name); } bool hasMultipleValues = false; if (targets.Length > 1) { Type t = (targets[0] as ProceduralImage).GetComponent <ProceduralImageModifier>().GetType(); foreach (var item in targets) { if ((item as ProceduralImage).GetComponent <ProceduralImageModifier>().GetType() != t) { hasMultipleValues = true; break; } } } if (!hasMultipleValues) { int index = EditorGUILayout.Popup(new GUIContent("Modifier Type"), selectedId, con); if (selectedId != index) { selectedId = index; foreach (var item in targets) { DestroyImmediate((item as ProceduralImage).GetComponent <ProceduralImageModifier>(), true); (item as ProceduralImage).ModifierType = ModifierUtility.GetTypeWithId(attrList[selectedId].Name); MoveComponentBehind((item as ProceduralImage), (item as ProceduralImage).GetComponent <ProceduralImageModifier>()); } //Exit GUI prevents Unity from trying to draw destroyed components editor; EditorGUIUtility.ExitGUI(); } } else { int index = EditorGUILayout.Popup(new GUIContent("Modifier Type"), -1, con); if (index != -1) { selectedId = index; foreach (var item in targets) { DestroyImmediate((item as ProceduralImage).GetComponent <ProceduralImageModifier>(), true); (item as ProceduralImage).ModifierType = ModifierUtility.GetTypeWithId(attrList[selectedId].Name); MoveComponentBehind((item as ProceduralImage), (item as ProceduralImage).GetComponent <ProceduralImageModifier>()); } //Exit GUI prevents Unity from trying to draw destroyed components editor; EditorGUIUtility.ExitGUI(); } } }