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. 
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
              
 
               
              Your answer
 
 
             Follow this Question
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
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                