Pārlūkot izejas kodu

Renderable inspector will now properly update renderable material
Fixed an issue where the texture drop field was too wide

BearishSun 10 gadi atpakaļ
vecāks
revīzija
e4192cbdca

+ 4 - 0
BansheeEditor/Source/BsBuiltinEditorResources.cpp

@@ -1277,6 +1277,10 @@ namespace BansheeEngine
 		textureDropStyle.border.right = 2;
 		textureDropStyle.border.top = 2;
 		textureDropStyle.border.bottom = 4;
+		textureDropStyle.contentOffset.left = 4;
+		textureDropStyle.contentOffset.right = 4;
+		textureDropStyle.contentOffset.top = 4;
+		textureDropStyle.contentOffset.bottom = 4;
 
 		skin->setStyle(TextureFieldDropStyleName, textureDropStyle);
 		

+ 0 - 0
MBansheeEditor/GUI/TextureField.cs → MBansheeEditor/GUI/GUITextureField.cs


+ 5 - 8
MBansheeEditor/Inspectors/RenderableInspector.cs

@@ -76,7 +76,11 @@ namespace BansheeEditor
                 layersValue = renderable.Layers;
             }
 
-            modifyState |= materialsField.Refresh();
+            InspectableState materialsModified = materialsField.Refresh();
+            if (materialsModified == InspectableState.Modified)
+                renderable.Materials = materials;
+
+            modifyState |= materialsModified;
 
             if (materials != null)
             {
@@ -118,13 +122,6 @@ namespace BansheeEditor
             materials = renderable.Materials;
             materialsField = GUIArrayField<Material, MaterialArrayRow>.Create(new LocEdString("Materials"), materials, Layout);
 
-            materialsField.OnChanged += x =>
-            {
-                renderable.Materials = x;
-                MarkAsModified();
-                ConfirmModify();
-            };
-
             meshField.OnChanged += x =>
             {
                 renderable.Mesh = x as Mesh;

+ 1 - 1
MBansheeEditor/MBansheeEditor.csproj

@@ -54,7 +54,7 @@
     <Compile Include="GUI\GUIListBoxField.cs" />
     <Compile Include="GUI\GUISceneTreeView.cs" />
     <Compile Include="GUI\GUISliderField.cs" />
-    <Compile Include="GUI\TextureField.cs" />
+    <Compile Include="GUI\GUITextureField.cs" />
     <Compile Include="HierarchyWindow.cs" />
     <Compile Include="Inspectors\CameraInspector.cs" />
     <Compile Include="Inspectors\FontInspector.cs" />

+ 17 - 2
MBansheeEngine/NativeRenderable.cs

@@ -58,8 +58,23 @@ namespace BansheeEngine
 
         internal Material[] Materials
         {
-            get { return materials; }
-            set { materials = value; Internal_SetMaterials(mCachedPtr, value); }
+            get
+            {
+                if (materials == null)
+                    return null;
+
+                Material[] copy = new Material[materials.Length];
+                Array.Copy(materials, copy, materials.Length);
+
+                return copy;
+            }
+            set
+            {
+                materials = new Material[value.Length];
+                Array.Copy(value, materials, value.Length);
+                
+                Internal_SetMaterials(mCachedPtr, value);
+            }
         }
 
         internal Material GetMaterial(int index = 0)

+ 7 - 1
MBansheeEngine/Renderable.cs

@@ -60,7 +60,13 @@ namespace BansheeEngine
         public Material[] Materials
         {
             get { return _native.Materials; }
-            set { _native.Materials = value; }
+            set
+            {
+                _native.Materials = value;
+
+                serializableData.materials = new Material[value.Length];
+                Array.Copy(value, serializableData.materials, value.Length);
+            }
         }
 
         /// <summary>

+ 1 - 1
SBansheeEditor/Source/BsGUITextureField.cpp

@@ -33,7 +33,7 @@ namespace BansheeEngine
 			mLayout->addElement(mLabel);
 		}
 
-		mDropButton = GUIDropButton::create((UINT32)DragAndDropType::Resources, GUIOptions(GUIOption::flexibleWidth()), getSubStyleName(BuiltinEditorResources::TextureFieldDropStyleName));
+		mDropButton = GUIDropButton::create((UINT32)DragAndDropType::Resources, getSubStyleName(BuiltinEditorResources::TextureFieldDropStyleName));
 		mClearButton = GUIButton::create(HString(L""), getSubStyleName(BuiltinEditorResources::TextureFieldClearBtnStyleName));
 		mClearButton->onClick.connect(std::bind(&GUITextureField::onClearButtonClicked, this));