Skip to content

Instantly share code, notes, and snippets.

@fuzzblob
Created March 10, 2017 16:54
Show Gist options
  • Save fuzzblob/b6f84688e3dbade9abfa7240af299abb to your computer and use it in GitHub Desktop.
Save fuzzblob/b6f84688e3dbade9abfa7240af299abb to your computer and use it in GitHub Desktop.
a collection of Unity editor scripting calls for custom inspectors and tools
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