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 /
avatar image
0
Question by $$anonymous$$ · Dec 07, 2016 at 12:40 PM · custom editorcustom-inspectoreditorguilayout

Question About EditorGUILayout.BeginFadeGroup

I notice that every time I run my game, in my custom editor that uses EditorGUILayout.BeginFadeGroup, a transition occurs. If the variables are showing before I press play, when I press play it does the transition to show them, and if they are not showing before I press play, when I press play it does the transition to hide them. I believe it has something to do with initializing the AnimBool variable. If anyone has a solution I would greatly appreciate it.

Comment
Add comment · Show 2
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
avatar image Adam-Mechtley · Dec 07, 2016 at 01:30 PM 0
Share

Hi @Oscar-Reyes! Can you show how you are initializing your AnimBool in your Editor's OnEnable () method?

avatar image $$anonymous$$ Adam-Mechtley · Dec 07, 2016 at 08:09 PM 0
Share

In OnEnable() I initialized the AnimBool like this. myAnimBool = new AnimBool() I think I just figured it out thanks! I didn't realize that AnimBool has more than one constructor and one of them takes in a bool value which will set its value right away ins$$anonymous$$d waiting for it to be set in OnInspectorGUI(). I'll post an answer showing the right way later.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by $$anonymous$$ · Dec 08, 2016 at 06:46 AM

Before I was initializing my AnimBool variable in OnEnable() using this constructor - myAnimBool = new AnimBool()

What I should have done is used the constructor that takes in a bool which will set the value on initialization instead of a blank AnimBool that has a value of false and a target of false. Since editor scripts also get OnEnable() called when the game starts, my AnimBool's value and target were initialized again and set to false, and when Repaint happened (which is what my AnimBool is listening for) the AnimBool would do its transition, then the AnimBool would get set again in OnInspectorGUI() which resulted in a unwanted transition. So, the way to go about it is to use...

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEditor;
 using UnityEditor.AnimatedValues;
 
 [CustomEditor(typeof(MyClass))]
 public class MyClassEditor : Editor 
 {
     bool showSettings;
     AnimBool myAnimBool;
 
     void OnEnable()
     {
         myAnimBool = new AnimBool(showSettings);
     }
     public override void OnInspectorGUI ()
     {
         //Code to show, hide variables and draw inspector
     }
 
 }

Comment
Add comment · Share
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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Custom Inspector: Making Individual Vertical Containers and Dynamically Adding & Removing Child Elements 1 Answer

Changes in the Custom Editor are not applied when restarting Unity 1 Answer

'type mismatch' at custom inspector .asset 0 Answers

Unity Custom Editor - save value 1 Answer

How to make a custom editor for a serializedObject that is in a script component 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