//[MenuItem("Window/UIModifier/Button &l")] //protected static void OpenButtonModifier() //{ // CurrentViewHeader = "Label"; // Initialize(); //} public static void Initialize() { CurrentViewHeader = "Button"; m_LabelProperty = new LabelProperty(); m_LabelProperty.Reset(); m_LabelProperty.OnSnap = OnSnapEvent; m_LabelProperty.OnAllPropertiesChanged = OnChangeAllEvent; m_SpriteProperty = new SpriteProperty(); m_SpriteProperty.Reset(); m_SpriteProperty.OnSnap = OnSnapEvent; m_SpriteProperty.OnAllPropertiesChanged = OnChangeAllEvent; m_ButtonProperty = new ButtonProperty(); m_ButtonProperty.Reset(); m_ButtonProperty.OnAllPropertiesChanged = OnChangeAllEvent; m_ButtonProperty.OnUpdateClick = OnButtonUpdateEvent; if (MainWindow == null) { MainWindow = GetWindow <UIQuickModifier>("UIQuick Replace", true); } MainWindow.Show(); MainWindow.Repaint(); }
/// <summary> /// Just Modify LocalPosition, not all values of Transform. /// </summary> /// <param name="widget"></param> /// <param name="value"></param> static public void ChangeTransform(UIWidget widget, WidgetProperty value) { if (value.Trans != new Vector3(-1, -1, -1)) { widget.transform.localPosition = value.Trans; } }
public void SetProperty(WidgetProperty content) { PivotH = content.PivotH; PivotV = content.PivotV; Depth = content.Depth; Width = content.Width; Height = content.Height; }
static public void ChangeWidgetProperties(UIWidget widget, WidgetProperty value) { widget.pivot = value.GetPivot(); if (value.Depth != -1) { widget.depth = value.Depth; } if (value.Width != -1 && value.Height != -1) { widget.width = value.Width; widget.height = value.Height; } if (widget is UISprite) { widget.keepAspectRatio = UIWidget.AspectRatioSource.Free; } }
static public bool OnSnap(UIWidget widget, WidgetProperty value) { if (!string.IsNullOrEmpty(value.Name) && widget.transform.name != value.Name) { return(false); } if (widget is UILabel) { EditorUtility.DisplayDialog("Error", "Operation is forbidden in UILabel!!", "OK"); return(false); } UISprite sprite = widget as UISprite; sprite.type = UIBasicSprite.Type.Simple; sprite.keepAspectRatio = UIWidget.AspectRatioSource.Free; sprite.MakePixelPerfect(); EditorUtility.SetDirty(widget); return(true); }
set => SetValue(WidgetProperty, value);