Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEditor;
- using System;
- [CustomEditor(typeof(myClass))]
- public class myClassEditor : Editor
- {
- public override void OnInspectorGUI()
- {
- myClass scriptToEdit = (myClass)target;
- //Used to hide all variables instead of greying them out.
- //scriptToEdit.showVariables = EditorGUILayout.Toggle("Show variables", scriptToEdit.showVariables);
- //using (var showVariablesGroup = new EditorGUILayout.FadeGroupScope(Convert.ToSingle(scriptToEdit.showVariables)))
- //{
- //if (showVariablesGroup.visible == true)
- //{
- //}
- using (var showVariablesGroup = new EditorGUILayout.ToggleGroupScope("Show variables", scriptToEdit.showVariables))
- {
- scriptToEdit.showVariables = showVariablesGroup.enabled;
- //Indents the text in the inspector 1 step.
- EditorGUI.indentLevel++;
- //This creates a regular field that takes an integer, just like public or serializeable will do.
- scriptToEdit.myInt = EditorGUILayout.IntField("Here you can add a label to your field", scriptToEdit.myInt);
- //This creates a slider for a floating point between 0 and 10
- scriptToEdit.myFloat = EditorGUILayout.Slider("This is a slider", scriptToEdit.myFloat, 0.0f, 10.0f);
- //This creates a field that tales a game object
- //the last "true" is a bool that allows/disallows objects from the scene to be used.
- scriptToEdit.myGameobject =
- (GameObject)EditorGUILayout.ObjectField("This field lets you add a gameobject", scriptToEdit.myGameobject, typeof(GameObject), true);
- //Creates a small spacing between the last control and the next one.
- EditorGUILayout.Space();
- //This provides a field where the user can select a color from the RGB spectrum.
- scriptToEdit.myColor = EditorGUILayout.ColorField("Here there be colors", scriptToEdit.myColor);
- //Moves the indentation 1 step to the left.
- EditorGUI.indentLevel--;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement