Created
March 10, 2017 16:54
-
-
Save fuzzblob/b6f84688e3dbade9abfa7240af299abb to your computer and use it in GitHub Desktop.
a collection of Unity editor scripting calls for custom inspectors and tools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EditorUtils | |
{ | |
public static bool WarningDialog(string message = "") | |
{ | |
if (message == "") | |
message = "Are you sure you want to Continue?"; | |
if (EditorUtility.DisplayDialog("Continue ?", message, "Continue", "Cancel")) | |
{ | |
return true; | |
} | |
else { return false; } | |
} | |
public static float ResettableSlider(string valString, float val, float min, float max, float resetValue) | |
{ | |
float ret; | |
EditorGUI.indentLevel++; | |
EditorGUILayout.BeginHorizontal(); | |
EditorGUILayout.Space(); | |
valString = (valString + val.ToString("0.00")); | |
if (GUILayout.Button(valString, MoonaEditors.__buttonOptions)) | |
{ | |
ret = resetValue; | |
val = resetValue; | |
} | |
GUILayout.Space(30f); | |
ret = GUILayout.HorizontalSlider(val, min, max, MoonaEditors.__sliderOptions); | |
ret = Mathf.Clamp( | |
EditorGUILayout.FloatField(ret, /*GUILayout.MinWidth(20), */GUILayout.ExpandWidth(false)), | |
min, max); | |
EditorGUILayout.Space(); | |
EditorGUILayout.EndHorizontal(); | |
EditorGUILayout.Space(); | |
EditorGUI.indentLevel--; | |
return ret; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment