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 JAAMY · Jun 06, 2018 at 08:54 PM · ioseditor-scriptingeditorguieditorguilayouteditor scripting

Custom Inspector and ExposedRefreces

Hi.

I'm Trying to write my custom inspector, every thing is fine and I can make right field for different type of variables I have in the main script.


But in Main script I have a field which is Exposed Reference

 public ExposedReference<GameObject> relativeToWhat;




How can I make a field for it in OnInspectorGUI ? I tried EditorGUILayout.ObjectField and some other things but I couldn't use them.


By the way if there is no way to do so, Is there any way that I can tell OnInspectorGUI to draw only a specific Part of Default Inspector ? only a specific part of Base.OnInspectorGUI()?

Or if again there Is no way, Is there any way that I can make a gameobject field in custom inspector script and some how handle it in My Main Code ? for example converting or resolving them ? I'm new to exposed References.


And My Main Script doesn't implements Monobehaviour and it is inheriting from TrackAsset Actually I'm creating my own type of playables for timeline.


Here is also put my Custom Editor script up to here Although it is not needed.

Thanks.

 using UnityEditor;
 using UnityEditor.AnimatedValues;
 using UnityEngine;
 
 [CustomEditor(typeof(MagneticTweenTrack))]
 public class MagneticTweenTrackDrawer : Editor
 {
 
     AnimBool animBoolShowUnParentingSettings = new AnimBool(false);
     AnimBool animBoolShowFallowOffset = new AnimBool(true);
     AnimBool animBoolShowRelativeSettings = new AnimBool(false);
 
     public override void OnInspectorGUI()
     {
         MagneticTweenTrack targetTrack = target as MagneticTweenTrack;
         if (targetTrack == null)
             return;
 
         targetTrack.animationClipTrackWillHaveChangesDurringPlayMode = EditorGUILayout.ToggleLeft("Any Change During PlayMode ?", targetTrack.animationClipTrackWillHaveChangesDurringPlayMode);
 
         EditorGUILayout.Space();
         EditorGUILayout.Space();
         EditorGUILayout.HelpBox("Change below values only if you know what are you doing. First read Documentations and then use bellow Parts", MessageType.None, true);
         EditorGUILayout.Space();
 
         EditorGUILayout.LabelField("Parent Mangement Settings", EditorStyles.boldLabel);
 
 
         animBoolShowUnParentingSettings.valueChanged.AddListener(Repaint);
 
         animBoolShowUnParentingSettings.target = EditorGUILayout.ToggleLeft("Use UnParenting ?", targetTrack.useUnParenting);
         targetTrack.useUnParenting = animBoolShowUnParentingSettings.target;
 
         if (EditorGUILayout.BeginFadeGroup(animBoolShowUnParentingSettings.faded))
         {
             EditorGUI.indentLevel++;
             targetTrack.revertToPreviousStatusAfterTimelineFinished = EditorGUILayout.ToggleLeft("Revert to Previous Status ?", targetTrack.revertToPreviousStatusAfterTimelineFinished);
 
             animBoolShowFallowOffset.valueChanged.AddListener(Repaint);
             //entegaMMM
             animBoolShowFallowOffset.target = EditorGUILayout.ToggleLeft("Make Parent to Follow Child ?", targetTrack.inTimelineDurationParentFollowChild);
             targetTrack.inTimelineDurationParentFollowChild = animBoolShowFallowOffset.target;
             if (EditorGUILayout.BeginFadeGroup(animBoolShowFallowOffset.faded))
             {
                 EditorGUI.indentLevel++;
                 EditorGUI.indentLevel++;
                 targetTrack.followOffsetPosition = EditorGUILayout.Vector3Field("Follow Offset Position", targetTrack.followOffsetPosition);
                 targetTrack.followOffsetRotation = EditorGUILayout.Vector3Field("Follow Offset Rotation", targetTrack.followOffsetRotation);
                 EditorGUI.indentLevel--;
                 EditorGUI.indentLevel--;
             }
 
             EditorGUILayout.EndFadeGroup();
             EditorGUI.indentLevel--;
         }
 
         EditorGUILayout.EndFadeGroup();
 
         EditorGUILayout.Space();
         EditorGUILayout.Space();
 
         EditorGUILayout.LabelField("Relative Mode Settings", EditorStyles.boldLabel);
 
         animBoolShowRelativeSettings.valueChanged.AddListener(Repaint);
         animBoolShowRelativeSettings.target = EditorGUILayout.ToggleLeft("Is it Relative ?", targetTrack.isRelative);
         targetTrack.isRelative = animBoolShowRelativeSettings.target;
         if (EditorGUILayout.BeginFadeGroup(animBoolShowRelativeSettings.faded))
         {
             EditorGUI.indentLevel++;
             //
             // Here i am stuck with making a field for my exposed Refrence
          //   targetTrack.relativeToWhat = EditorGUILayout.ObjectField("Relative to what ?",targetTrack.relativeToWhatGameObject, typeof(ExposedReference<GameObject>), true) as ExposedReference<GameObject>;
             
             EditorGUI.indentLevel--;
         }
 
         EditorGUILayout.EndFadeGroup();
 
     }
 }





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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by SolutionStudios · Jun 19, 2020 at 03:04 PM

Sorry for replying to a very old question, but I had the same issue and found the best you can do is use EditorGUILayout.PropertyField.

https://docs.unity3d.com/ScriptReference/EditorGUILayout.PropertyField.html

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

127 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

Related Questions

Track when the value is changed and get it 0 Answers

Text in custom editor is displayed/rendered with boxes around characters... 2 Answers

Hint at Inspector variables that have tooltips 0 Answers

Recreate default editor look manually without base.OnInspectorGUI [UnityEditor] 2 Answers

GUIStyle doesn't work when renamed. What to do here? 1 Answer


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