Преглед изворни кода

Bugfix: Fixing an issue where component drop-zones in Inspector weren't properly calculated if/when an existing component was collapsed

BearishSun пре 8 година
родитељ
комит
f147456113

+ 14 - 14
Source/MBansheeEditor/Utility/EditorBuiltin.cs

@@ -13,42 +13,42 @@ namespace BansheeEditor
     /// Types of icons that may be displayed on the tool bar.
     /// </summary>
     public enum ToolbarIcon // Note: Must match C++ enum ToolbarIcon
-	{
+    {
         NewCamera, NewRenderable, NewPointLight, NewDirLight, NewSpotLight, NewSceneObject, NewCube, NewSphere, NewCone, 
         NewQuad, NewMat, NewCSScript, NewShader, NewSpriteTex, Pause, Play, Step, Undo, Redo, OpenProject, SaveProject, 
         SaveScene
-	}
+    }
 
     /// <summary>
     /// Types of icons that may be displayed in the scene window.
     /// </summary>
     public enum SceneWindowIcon // Note: Must match C++ enum SceneWindowIcon
-	{
-		View, Move, Rotate, Scale, Pivot, Center, Local, World, MoveSnap, RotateSnap
-	}
+    {
+        View, Move, Rotate, Scale, Pivot, Center, Local, World, MoveSnap, RotateSnap
+    }
 
     /// <summary>
     /// Types of icons that may be displayed in the library window.
     /// </summary>
     public enum LibraryWindowIcon // Note: Must match C++ enum LibraryWindowIcon
-	{
-		Home, Up, Clear, Options
-	}
+    {
+        Home, Up, Clear, Options
+    }
 
     /// <summary>
     /// Types of icons that may be displayed in the inspector window.
     /// </summary>
-	public enum InspectorWindowIcon  // Note: Must match C++ enum InspectorWindowIcon
-	{
-		Create, Clone, Clear, Resize, Delete, MoveUp, MoveDown, Edit, Apply, Add, Cancel
-	}
+    public enum InspectorWindowIcon  // Note: Must match C++ enum InspectorWindowIcon
+    {
+        Create, Clone, Clear, Resize, Delete, MoveUp, MoveDown, Edit, Apply, Add, Cancel
+    }
 
     /// <summary>
     /// Types of icons that may be displayed for resources in the library window.
     /// </summary>
     public enum LibraryItemIcon // Note: Must match C++ enum ProjectIcon
-	{
-		Folder, Mesh, Font, Texture, PlainText, ScriptCode, SpriteTexture, Shader, ShaderInclude, Material, Prefab, GUISkin,
+    {
+        Folder, Mesh, Font, Texture, PlainText, ScriptCode, SpriteTexture, Shader, ShaderInclude, Material, Prefab, GUISkin,
         PhysicsMaterial, PhysicsMesh, AudioClip, AnimationClip
     }
 

+ 9 - 1
Source/MBansheeEditor/Windows/Inspector/InspectorWindow.cs

@@ -39,6 +39,7 @@ namespace BansheeEditor
             public GUIPanel panel;
             public Inspector inspector;
             public UInt64 instanceId;
+            public bool folded;
         }
 
         /// <summary>
@@ -191,6 +192,7 @@ namespace BansheeEditor
 
                 InspectorComponent data = new InspectorComponent();
                 data.instanceId = allComponents[i].InstanceId;
+                data.folded = false;
 
                 data.foldout = new GUIToggle(allComponents[i].GetType().Name, EditorStyles.Foldout);
 
@@ -675,6 +677,9 @@ namespace BansheeEditor
         {
             inspectorData.inspector.Persistent.SetBool(inspectorData.instanceId + "_Expanded", expanded);
             inspectorData.inspector.SetVisible(expanded);
+            inspectorData.folded = !expanded;
+
+            UpdateDropAreas();
         }
 
         /// <summary>
@@ -890,7 +895,10 @@ namespace BansheeEditor
             for (int i = 0; i < inspectorComponents.Count; i++)
             {
                 dropAreas[i] = new Rect2I(0, yOffset, contentBounds.width, COMPONENT_SPACING);
-                yOffset += inspectorComponents[i].title.Bounds.height + inspectorComponents[i].panel.Bounds.height + COMPONENT_SPACING;
+                yOffset += inspectorComponents[i].title.Bounds.height + COMPONENT_SPACING;
+
+                if (!inspectorComponents[i].folded)
+                    yOffset += inspectorComponents[i].panel.Bounds.height;
             }
 
             dropAreas[dropAreas.Length - 1] = new Rect2I(0, yOffset, contentBounds.width, contentBounds.height - yOffset);