public bool EditButton(bool selected) { float width = 40f; editButtonContent.image = ResourceUtility.EditorLoadTexture("Splines/Editor/Icons", "edit_cursor"); if (editButtonContent.image != null) { editButtonContent.text = ""; width = 25f; } SplineEditorGUI.SetHighlightColors(SplinePrefs.highlightColor, SplinePrefs.highlightContentColor); if (SplineEditorGUI.EditorLayoutSelectableButton(editButtonContent, true, selected, GUILayout.Width(width))) { SceneView.RepaintAll(); return(true); } return(false); }
public override void OnInspectorGUI() { MeshGenerator generator = (MeshGenerator)target; if (generator.baked) { SplineEditorGUI.SetHighlightColors(SplinePrefs.highlightColor, SplinePrefs.highlightContentColor); if (SplineEditorGUI.EditorLayoutSelectableButton(new GUIContent("Revert Bake", "Makes the mesh dynamic again and allows editing"), true, true)) { for (int i = 0; i < generators.Length; i++) { generators[i].Unbake(); EditorUtility.SetDirty(generators[i]); } } return; } base.OnInspectorGUI(); }
void OnGUI() { if (tools == null) { Awake(); } GUI.color = new Color(0f, 0f, 0f, 0.15f); GUI.DrawTexture(new Rect(0, 0, menuWidth, position.height), SplineEditorGUI.white, ScaleMode.StretchToFill); GUI.color = Color.white; GUILayout.BeginHorizontal(); GUILayout.BeginScrollView(scroll, GUILayout.Width(menuWidth), GUILayout.Height(position.height - 10)); if (tools == null) { Init(); } SplineEditorGUI.SetHighlightColors(SplinePrefs.highlightColor, SplinePrefs.highlightContentColor); for (int i = 0; i < tools.Length; i++) { if (SplineEditorGUI.EditorLayoutSelectableButton(new GUIContent(tools[i].GetName()), true, toolIndex == i)) { if (toolIndex >= 0 && toolIndex < tools.Length) { tools[toolIndex].Close(); } toolIndex = i; if (toolIndex < tools.Length) { tools[toolIndex].Open(this); } } } GUILayout.EndScrollView(); if (toolIndex >= 0 && toolIndex < tools.Length) { GUILayout.BeginVertical(); tools[toolIndex].Draw(new Rect(menuWidth, 0, position.width - menuWidth - 5f, position.height - 10)); GUILayout.EndVertical(); } GUILayout.EndHorizontal(); }
void ConnectionsGUI() { Node node = (Node)target; Node.Connection[] connections = node.GetConnections(); EditorGUILayout.Space(); if (connections.Length > 0) { for (int i = 0; i < connections.Length; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(connections[i].spline.name + " at point " + (connections[i].pointIndex + 1)); if (GUILayout.Button("Select", GUILayout.Width(70))) { Selection.activeGameObject = connections[i].spline.gameObject; } SplineEditorGUI.SetHighlightColors(SplinePrefs.highlightColor, SplinePrefs.highlightContentColor); if (SplineEditorGUI.EditorLayoutSelectableButton(new GUIContent("Swap Tangents"), connections[i].spline.type == Spline.Type.Bezier, connections[i].invertTangents)) { connections[i].invertTangents = !connections[i].invertTangents; node.UpdateConnectedComputers(); SceneView.RepaintAll(); } if (GUILayout.Button("x", GUILayout.Width(20))) { Undo.RecordObject(node, "Remove connection"); Undo.RecordObject(connections[i].spline, "Remove node"); connections[i].spline.DisconnectNode(connections[i].pointIndex); node.RemoveConnection(connections[i].spline, connections[i].pointIndex); } EditorGUILayout.EndHorizontal(); } } else { EditorGUILayout.HelpBox("Drag & Drop SplineComputers here to link their points.", MessageType.Info); } }
public override void DrawInspector() { base.DrawInspector(); if (spline == null) { return; } SplineEditorGUI.SetHighlightColors(SplinePrefs.highlightColor, SplinePrefs.highlightContentColor); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); EditorGUI.BeginChangeCheck(); operationsToolbar.SetContent(0, new GUIContent(spline.isClosed ? "Break" : "Close")); operationsToolbar.SetContent(1, new GUIContent("Reverse")); operationsToolbar.SetContent(2, new GUIContent(spline.is2D ? "3D Mode" : "2D Mode")); operationsToolbar.Draw(ref operation); //operation = GUILayout.Toolbar(operation, new string[] { , "Reverse", text2D }, GUILayout.Width(220f)); if (EditorGUI.EndChangeCheck()) { PerformOperation(); } EditorGUI.BeginChangeCheck(); if (splines.Length == 1) { int mod = module; utilityToolbar.Draw(ref mod); if (EditorGUI.EndChangeCheck()) { ToggleModule(mod); } } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); if (module >= 0 && module < modules.Length) { modules[module].DrawInspector(); } EditorGUILayout.Space(); DreamteckEditorGUI.DrawSeparator(); EditorGUILayout.Space(); serializedObject.Update(); SerializedProperty splineProperty = serializedObject.FindProperty("spline"); SerializedProperty sampleRate = serializedObject.FindProperty("spline").FindPropertyRelative("sampleRate"); SerializedProperty type = serializedObject.FindProperty("spline").FindPropertyRelative("type"); SerializedProperty linearAverageDirection = splineProperty.FindPropertyRelative("linearAverageDirection"); SerializedProperty space = serializedObject.FindProperty("_space"); SerializedProperty sampleMode = serializedObject.FindProperty("_sampleMode"); SerializedProperty optimizeAngleThreshold = serializedObject.FindProperty("_optimizeAngleThreshold"); SerializedProperty updateMode = serializedObject.FindProperty("updateMode"); SerializedProperty rebuildOnAwake = serializedObject.FindProperty("rebuildOnAwake"); SerializedProperty multithreaded = serializedObject.FindProperty("multithreaded"); SerializedProperty customNormalInterpolation = splineProperty.FindPropertyRelative("customNormalInterpolation"); SerializedProperty customValueInterpolation = splineProperty.FindPropertyRelative("customValueInterpolation"); EditorGUI.BeginChangeCheck(); Spline.Type lastType = (Spline.Type)type.intValue; EditorGUILayout.PropertyField(type); if (lastType == Spline.Type.CatmullRom && type.intValue == (int)Spline.Type.Bezier) { if (EditorUtility.DisplayDialog("Hermite to Bezier", "Would you like to retain the Catmull Rom shape in Bezier mode?", "Yes", "No")) { for (int i = 0; i < splines.Length; i++) { splines[i].CatToBezierTangents(); } serializedObject.Update(); pathEditor.Refresh(); } } if (spline.type == Spline.Type.Linear) { EditorGUILayout.PropertyField(linearAverageDirection); } int lastSpace = space.intValue; EditorGUILayout.PropertyField(space, new GUIContent("Space")); EditorGUILayout.PropertyField(sampleMode, new GUIContent("Sample Mode")); if (sampleMode.intValue == (int)SplineComputer.SampleMode.Optimized) { EditorGUILayout.PropertyField(optimizeAngleThreshold); } EditorGUILayout.PropertyField(updateMode); if (updateMode.intValue == (int)SplineComputer.UpdateMode.None && Application.isPlaying) { if (GUILayout.Button("Rebuild")) { for (int i = 0; i < splines.Length; i++) { splines[i].RebuildImmediate(true, true); } } } if (spline.type != Spline.Type.Linear) { EditorGUILayout.PropertyField(sampleRate, new GUIContent("Sample Rate")); } EditorGUILayout.PropertyField(rebuildOnAwake); EditorGUILayout.PropertyField(multithreaded); EditorGUI.indentLevel++; bool curveUpdate = false; interpolationFoldout = EditorGUILayout.Foldout(interpolationFoldout, "Point Value Interpolation"); if (interpolationFoldout) { if (customValueInterpolation.animationCurveValue == null || customValueInterpolation.animationCurveValue.keys.Length == 0) { if (GUILayout.Button("Size & Color Interpolation")) { AnimationCurve curve = new AnimationCurve(); curve.AddKey(new Keyframe(0, 0, 0, 0)); curve.AddKey(new Keyframe(1, 1, 0, 0)); for (int i = 0; i < splines.Length; i++) { splines[i].customValueInterpolation = curve; } serializedObject.Update(); curveUpdate = true; } } else { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(customValueInterpolation, new GUIContent("Size & Color Interpolation")); if (GUILayout.Button("x", GUILayout.MaxWidth(25))) { customValueInterpolation.animationCurveValue = null; for (int i = 0; i < splines.Length; i++) { splines[i].customValueInterpolation = null; } serializedObject.Update(); curveUpdate = true; } EditorGUILayout.EndHorizontal(); } if (customNormalInterpolation.animationCurveValue == null || customNormalInterpolation.animationCurveValue.keys.Length == 0) { if (GUILayout.Button("Normal Interpolation")) { AnimationCurve curve = new AnimationCurve(); curve.AddKey(new Keyframe(0, 0)); curve.AddKey(new Keyframe(1, 1)); for (int i = 0; i < splines.Length; i++) { splines[i].customNormalInterpolation = curve; } serializedObject.Update(); curveUpdate = true; } } else { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(customNormalInterpolation, new GUIContent("Normal Interpolation")); if (GUILayout.Button("x", GUILayout.MaxWidth(25))) { customNormalInterpolation.animationCurveValue = null; for (int i = 0; i < splines.Length; i++) { splines[i].customNormalInterpolation = null; } serializedObject.Update(); curveUpdate = true; } EditorGUILayout.EndHorizontal(); } } EditorGUI.indentLevel--; if (EditorGUI.EndChangeCheck() || curveUpdate) { if (sampleRate.intValue < 2) { sampleRate.intValue = 2; } if (lastSpace != space.intValue) { for (int i = 0; i < splines.Length; i++) { splines[i].space = (SplineComputer.Space)space.intValue; } serializedObject.Update(); if (splines.Length == 1) { pathEditor.Refresh(); } } serializedObject.ApplyModifiedProperties(); for (int i = 0; i < splines.Length; i++) { splines[i].Rebuild(true); } } if (pathEditor.currentModule != null) { transformTool = 0; } EditorGUILayout.BeginHorizontal(); GUILayout.Label("Edit Transform"); GUILayout.FlexibleSpace(); int lastTool = transformTool; transformToolbar.Draw(ref transformTool); if (lastTool != transformTool && transformTool > 0) { pathEditor.UntoggleCurrentModule(); } EditorGUILayout.EndHorizontal(); }