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 CGranule · May 29, 2016 at 03:17 AM · unity 5editor-scriptingguilayouteditorguilayout

Unity Editor Layout Problem

Hi, I don't have much experience about Editor Scripting and I want to ask my problem about the implementation. alt text

Image at left is when the component attached with Collider and scene view is normal. but when I remove Collider component, as you can see my custom scene view window is like using dark theme unity. Is this bug?

This is my code :

 public virtual void OnEnable()
 {
     if (Application.isPlaying)
         return;

     SceneView.onSceneGUIDelegate += SceneViewUpdate;
     pe = (ProformerEntity)target;
     lb = GameObject.FindObjectOfType<LevelBounds>();
             <another code>
     }
 
 public virtual void OnDisable()
 {
     SceneView.onSceneGUIDelegate -= SceneViewUpdate;
     if (Application.isPlaying)
         return;
 }
 
 void SceneViewUpdate(SceneView sceneView)
 {
     if (Application.isPlaying)
         return;
        ///Gather all Level Path
     if (lb.levelPath.Count == 0)
         lb.GatherLevelPath();
     SerializedProperty rawHor = serializedObject.FindProperty("rawHorizontal");
     SerializedProperty rawVert = serializedObject.FindProperty("rawVertical");
     SerializedProperty indexLP = serializedObject.FindProperty("indexLastLp");
 
     Handles.BeginGUI();
     GUILayout.Box("Position", GUILayout.Width(240), GUILayout.Height(105));
     GUILayout.BeginArea(new Rect(10, 45, 220, 105));
     GUILayout.BeginHorizontal();
     GUILayout.Label("Level Path Index : " + indexLP.intValue.ToString());
     if (lb.levelPath.Count != 0)
     {
         if (GUILayout.Button(downButton, GUILayout.ExpandWidth(true)))
         {
             if (pe.indexLastLp > 0)
                 indexLP.intValue -= 1;
             else if (pe.indexLastLp <= 0 && lb.loop)
                 indexLP.intValue = lb.levelPath.Count - 1;
         }
         if (GUILayout.Button(upButton, GUILayout.ExpandWidth(true)))
         {
             if (pe.indexLastLp < lb.levelPath.Count - 2)
                 indexLP.intValue += 1;
             //cb.levelPath = lb.levelPath[cb.indexLastLp + 1];
             else if (pe.indexLastLp == lb.levelPath.Count - 2 && lb.loop)
                 indexLP.intValue += 1;
             //cb.levelPath = lb.levelPath[cb.indexLastLp + 1];
             else if (pe.indexLastLp >= lb.levelPath.Count - 1 && lb.loop)
                 indexLP.intValue = 0;
             //cb.levelPath = lb.levelPath[0];
         }
         if (GUILayout.Button("i"))
         {
             ToggleInfo();
         }
     }
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     GUILayout.Label("Horizontal Position ");
     GUILayout.FlexibleSpace();
     rawHor.floatValue = GUILayout.HorizontalSlider(rawHor.floatValue, 0, 1, GUILayout.Width(100));
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     GUILayout.Label("Vertical Position ");
     GUILayout.FlexibleSpace();
     rawVert.floatValue = MyFloatFieldInternal(new Rect(120, 40, 50, 15), new Rect(10, 40, 100, 15), rawVert.floatValue, EditorStyles.numberField);
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     GUILayout.Label("World Point Pos : " + pe.transform.position);
     GUILayout.EndHorizontal();
 
     GUILayout.EndArea();
     ShowInfo();
     Handles.EndGUI();

    if (Application.isPlaying)
         return;
 
     ///Set Level Path
     pe.levelPath = lb.levelPath[pe.indexLastLp];
 
     ///Set Position Object
     if (pe.levelPath != null)
     {
         Vector3 newPos = pe.levelPath.from + pe.levelPath.direction * pe.rawHorizontal * pe.levelPath.length;
         newPos.y = pe.rawVertical;
         pe.transform.position = newPos;
     }
     serializedObject.ApplyModifiedProperties();
 
 }
 
 void ToggleInfo()
 {
     isShowInfo = !isShowInfo;
 }
 
 void ShowInfo()
 {
     if (!isShowInfo || pe == null)
         return;
     GUILayout.BeginArea(new Rect(250, 20, 180, 100));
     GUILayout.Box("Level Path Info", GUILayout.Width(160), GUILayout.Height(100));
     GUILayout.EndArea();
     GUILayout.BeginArea(new Rect(250, 45, 150, 100));
     GUILayout.BeginHorizontal();
     GUILayout.Label("Start : " + pe.levelPath.from);
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     GUILayout.Label("To : " + pe.levelPath.to);
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     GUILayout.Label("Direction : " + pe.levelPath.direction);
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     GUILayout.Label("Length : " + pe.levelPath.length);
     GUILayout.EndHorizontal();
     GUILayout.EndArea();
 }
 
 private float MyFloatFieldInternal(Rect position, Rect dragHotZone, float value, [DefaultValue("EditorStyles.numberField")]GUIStyle style)
 {
     int controlID = GUIUtility.GetControlID("EditorTextField".GetHashCode(), FocusType.Keyboard, position);
     Type editorGUIType = typeof(EditorGUI);
                Type RecycledTextEditorType = Assembly.GetAssembly(editorGUIType).GetType("UnityEditor.EditorGUI+RecycledTextEditor");
     Type[] argumentTypes = new Type[] { RecycledTextEditorType, typeof(Rect), typeof(Rect), typeof(int), typeof(float), typeof(string), typeof(GUIStyle), typeof(bool) };
     MethodInfo doFloatFieldMethod = editorGUIType.GetMethod("DoFloatField", BindingFlags.NonPublic | BindingFlags.Static, null, argumentTypes, null);
 
     object[] parameters;
     FieldInfo fieldInfo = editorGUIType.GetField("s_RecycledEditor", BindingFlags.NonPublic | BindingFlags.Static);
     object recycledEditor = fieldInfo.GetValue(null);
     parameters = new object[] { recycledEditor, position, dragHotZone, controlID, value, "g7", style, true };
 
     return (float)doFloatFieldMethod.Invoke(null, parameters);
 }
problem.jpg (163.9 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

91 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

Related Questions

EditorGUILayout.ObjectField on a ScriptableObject's inspector doesn't update properly 0 Answers

How to return the default value for EditorStyles.toolbarButton.normal.background ??? 1 Answer

Access an Array of class inside another Array of class? (EditorGUILayout) 1 Answer

Have Problem Storing GUILayout Foldout Bool 0 Answers

GUILayout.Label with Texture2D on the same line in Inspector ? 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