Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by katy_cat · Apr 24, 2020 at 09:04 AM · performanceeditor-scriptingperformance optimizationcustom editor

Why is my Custom Inspector Causing Performance Issues?

I've attached the editor script and screenshots of the profiler breakdown (Both images taken from the same frame while multiselecting about 7 objects using this custom inspector).

Any help would be appreciated on how to improve the performance of this, I'm sure there is a simple solution that I'm just not seeing.

alt text

alt text

 using UnityEngine;
 using UnityEditor;
 
 [CanEditMultipleObjects]
 [CustomEditor(typeof(Button3D))]
 public class Button3DEditor : Editor
 {
 
     SerializedProperty mesh;
     SerializedProperty canvasRen;
     SerializedProperty text;
     SerializedProperty uguiText;
     SerializedProperty highlightedColor;
     SerializedProperty highlightedTextColor;
     SerializedProperty pressColor;
     SerializedProperty pressTextColor;
     SerializedProperty disabledColor;
     SerializedProperty disabledTextColor;
     SerializedProperty highlightedMat;
     SerializedProperty pressedMat;
     SerializedProperty disabledMat;
     SerializedProperty actionType;
     SerializedProperty highlightedScale;
     SerializedProperty pressedScale;
     SerializedProperty disabledScale;
     SerializedProperty highlightedTexture;
     SerializedProperty pressedTexture;
     SerializedProperty disabledTexture;
 
     private GUIContent ActionType;
     private GUIContent CanvasRenderer;
     private GUIContent TextObject;
     private GUIContent MeshObject;
     private GUIContent HighlightColor;
     private GUIContent PressedColor;
     private GUIContent DisabledColor;
     private GUIContent HighlightTexture;
     private GUIContent PressedTexture;
     private GUIContent DisabledTexture;
     private GUIContent HighlightMaterial;
     private GUIContent PressedMaterial;
     private GUIContent DisabledMaterial;
     private GUIContent HighlightScale;
     private GUIContent PressedScale;
     private GUIContent DisabledScale;
     private GUIContent HighlightTextColor;
     private GUIContent PressedTextColor;
     private GUIContent DisabledTextColor;
 
     private void OnEnable()
     {
 
 
         highlightedColor = serializedObject.FindProperty("highlightedColor");
         highlightedTextColor = serializedObject.FindProperty("highlightedTextColor");
         pressColor = serializedObject.FindProperty("pressColor");
         pressTextColor = serializedObject.FindProperty("pressTextColor");
         disabledColor = serializedObject.FindProperty("disabledColor");
         disabledTextColor = serializedObject.FindProperty("disabledTextColor");
         highlightedMat = serializedObject.FindProperty("highlight");
         disabledMat = serializedObject.FindProperty("disabled");
         pressedMat = serializedObject.FindProperty("pressedMat");
         text = serializedObject.FindProperty("text");
         uguiText = serializedObject.FindProperty("uguiText");
         mesh = serializedObject.FindProperty("mesh");
         canvasRen = serializedObject.FindProperty("canvasRen");
         actionType = serializedObject.FindProperty("actionType");
         highlightedScale = serializedObject.FindProperty("highlightedScale");
         pressedScale = serializedObject.FindProperty("pressScale");
         disabledScale = serializedObject.FindProperty("disabledScale");
         highlightedTexture = serializedObject.FindProperty("highlightedTex");
         pressedTexture = serializedObject.FindProperty("pressedTex");
         disabledTexture = serializedObject.FindProperty("disabledTex");
 
         ActionType = new GUIContent("Action Type");
         CanvasRenderer = new GUIContent("Canvas Renderer");
         TextObject = new GUIContent("Text Object");
         MeshObject = new GUIContent("Mesh Object");
         HighlightColor = new GUIContent("Color when highlighted");
         PressedColor = new GUIContent("Color when pressed");
         DisabledColor = new GUIContent("Color when disabled");
         HighlightTexture = new GUIContent("Highlight Texture");
         PressedTexture = new GUIContent("Pressed Texture");
         DisabledTexture = new GUIContent("Disabled Texture");
         HighlightMaterial = new GUIContent("Highlighted Material");
         PressedMaterial = new GUIContent("Pressed Material");
         DisabledMaterial = new GUIContent("Disabled Material");
         HighlightScale = new GUIContent("Highlight Scale Factor");
         PressedScale = new GUIContent("Pressed Scale Factor");
         DisabledScale = new GUIContent("Disabled Scale Factor");
         HighlightTextColor = new GUIContent("Highlighted Text Color");
         PressedTextColor = new GUIContent("Press Text Color");
         DisabledTextColor = new GUIContent("Disabled Text Color");
     }
 
     public override void OnInspectorGUI()
     {
         serializedObject.Update();
         base.OnInspectorGUI();
 
 
         EditorGUILayout.PropertyField(actionType, ActionType);
 
         //mesh options
         if ((target as Button3D).gameObject.transform as RectTransform != null)
         {
             EditorGUILayout.PropertyField(canvasRen, CanvasRenderer);
             EditorGUILayout.PropertyField(uguiText, TextObject);
         }
         else
         {
             EditorGUILayout.PropertyField(mesh, MeshObject);
             EditorGUILayout.PropertyField(text, TextObject);
         }
         if ((mesh != null && (mesh.objectReferenceValue as MeshRenderer) != null) || (canvasRen != null && (canvasRen.objectReferenceValue as CanvasRenderer) != null))
         {
             if (((Button3D.ActionType)actionType.intValue & Button3D.ActionType.ColorChange) != 0)
             {
                 EditorGUILayout.PropertyField(highlightedColor, HighlightColor);
                 EditorGUILayout.PropertyField(pressColor, PressedColor);
                 EditorGUILayout.PropertyField(disabledColor,DisabledColor);
             }
 
             if (((Button3D.ActionType)actionType.intValue & Button3D.ActionType.TextureChange) != 0)
             {
                 EditorGUILayout.PropertyField(highlightedTexture, HighlightTexture);
                 EditorGUILayout.PropertyField(pressedTexture,PressedTexture);
                 EditorGUILayout.PropertyField(disabledTexture,DisabledTexture);
             }
 
      
             if (((Button3D.ActionType)actionType.intValue & Button3D.ActionType.MaterialChange) != 0)
             {
                 EditorGUILayout.PropertyField(highlightedMat, HighlightMaterial);
                 EditorGUILayout.PropertyField(pressedMat, PressedMaterial);
                 EditorGUILayout.PropertyField(disabledMat,DisabledMaterial);
 
                 
             }
 
             if (((Button3D.ActionType)actionType.intValue & Button3D.ActionType.ScaleChange) != 0)
             {
                 EditorGUILayout.PropertyField(highlightedScale, HighlightScale);
                 EditorGUILayout.PropertyField(pressedScale, PressedScale);
                 EditorGUILayout.PropertyField(disabledScale, DisabledScale);
             }
         }
         if ((text != null && (text.objectReferenceValue as TMPro.TextMeshPro) != null) || (uguiText != null && (uguiText.objectReferenceValue as UnityEngine.UI.Text) != null))
         {
             EditorGUILayout.PropertyField(highlightedTextColor, HighlightTextColor);
             EditorGUILayout.PropertyField(pressTextColor, PressedTextColor);
             EditorGUILayout.PropertyField(disabledTextColor, DisabledTextColor);
 
         }
 
         if (serializedObject.hasModifiedProperties)
             serializedObject.ApplyModifiedProperties();
     }
 }


slow2.png (109.5 kB)
slow1.png (164.8 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

228 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to edit array/list property with custom PropertyDrawer? 3 Answers

GameView.GetMainGameViewTargetSize() problem 0 Answers

Profiler knurl ... 0 Answers

any physical/practical limit to number of lights in view? 0 Answers

Different pc performance problem 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges