Selaa lähdekoodia

Hooked up color picker to the color field
Various ColorPicker fixes
Editor/Modal/DropDown window OnInitialize method will now get called just before the first update instead in the constructor

BearishSun 10 vuotta sitten
vanhempi
sitoutus
a393b43fc3

+ 8 - 2
BansheeCore/Source/BsCoreObjectManager.cpp

@@ -81,9 +81,16 @@ namespace BansheeEngine
 		CoreStoredSyncData& syncData = mCoreSyncData.back();
 
 		syncData.alloc = allocator;
-
 		bs_frame_mark();
 		
+		// Note: Optimization possibilities
+		//  - Iterating over every single object takes too long. Instead dirty objects should be added to a separate array 
+		//    and then just directly iterated over.
+		//  - Retrieving dependencies takes too long. A better system should be implemented so I can immediately tell
+		//    what depends on a dependency at the moment it is marked dirty. Then we can queue it into the same array above.
+		//     - e.g. Whenever dependencies change (e.g. object is created or modified) register the dependencies so we
+		//       can look them up later.
+
 		// Order in which objects are recursed in matters, ones with lower ID will have been created before
 		// ones with higher ones and should be updated first.
 		for (auto& objectData : mObjects)
@@ -93,7 +100,6 @@ namespace BansheeEngine
 				// Sync dependencies before dependants
 				// Note: I don't check for recursion. Possible infinite loop if two objects
 				// are dependent on one another.
-				
 				FrameVector<SPtr<CoreObject>> dependencies;
 				curObj->getCoreDependencies(dependencies);
 

+ 1 - 1
BansheeEditor/Include/BsGUIColor.h

@@ -54,7 +54,7 @@ namespace BansheeEngine
 		 */
 		Color getColor() const { return mValue; }
 
-		Event<void(const Color&)> onValueChanged; /**< Triggered when the displayed color value changes. */
+		Event<void()> onClicked; /**< Triggered when the user clicks on the GUI element. */
 	protected:
 		GUIColor(const String& styleName, const GUIDimensions& dimensions);
 		virtual ~GUIColor();

+ 3 - 3
BansheeEditor/Include/BsGUIColorField.h

@@ -47,7 +47,7 @@ namespace BansheeEngine
 		 */
 		Vector2I _getOptimalSize() const override;
 
-		Event<void(const Color&)> onValueChanged; /**< Triggered when the displayed color value changes. */
+		Event<void()> onClicked; /**< Triggered when the user clicks on the GUI element. */
 	protected:
 		virtual ~GUIColorField();
 
@@ -57,9 +57,9 @@ namespace BansheeEngine
 		void styleUpdated() override;
 
 		/**
-		 * @brief	Triggered when the child color input field's value changes.
+		 * @brief	Triggered when the child color input field is clicked on.
 		 */
-		void valueChanged(const Color& newValue);
+		void clicked();
 
 		UINT32 mLabelWidth;
 		Color mValue;

+ 2 - 2
BansheeEditor/Source/BsBuiltinEditorResources.cpp

@@ -1580,8 +1580,8 @@ namespace BansheeEngine
 		GUIElementStyle colorPickerSlider2DHandleStyle;
 		colorPickerSlider2DHandleStyle.fixedHeight = true;
 		colorPickerSlider2DHandleStyle.fixedWidth = true;
-		colorPickerSlider2DHandleStyle.height = 8;
-		colorPickerSlider2DHandleStyle.width = 8;
+		colorPickerSlider2DHandleStyle.height = 7;
+		colorPickerSlider2DHandleStyle.width = 7;
 		colorPickerSlider2DHandleStyle.normal.texture = getGUITexture(ColorPickerSlider2DHandleTex);
 		colorPickerSlider2DHandleStyle.hover.texture = colorPickerSlider2DHandleStyle.normal.texture;
 		colorPickerSlider2DHandleStyle.active.texture = colorPickerSlider2DHandleStyle.normal.texture;

+ 1 - 4
BansheeEditor/Source/BsGUIColor.cpp

@@ -145,10 +145,7 @@ namespace BansheeEngine
 		if(ev.getType() == GUIMouseEventType::MouseUp)
 		{
 			if (!_isDisabled())
-			{
-				// TODO - Open color picker window
-				//      - Trigger onValueChanged when done
-			}
+				onClicked();
 
 			return true;
 		}

+ 3 - 6
BansheeEditor/Source/BsGUIColorField.cpp

@@ -18,7 +18,7 @@ namespace BansheeEngine
 		mLabel(nullptr), mColor(nullptr), mLabelWidth(100)
 	{
 		mColor = GUIColor::create(getSubStyleName(getColorInputStyleType()));
-		mColor->onValueChanged.connect(std::bind(&GUIColorField::valueChanged, this, _1));
+		mColor->onClicked.connect(std::bind(&GUIColorField::clicked, this));
 
 		mLayout->addElement(mColor);
 	}
@@ -64,12 +64,9 @@ namespace BansheeEngine
 		mColor->setStyle(getSubStyleName(getColorInputStyleType()));
 	}
 
-	void GUIColorField::valueChanged(const Color& newValue)
+	void GUIColorField::clicked()
 	{
-		setValue(newValue);
-
-		if (!onValueChanged.empty())
-			onValueChanged(newValue);
+		onClicked();
 	}
 
 	const String& GUIColorField::getGUITypeName()

+ 8 - 3
BansheeEngine/Source/BsGUIScrollBar.cpp

@@ -156,11 +156,16 @@ namespace BansheeEngine
 	{
 		float newHandlePos = Math::clamp01(mHandleBtn->getHandlePos() - amount);
 
+		float oldHandlePos = mHandleBtn->getHandlePos();
 		mHandleBtn->_setHandlePos(newHandlePos);
-		mHandleBtn->_markLayoutAsDirty();
 
-		if(!onScrollPositionChanged.empty())
-			onScrollPositionChanged(newHandlePos);
+		if (oldHandlePos != mHandleBtn->getHandlePos())
+		{
+			mHandleBtn->_markLayoutAsDirty();
+
+			if (!onScrollPositionChanged.empty())
+				onScrollPositionChanged(newHandlePos);
+		}
 	}
 
 	void GUIScrollBar::_setHandleSize(UINT32 size)

+ 10 - 7
BansheeEngine/Source/BsGUISlider.cpp

@@ -69,7 +69,7 @@ namespace BansheeEngine
 		{
 			Vector2I optimalSize = mBackground->_getOptimalSize();
 			childData.area.height = optimalSize.y;
-			childData.area.y += (INT32)((data.area.height - childData.area.height) * 0.5f);
+			childData.area.y = data.area.y + (INT32)((data.area.height - childData.area.height) * 0.5f);
 
 			childData.clipRect = data.area;
 			childData.clipRect.clip(data.clipRect);
@@ -78,7 +78,7 @@ namespace BansheeEngine
 
 			optimalSize = mSliderHandle->_getOptimalSize();
 			childData.area.height = optimalSize.y;
-			childData.area.y += (INT32)((data.area.height - childData.area.height) * 0.5f);
+			childData.area.y = data.area.y + (INT32)((data.area.height - childData.area.height) * 0.5f);
 
 			childData.clipRect = data.area;
 			childData.clipRect.clip(data.clipRect);
@@ -88,7 +88,7 @@ namespace BansheeEngine
 
 			optimalSize = mFillBackground->_getOptimalSize();
 			childData.area.height = optimalSize.y;
-			childData.area.y += (INT32)((data.area.height - childData.area.height) * 0.5f);
+			childData.area.y = data.area.y + (INT32)((data.area.height - childData.area.height) * 0.5f);
 			childData.area.width = mSliderHandle->getHandlePosPx() + handleWidth / 2;
 
 			childData.clipRect = data.area;
@@ -100,7 +100,7 @@ namespace BansheeEngine
 		{
 			Vector2I optimalSize = mBackground->_getOptimalSize();
 			childData.area.width = optimalSize.x;
-			childData.area.x += (INT32)((data.area.width - childData.area.width) * 0.5f);
+			childData.area.x = data.area.x + (INT32)((data.area.width - childData.area.width) * 0.5f);
 
 			childData.clipRect = data.area;
 			childData.clipRect.clip(data.clipRect);
@@ -109,7 +109,7 @@ namespace BansheeEngine
 
 			optimalSize = mSliderHandle->_getOptimalSize();
 			childData.area.width = optimalSize.x;
-			childData.area.x += (INT32)((data.area.width - childData.area.width) * 0.5f);
+			childData.area.x = data.area.x + (INT32)((data.area.width - childData.area.width) * 0.5f);
 
 			childData.clipRect = data.area;
 			childData.clipRect.clip(data.clipRect);
@@ -119,7 +119,7 @@ namespace BansheeEngine
 
 			optimalSize = mFillBackground->_getOptimalSize();
 			childData.area.width = optimalSize.x;
-			childData.area.x += (INT32)((data.area.width - childData.area.width) * 0.5f);
+			childData.area.x = data.area.x + (INT32)((data.area.width - childData.area.width) * 0.5f);
 			childData.area.height = mSliderHandle->getHandlePosPx() + handleHeight / 2;
 
 			childData.clipRect = data.area;
@@ -138,8 +138,11 @@ namespace BansheeEngine
 
 	void GUISlider::setPercent(float pct)
 	{
+		float oldHandlePos = mSliderHandle->getHandlePos();
 		mSliderHandle->_setHandlePos(pct);
-		mSliderHandle->_markLayoutAsDirty();
+
+		if (oldHandlePos != mSliderHandle->getHandlePos())
+			mSliderHandle->_markLayoutAsDirty();
 	}
 
 	float GUISlider::getPercent() const

+ 31 - 27
MBansheeEditor/ColorPicker.cs

@@ -9,13 +9,13 @@ namespace BansheeEditor
     public class ColorPicker : ModalWindow
     {
         private const int SliderIndividualWidth = 150;
-        private const int SliderIndividualHeight = 20;
+        private const int SliderIndividualHeight = 15;
 
-        private const int ColorBoxWidth = 150;
-        private const int ColorBoxHeight = 150;
+        private const int ColorBoxWidth = 200;
+        private const int ColorBoxHeight = 200;
 
         private const int SliderSideWidth = 40;
-        private const int SliderSideHeight = 150;
+        private const int SliderSideHeight = 200;
 
         private float colRed, colGreen, colBlue;
         private float colHue, colSaturation, colValue;
@@ -102,9 +102,7 @@ namespace BansheeEditor
         /// <returns>A. instance of the color picker window.</returns>
         public static ColorPicker Show(Action<bool, Color> closedCallback = null)
         {
-            ColorPicker picker = new ColorPicker();
-            picker.closedCallback = closedCallback;
-
+            ColorPicker picker = new ColorPicker(Color.Black, closedCallback);
             return picker;
         }
 
@@ -117,36 +115,42 @@ namespace BansheeEditor
         /// <returns>A. instance of the color picker window.</returns>
         public static ColorPicker Show(Color color, Action<bool, Color> closedCallback = null)
         {
-            ColorPicker picker = new ColorPicker();
-            picker.colRed = color.r;
-            picker.colGreen = color.g;
-            picker.colBlue = color.b; 
-            picker.colAlpha = color.a;
-            picker.closedCallback = closedCallback;
-
+            ColorPicker picker = new ColorPicker(color, closedCallback);
             return picker;
         }
 
         /// <summary>
         /// Constructs a new color picker window.
         /// </summary>
-        protected ColorPicker()
+        /// <param name="color">Initial color to display.</param>
+        /// <param name="closedCallback">Optional callback to trigger when the user selects a color or cancels out
+        ///                              of the dialog.</param>
+        protected ColorPicker(Color color, Action<bool, Color> closedCallback = null)
             : base(false)
-        { }
-
-        private void OnInitialize()
         {
             Title = new LocEdString("Color Picker");
             Width = 270;
             Height = 400;
 
+            colRed = color.r;
+            colGreen = color.g;
+            colBlue = color.b;
+            colAlpha = color.a;
+
+            RGBToHSV();
+
+            this.closedCallback = closedCallback;
+        }
+
+        private void OnInitialize()
+        {
             guiColor = new GUIColorField("", GUIOption.FixedWidth(100));
-            guiSlider2DTex = new GUITexture(null, GUIOption.FixedHeight(200), GUIOption.FixedWidth(200));
-            guiSliderVertTex = new GUITexture(null, GUIOption.FixedHeight(200), GUIOption.FixedWidth(40));
-            guiSliderRHorzTex = new GUITexture(null, GUIOption.FixedHeight(15));
-            guiSliderGHorzTex = new GUITexture(null, GUIOption.FixedHeight(15));
-            guiSliderBHorzTex = new GUITexture(null, GUIOption.FixedHeight(15));
-            guiSliderAHorzTex = new GUITexture(null, GUIOption.FixedHeight(15));
+            guiSlider2DTex = new GUITexture(null, GUIOption.FixedHeight(ColorBoxHeight), GUIOption.FixedWidth(ColorBoxWidth));
+            guiSliderVertTex = new GUITexture(null, GUIOption.FixedHeight(SliderSideHeight), GUIOption.FixedWidth(SliderSideWidth));
+            guiSliderRHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight));
+            guiSliderGHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight));
+            guiSliderBHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight));
+            guiSliderAHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight));
 
             guiColorBoxBtn = new GUIButton(colorBoxMode.ToString());
             guiColorModeBtn = new GUIButton(sliderMode.ToString());
@@ -295,11 +299,11 @@ namespace BansheeEditor
 
             guiColor.Value = SelectedColor;
             UpdateInputBoxValues();
-            Update2DSliderTextures();
             Update2DSliderValues();
-            Update1DSliderTextures();
             Update1DSliderValues();
             UpdateSliderMode();
+            Update2DSliderTextures();
+            Update1DSliderTextures();
         }
 
         private void OnEditorUpdate()
@@ -949,7 +953,7 @@ namespace BansheeEditor
 
                 Rect2I sliderBounds = guiTexture.Bounds;
                 sliderBounds.x -= SLIDER_X_OFFSET;
-                sliderBounds.width += SLIDER_X_OFFSET*2;
+                sliderBounds.width += SLIDER_X_OFFSET * 2;
                 sliderBounds.y -= SLIDER_Y_OFFSET;
                 sliderBounds.height += SLIDER_Y_OFFSET;
 

+ 16 - 7
MBansheeEditor/GUI/GUIColorField.cs

@@ -70,21 +70,30 @@ namespace BansheeEditor
         }
 
         /// <summary>
-        /// Triggered by the runtime when the value of the color field changes.
+        /// Triggered when the user closes the color picker window.
         /// </summary>
-        /// <param name="newValue">New value of the color field.</param>
-        private void DoOnChanged(Color newValue)
+        /// <param name="selected">True if the user confirms color selection, false if he cancels.</param>
+        /// <param name="color">Newly selected color.</param>
+        private void ColorPickerClosed(bool selected, Color color)
         {
-            if (OnChanged != null)
-                OnChanged(newValue);
+            if (!selected)
+                return;
+
+            if (Value != color)
+            {
+                Value = color;
+
+                if(OnChanged != null)
+                    OnChanged(color);
+            }
         }
 
         /// <summary>
         /// Triggered by the runtime when the user clicks on the color field.
         /// </summary>
-        private void DoOnClicked()
+        private void Internal_DoOnClicked()
         {
-            // TODO
+            ColorPicker.Show(Value, ColorPickerClosed);
         }
 
         [MethodImpl(MethodImplOptions.InternalCall)]

+ 13 - 4
MBansheeEngine/Color.cs

@@ -157,14 +157,23 @@ namespace BansheeEngine
 
             output.b = max;
 
+            if (max == 0.0f)
+            {
+                output.r = 0.0f;
+                output.g = 0.0f;
+
+                return output;
+            }
+
             float delta = max - min;
-            if (max > 0.0f)
+            if (delta != 0.0f)
+            {
                 output.g = (delta / max);
+            }
             else
             {
                 output.g = 0.0f;
-                output.r = 0.0f;
-                return output;
+                delta = 1.0f;
             }
 
             if (input.r >= max)
@@ -176,7 +185,7 @@ namespace BansheeEngine
                 else
                     output.r = 4.0f + (input.r - input.g) / delta;
             }
-
+            
             output.r /= 6.0f;
 
             if (output.r < 0.0f)

+ 1 - 0
SBansheeEditor/Include/BsScriptDropDownWindow.h

@@ -111,6 +111,7 @@ namespace BansheeEngine
 		OnDestroyThunkDef mOnDestroyThunk;
 		UpdateThunkDef mUpdateThunk;
 
+		bool mIsInitialized;
 		MonoObject* mManagedInstance;
 		uint32_t mGCHandle;
 

+ 6 - 0
SBansheeEditor/Include/BsScriptEditorWindow.h

@@ -164,6 +164,11 @@ namespace BansheeEngine
 		 */
 		bool createManagedInstance();
 
+		/**
+		 * @brief	Checks has the OnInitialize method been called yet.
+		 */
+		bool isInitialized() const { return mIsInitialized; }
+
 		/**
 		 * @copydoc	EditorWidgetBase::update 
 		 */
@@ -216,5 +221,6 @@ namespace BansheeEngine
 
 		ScriptEditorWindow* mScriptOwner;
 		ScriptGUILayout* mContentsPanel;
+		bool mIsInitialized;
 	};
 }

+ 4 - 5
SBansheeEditor/Include/BsScriptGUIColorField.h

@@ -18,12 +18,11 @@ namespace BansheeEngine
 		ScriptGUIColorField(MonoObject* instance, GUIColorField* colorField);
 
 		/**
-		 * @brief	Triggered when the value in the native color field changes.
+		 * @brief	Triggered when the user clicks on the native color field.
 		 *
 		 * @param	instance	Managed GUIColorField instance.
-		 * @param	newValue	New color value.
 		 */
-		static void onChanged(MonoObject* instance, Color newValue);
+		static void onClicked(MonoObject* instance);
 
 		/************************************************************************/
 		/* 								CLR HOOKS						   		*/
@@ -35,8 +34,8 @@ namespace BansheeEngine
 		static void internal_setValue(ScriptGUIColorField* nativeInstance, Color value);
 		static void internal_setTint(ScriptGUIColorField* nativeInstance, Color color);
 
-		typedef void(__stdcall *OnChangedThunkDef) (MonoObject*, Color, MonoException**);
+		typedef void(__stdcall *OnClickedThunkDef) (MonoObject*, MonoException**);
 
-		static OnChangedThunkDef onChangedThunk;
+		static OnClickedThunkDef onClickedThunk;
 	};
 }

+ 1 - 0
SBansheeEditor/Include/BsScriptModalWindow.h

@@ -147,6 +147,7 @@ namespace BansheeEngine
 		UpdateThunkDef mUpdateThunk;
 		MonoMethod* mOnWindowResizedMethod;
 
+		bool mIsInitialized;
 		MonoObject* mManagedInstance;
 		uint32_t mGCHandle;
 

+ 8 - 4
SBansheeEditor/Source/BsScriptDropDownWindow.cpp

@@ -72,10 +72,7 @@ namespace BansheeEngine
 		ScriptDropDownWindow* nativeInstance = new (bs_alloc<ScriptDropDownWindow>()) ScriptDropDownWindow(dropDownWindow);
 
 		if (dropDownWindow != nullptr)
-		{
 			dropDownWindow->initialize(nativeInstance);
-			dropDownWindow->triggerOnInitialize();
-		}
 	}
 
 	void ScriptDropDownWindow::internal_Close(ScriptDropDownWindow* thisPtr)
@@ -126,7 +123,8 @@ namespace BansheeEngine
 	ManagedDropDownWindow::ManagedDropDownWindow(const RenderWindowPtr& parent, const CameraPtr& camera,
 		const Vector2I& position, MonoObject* managedInstance, UINT32 width, UINT32 height)
 		:DropDownWindow(parent, camera, position, width, height), mUpdateThunk(nullptr), mManagedInstance(managedInstance),
-		mOnInitializeThunk(nullptr), mOnDestroyThunk(nullptr), mGCHandle(0), mScriptParent(nullptr), mContentsPanel(nullptr)
+		mOnInitializeThunk(nullptr), mOnDestroyThunk(nullptr), mGCHandle(0), mScriptParent(nullptr), 
+		mContentsPanel(nullptr), mIsInitialized(false)
 	{
 		mGCHandle = mono_gchandle_new(mManagedInstance, false);
 
@@ -182,6 +180,12 @@ namespace BansheeEngine
 
 	void ManagedDropDownWindow::update()
 	{
+		if (!mIsInitialized)
+		{
+			triggerOnInitialize();
+			mIsInitialized = true;
+		}
+
 		if (mUpdateThunk != nullptr && mManagedInstance != nullptr)
 		{
 			// Note: Not calling virtual methods. Can be easily done if needed but for now doing this

+ 8 - 3
SBansheeEditor/Source/BsScriptEditorWindow.cpp

@@ -207,7 +207,7 @@ namespace BansheeEngine
 
 	void ScriptEditorWindow::onWidgetResized(UINT32 width, UINT32 height)
 	{
-		if (isDestroyed() || mManagedInstance == nullptr)
+		if (isDestroyed() || !mEditorWidget->isInitialized() || mManagedInstance == nullptr)
 			return;
 
 		void* params[2] = { &width, &height };
@@ -264,7 +264,6 @@ namespace BansheeEngine
 
 		mono_runtime_object_init(editorWidget->getManagedInstance()); // Construct it
 		editorWidget->setScriptOwner(nativeInstance);
-		editorWidget->triggerOnInitialize();
 
 		return editorWidget;
 	}
@@ -300,7 +299,7 @@ namespace BansheeEngine
 	ScriptEditorWidget::ScriptEditorWidget(const String& ns, const String& type, EditorWidgetContainer& parentContainer)
 		:EditorWidgetBase(HString(toWString(type)), ns + "." + type, parentContainer), mNamespace(ns), mTypename(type),
 		mUpdateThunk(nullptr), mManagedInstance(nullptr), mOnInitializeThunk(nullptr), mOnDestroyThunk(nullptr), 
-		mContentsPanel(nullptr), mScriptOwner(nullptr), mGetDisplayName(nullptr)
+		mContentsPanel(nullptr), mScriptOwner(nullptr), mGetDisplayName(nullptr), mIsInitialized(false)
 	{
 		if(createManagedInstance())
 		{
@@ -382,6 +381,12 @@ namespace BansheeEngine
 
 	void ScriptEditorWidget::update()
 	{
+		if (!mIsInitialized)
+		{
+			triggerOnInitialize();
+			mIsInitialized = true;
+		}
+
 		if (mUpdateThunk != nullptr && mManagedInstance != nullptr)
 		{
 			// Note: Not calling virtual methods. Can be easily done if needed but for now doing this

+ 5 - 5
SBansheeEditor/Source/BsScriptGUIColorField.cpp

@@ -19,7 +19,7 @@ using namespace std::placeholders;
 
 namespace BansheeEngine
 {
-	ScriptGUIColorField::OnChangedThunkDef ScriptGUIColorField::onChangedThunk;
+	ScriptGUIColorField::OnClickedThunkDef ScriptGUIColorField::onClickedThunk;
 
 	ScriptGUIColorField::ScriptGUIColorField(MonoObject* instance, GUIColorField* colorField)
 		:TScriptGUIElement(instance, colorField)
@@ -34,7 +34,7 @@ namespace BansheeEngine
 		metaData.scriptClass->addInternalCall("Internal_SetValue", &ScriptGUIColorField::internal_setValue);
 		metaData.scriptClass->addInternalCall("Internal_SetTint", &ScriptGUIColorField::internal_setTint);
 
-		onChangedThunk = (OnChangedThunkDef)metaData.scriptClass->getMethod("DoOnChanged", 1)->getThunk();
+		onClickedThunk = (OnClickedThunkDef)metaData.scriptClass->getMethod("Internal_DoOnClicked")->getThunk();
 	}
 
 	void ScriptGUIColorField::internal_createInstance(MonoObject* instance, MonoObject* title, UINT32 titleWidth,
@@ -59,7 +59,7 @@ namespace BansheeEngine
 			guiField = GUIColorField::create(options, styleName);
 		}
 
-		guiField->onValueChanged.connect(std::bind(&ScriptGUIColorField::onChanged, instance, _1));
+		guiField->onClicked.connect(std::bind(&ScriptGUIColorField::onClicked, instance));
 
 		ScriptGUIColorField* nativeInstance = new (bs_alloc<ScriptGUIColorField>()) ScriptGUIColorField(instance, guiField);
 	}
@@ -82,8 +82,8 @@ namespace BansheeEngine
 		colorField->setTint(color);
 	}
 
-	void ScriptGUIColorField::onChanged(MonoObject* instance, Color newValue)
+	void ScriptGUIColorField::onClicked(MonoObject* instance)
 	{
-		MonoUtil::invokeThunk(onChangedThunk, instance, newValue);
+		MonoUtil::invokeThunk(onClickedThunk, instance);
 	}
 }

+ 7 - 2
SBansheeEditor/Source/BsScriptModalWindow.cpp

@@ -48,7 +48,6 @@ namespace BansheeEngine
 		ManagedModalWindow* modalWindow = bs_new<ManagedModalWindow>(allowCloseButton, instance);
 		ScriptModalWindow* nativeInstance = new (bs_alloc<ScriptModalWindow>()) ScriptModalWindow(modalWindow);
 		modalWindow->setParent(nativeInstance);
-		modalWindow->triggerOnInitialize();
 	}
 
 	void ScriptModalWindow::internal_close(ScriptModalWindow* thisPtr)
@@ -127,7 +126,7 @@ namespace BansheeEngine
 	ManagedModalWindow::ManagedModalWindow(bool allowCloseButton, MonoObject* managedInstance)
 		:ModalWindow(HString::dummy(), allowCloseButton), mUpdateThunk(nullptr), mManagedInstance(managedInstance),
 		mOnInitializeThunk(nullptr), mOnDestroyThunk(nullptr), mOnWindowResizedMethod(nullptr), mGCHandle(0),
-		mScriptParent(nullptr), mContentsPanel(nullptr)
+		mScriptParent(nullptr), mContentsPanel(nullptr), mIsInitialized(false)
 	{
 		mGCHandle = mono_gchandle_new(mManagedInstance, false);
 
@@ -207,6 +206,12 @@ namespace BansheeEngine
 
 	void ManagedModalWindow::update()
 	{
+		if (!mIsInitialized)
+		{
+			triggerOnInitialize();
+			mIsInitialized = true;
+		}
+
 		if (mUpdateThunk != nullptr && mManagedInstance != nullptr)
 		{
 			// Note: Not calling virtual methods. Can be easily done if needed but for now doing this

+ 0 - 3
TODO.txt

@@ -24,9 +24,6 @@ Prefab diff
 ----------------------------------------------------------------------
 Polish
 
-Ribek use:
- - Hook up color picker to guicolor field
-
 Other polish:
  - Add menu items:
   - Edit: Cut/Copy/Paste/Duplicate/Delete(need to make sure it works in Hierarchy, with shortcuts), View/Move/rotate/scale