public override void OnInspectorGUI() { // DrawDefaultInspector(); if (GUI.Button(new Rect(EditorGUIUtility.currentViewWidth - 40, 2, 18, 18), Delete, GUIStyle.none)) { if (EditorUtility.DisplayDialog("Confirm", "Are you sure you want to delete this modifier?", "Yes", "Cancel")) { DestroyImmediate(TubeMesh.MeshHolder); DestroyImmediate(TubeMesh); } } GUILayout.Space(20); EditorGUI.BeginChangeCheck(); var flipHandles = EditorGUILayout.EnumPopup("Flip Faces", TubeMesh.FlipFaces); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(TubeMesh, "Flip faces value changed"); TubeMesh.FlipFaces = (Switch)flipHandles; TubeMesh.DrawMesh(); } EditorGUI.BeginChangeCheck(); var twoSided = EditorGUILayout.EnumPopup("Two Sided", TubeMesh.TwoSided); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(TubeMesh, "Two sided value changed"); TubeMesh.TwoSided = (Switch)twoSided; TubeMesh.DrawMesh(); } EditorGUI.BeginChangeCheck(); var radius = EditorGUILayout.FloatField("Radius", TubeMesh.Radius); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(TubeMesh, "Radius changed"); TubeMesh.Radius = radius; TubeMesh.DrawMesh(); } EditorGUI.BeginChangeCheck(); var segments = EditorGUILayout.IntField("Segments", TubeMesh.Segments); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(TubeMesh, "Segments changed"); if (segments < 1) { segments = 1; } TubeMesh.Segments = segments; TubeMesh.DrawMesh(); } EditorGUI.BeginChangeCheck(); var material = (Material)EditorGUILayout.ObjectField("Material", TubeMesh.Material, typeof(Material), true); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(TubeMesh, "materialchanged"); TubeMesh.Material = material; TubeMesh.MeshRenderer.sharedMaterial = TubeMesh.Material; } EditorGUI.BeginChangeCheck(); var uVRotation = EditorGUILayout.FloatField("Uv Rotation", TubeMesh.UVRotation); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(TubeMesh, "UV Rotation changed"); TubeMesh.UVRotation = uVRotation; TubeMesh.DrawMesh(); } if (GUILayout.Button("Save Prefab")) { SplinePlusEditorAPI.SavePrefab(TubeMesh.MeshHolder, "TubeMesh"); } }
public override void OnInspectorGUI() { // DrawDefaultInspector(); if (GUI.Button(new Rect(EditorGUIUtility.currentViewWidth - 40, 2, 18, 18), Delete, GUIStyle.none)) { if (EditorUtility.DisplayDialog("Confirm", "Are you sure you want to delete this modifier?", "Yes", "Cancel")) { DestroyImmediate(PlaneMesh.MeshHolder); DestroyImmediate(PlaneMesh); } } GUILayout.Space(20); EditorGUI.BeginChangeCheck(); var flipFaces = EditorGUILayout.EnumPopup("Flip Faces", PlaneMesh.FlipFaces); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(PlaneMesh, "Flip faces value changed"); PlaneMesh.FlipFaces = (Switch)flipFaces; PlaneMesh.DrawMesh(); } EditorGUI.BeginChangeCheck(); var twoSided = EditorGUILayout.EnumPopup("Two Sided", PlaneMesh.TwoSided); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(PlaneMesh, "Two sided value changed"); PlaneMesh.TwoSided = (Switch)twoSided; PlaneMesh.DrawMesh(); } EditorGUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); var MaxWidth = EditorGUILayout.FloatField("Width", PlaneMesh.Width); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(PlaneMesh, "Max width changed"); PlaneMesh.Width = MaxWidth; PlaneMesh.DrawMesh(); } EditorGUI.BeginChangeCheck(); var axis = EditorGUILayout.EnumPopup(PlaneMesh.SPData.SplineSettings.ReferenceAxis, GUILayout.Width(60)); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(PlaneMesh.SPData.SplinePlus, "PlaneMesh axis value changed"); PlaneMesh.SPData.SplineSettings.ReferenceAxis = (RefAxis)axis; PlaneMesh.DrawMesh(); } EditorGUILayout.EndHorizontal(); EditorGUI.BeginChangeCheck(); var material = (Material)EditorGUILayout.ObjectField("Material", PlaneMesh.Material, typeof(Material), true); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(PlaneMesh, "materialchanged"); PlaneMesh.Material = material; PlaneMesh.MeshRenderer.sharedMaterial = PlaneMesh.Material; } EditorGUI.BeginChangeCheck(); var uVRotation = EditorGUILayout.FloatField("Uv Rotation", PlaneMesh.UVRotation); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(PlaneMesh, "UV Rotation changed"); PlaneMesh.UVRotation = uVRotation; PlaneMesh.DrawMesh(); } if (GUILayout.Button("Save Prefab")) { SplinePlusEditorAPI.SavePrefab(PlaneMesh.MeshHolder, "PlaneMesh"); } }