public void GetBodyMeshLinkType(JelloBody t) { if(t.meshLink == null) t.meshLink = t.GetComponent<MeshLink>(); if(t.meshLink == null) return; foreach(MeshLink.MeshLinkType mltype in (MeshLink.MeshLinkType[])Enum.GetValues(typeof(MeshLink.MeshLinkType))) { if(t.meshLink.GetType().ToString() == mltype.ToString()) { t.meshLink.meshLinkType = mltype; break; } } meshLinkType = t.meshLink.meshLinkType; }
public void GetBodyMeshLinkType(JelloBody t) { if(t.meshLink == null) t.meshLink = t.GetComponent<MeshLink>(); if(t.meshLink == null) return; foreach(MeshLink.MeshLinkType mltype in (MeshLink.MeshLinkType[])Enum.GetValues(typeof(MeshLink.MeshLinkType))) { if(t.meshLink.GetType().ToString() == mltype.ToString()) { t.meshLink.meshLinkType = mltype; break; } } meshLinkType = t.meshLink.meshLinkType; }
public virtual void DrawEditorGUITwo() { serializedObject.Update(); if(tar.GetComponent<MeshLink>() != null) hasMeshLink = true; else hasMeshLink = false; EditorGUILayout.BeginHorizontal(); SerializedProperty eMeshLink = serializedObject.FindProperty("meshLink"); GUIStyle meshStyle = new GUIStyle(EditorStyles.popup); if(eMeshLink.prefabOverride) meshStyle.fontStyle = FontStyle.Bold; meshLinkType = (MeshLink.MeshLinkType)EditorGUILayout.EnumPopup(meshLinkTypeContent, meshLinkType, meshStyle); bool showChangeButton = false; if(hasMeshLink) { if(tar.GetComponent<MeshLink>().meshLinkType != meshLinkType) showChangeButton = true; } else if(meshLinkType != MeshLink.MeshLinkType.None) { showChangeButton = true; } if(showChangeButton) { if(GUILayout.Button(changeTypeContent, EditorStyles.miniButton)) { for(int i = 0; i < serializedObject.targetObjects.Length; i++) ChangeMeshLink((JelloBody)serializedObject.targetObjects[i]); } } EditorGUILayout.EndHorizontal(); colliderType = (ColliderType)EditorGUILayout.EnumPopup(bodyTypeContent, colliderType, EditorStyles.miniButton); EditorGUILayout.BeginHorizontal(); if(CompareEnumStateWithType(tar)) { EditorGUI.indentLevel++; if(GUILayout.Button(new GUIContent(changeTypeContent), EditorStyles.miniButton )) //todo make this change all targets { JelloBody[] oldTargets = new JelloBody[targets.Length]; for(int i = 0; i < serializedObject.targetObjects.Length; i++) { JelloBody t = (JelloBody)serializedObject.targetObjects[i]; ChangeBodyType(t, retainBodyInformation); oldTargets[i] = t; } for(int i = 0; i < oldTargets.Length; i++) { Undo.DestroyObjectImmediate (oldTargets[i]); } return; } retainBodyInformation = EditorGUILayout.Toggle(keepInfoContent, retainBodyInformation); EditorGUI.indentLevel--; } EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); string[] options = new string[subEditors.Count]; for(int i = 0; i < options.Length; i++) options[i] = subEditors[i].name; currentSubEditor = EditorGUILayout.Popup("SubComponent", currentSubEditor, options); EditorGUILayout.EndHorizontal(); subEditors[currentSubEditor].DrawEditorGUI(); serializedObject.ApplyModifiedProperties(); }
public virtual void DrawEditorGUITwo() { serializedObject.Update(); if(tar.GetComponent<MeshLink>() != null) hasMeshLink = true; else hasMeshLink = false; EditorGUILayout.BeginHorizontal(); SerializedProperty eMeshLink = serializedObject.FindProperty("meshLink"); GUIStyle meshStyle = new GUIStyle(EditorStyles.popup); if(eMeshLink.prefabOverride) meshStyle.fontStyle = FontStyle.Bold; meshLinkType = (MeshLink.MeshLinkType)EditorGUILayout.EnumPopup(meshLinkTypeContent, meshLinkType, meshStyle); bool showChangeButton = false; if(hasMeshLink) { if(tar.GetComponent<MeshLink>().meshLinkType != meshLinkType) showChangeButton = true; } else if(meshLinkType != MeshLink.MeshLinkType.None) { showChangeButton = true; } if(showChangeButton) { if(GUILayout.Button(changeTypeContent, EditorStyles.miniButton)) { for(int i = 0; i < serializedObject.targetObjects.Length; i++) ChangeMeshLink((JelloBody)serializedObject.targetObjects[i]); } } EditorGUILayout.EndHorizontal(); colliderType = (ColliderType)EditorGUILayout.EnumPopup(bodyTypeContent, colliderType, EditorStyles.miniButton); EditorGUILayout.BeginHorizontal(); if(CompareEnumStateWithType(tar)) { EditorGUI.indentLevel++; if(GUILayout.Button(new GUIContent(changeTypeContent), EditorStyles.miniButton )) //todo make this change all targets { JelloBody[] oldTargets = new JelloBody[targets.Length]; for(int i = 0; i < serializedObject.targetObjects.Length; i++) { JelloBody t = (JelloBody)serializedObject.targetObjects[i]; ChangeBodyType(t, retainBodyInformation); oldTargets[i] = t; } for(int i = 0; i < oldTargets.Length; i++) { Undo.DestroyObjectImmediate (oldTargets[i]); } return; } retainBodyInformation = EditorGUILayout.Toggle(keepInfoContent, retainBodyInformation); EditorGUI.indentLevel--; } EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); string[] options = new string[subEditors.Count]; for(int i = 0; i < options.Length; i++) options[i] = subEditors[i].name; currentSubEditor = EditorGUILayout.Popup("SubComponent", currentSubEditor, options); EditorGUILayout.EndHorizontal(); subEditors[currentSubEditor].DrawEditorGUI(); serializedObject.ApplyModifiedProperties(); }