Sfoglia il codice sorgente

Add color wheel in editor for Text3D component.

orefkov 8 anni fa
parent
commit
fa71240346

+ 17 - 1
bin/Data/Scripts/Editor/EditorScene.as

@@ -1639,7 +1639,23 @@ bool ColorWheelSetupBehaviorForColoring()
             ShowColorWheelWithColor(coloringOldColor);
         }
     }
-          
+    else if (coloringComponent.typeName == "Text3D") 
+    {
+        Text3D@ txt = cast<Text3D>(coloringComponent);
+        if (txt !is null) 
+        {
+            if (coloringPropertyName == "c" || coloringPropertyName == "tl")
+                coloringOldColor = txt.colors[C_TOPLEFT];
+            else if (coloringPropertyName == "tr") 
+                coloringOldColor = txt.colors[C_TOPRIGHT];
+            else if (coloringPropertyName == "bl") 
+                coloringOldColor = txt.colors[C_BOTTOMLEFT];
+            else if (coloringPropertyName == "br") 
+                coloringOldColor = txt.colors[C_BOTTOMRIGHT];
+            
+            ShowColorWheelWithColor(coloringOldColor);
+        }
+    }          
     return true;
 }
 

+ 27 - 1
bin/Data/Scripts/Editor/EditorUI.as

@@ -1960,7 +1960,15 @@ bool ColorWheelBuildMenuSelectTypeColor()
 
         actions.Push(CreateContextMenuItem("Cancel", "HandleColorWheelMenu", "menuCancel"));
     }
-
+    else if (coloringComponent.typeName == "Text3D")
+    {
+        actions.Push(CreateContextMenuItem("Color", "HandleColorWheelMenu", "c"));
+        actions.Push(CreateContextMenuItem("Top left color", "HandleColorWheelMenu", "tl"));
+        actions.Push(CreateContextMenuItem("Top right color", "HandleColorWheelMenu", "tr"));
+        actions.Push(CreateContextMenuItem("Bottom left color", "HandleColorWheelMenu", "bl"));
+        actions.Push(CreateContextMenuItem("Bottom right color", "HandleColorWheelMenu", "br"));
+        actions.Push(CreateContextMenuItem("Cancel", "HandleColorWheelMenu", "menuCancel"));
+    }
     if (actions.length > 0) {
         ActivateContextMenu(actions);
         return true;
@@ -2095,6 +2103,24 @@ void HandleWheelChangeColor(StringHash eventType, VariantMap& eventData)
                 attributesDirty = true;
             }
         }
+		else if (coloringComponent.typeName == "Text3D") 
+		{
+			Text3D@ txt = cast<Text3D>(coloringComponent);
+			if (txt !is null) 
+			{
+				if (coloringPropertyName == "c")
+					txt.color = c;
+				else if (coloringPropertyName == "tl") 
+					txt.colors[C_TOPLEFT] = c;
+				else if (coloringPropertyName == "tr") 
+					txt.colors[C_TOPRIGHT] = c;
+				else if (coloringPropertyName == "bl") 
+					txt.colors[C_BOTTOMLEFT] = c;
+				else if (coloringPropertyName == "br") 
+					txt.colors[C_BOTTOMRIGHT] = c;
+                attributesDirty = true;
+			}
+		}
     }
 
     timeToNextColoringGroupUpdate = time.systemTime + stepColoringGroupUpdate;