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))]
- [CanEditMultipleObjects]
- public class myClassEditorMultiple : Editor
- {
- SerializedProperty showVariables;
- SerializedProperty myInt;
- SerializedProperty myFloat;
- SerializedProperty myGameobject;
- SerializedProperty myColor;
- private void OnEnable()
- {
- showVariables = serializedObject.FindProperty("showVariables");
- myInt = serializedObject.FindProperty("myInt");
- myFloat = serializedObject.FindProperty("myFloat");
- myGameobject = serializedObject.FindProperty("myGameobject");
- myColor = serializedObject.FindProperty("myColor");
- }
- public override void OnInspectorGUI()
- {
- serializedObject.Update();
- showVariables.boolValue = EditorGUILayout.Toggle("Show variables", showVariables.boolValue);
- using (var showVariablesGroup = new EditorGUILayout.FadeGroupScope(Convert.ToSingle(showVariables.boolValue)))
- {
- if (showVariablesGroup.visible == true)
- {
- EditorGUILayout.DelayedIntField(myInt, new GUIContent("Integer"));
- EditorGUILayout.Slider(myFloat, 0.0f, 10.0f, new GUIContent("Float slider"));
- EditorGUILayout.ObjectField(myGameobject, new GUIContent("A gameobject"));
- EditorGUILayout.ColorField(new GUIContent("Color"), myColor.colorValue);
- }
- }
- serializedObject.ApplyModifiedProperties();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement