Ejemplo n.º 1
0
        /// <summary>
        /// Create a texture and fill it with specified color
        /// </summary>
        /// <param name="color">Color of texture</param>
        /// <returns>Texture</returns>
        /// <param name="size">size of texture</param>
        /// <param name="border">Border</param>
        /// <param name="borderColor">Border color</param>
        /// <returns>Texture</returns>
        public static Texture2D CreateTexture(Color color, int size, Skill.Framework.UI.Thickness border, Color borderColor)
        {
            size = Mathf.Max(size, 1);
            Texture2D texture = new Texture2D(size, size, TextureFormat.ARGB32, true);

            FillImage(texture, 0, 0, size, size, color);

            if (border.Left >= 1)
            {
                FillImage(texture, 0, 0, size, (int)border.Left, borderColor);
            }
            if (border.Right >= 1)
            {
                FillImage(texture, 0, size - (int)border.Right - 1, size, (int)border.Left, borderColor);
            }
            if (border.Top >= 1)
            {
                FillImage(texture, 0, 0, (int)border.Top, size, borderColor);
            }
            if (border.Bottom >= 1)
            {
                FillImage(texture, size - (int)border.Bottom - 1, 0, (int)border.Bottom, size, borderColor);
            }

            texture.Apply();
            return(texture);
        }
Ejemplo n.º 2
0
        protected override void CreateCustomFileds()
        {
            base.CreateCustomFileds();

            Skill.Framework.UI.Thickness margin = new Skill.Framework.UI.Thickness(2, 2, 0, 2);

            _Object = new Skill.Editor.UI.ObjectField <GameObject>()
            {
                Margin = margin
            }; _Object.Label.text = "Game Object";
            _Component            = new Skill.Editor.UI.Popup()
            {
                Margin = margin
            }; _Component.Label.text = "Component";
            _Property = new Skill.Editor.UI.Popup()
            {
                Margin = margin
            }; _Property.Label.text = "Property";
            _BtnRefresh             = new Skill.Framework.UI.Button()
            {
                Margin = margin, Width = 80, HorizontalAlignment = Framework.UI.HorizontalAlignment.Right
            }; _BtnRefresh.Content.text = "Refresh";

            Controls.Add(_Object);
            Controls.Add(_BtnRefresh);
            Controls.Add(_Component);
            Controls.Add(_Property);

            _Object.ObjectChanged    += _Object_ObjectChanged;
            _Component.OptionChanged += _Component_OptionChanged;
            _Property.OptionChanged  += _Property_OptionChanged;
            _BtnRefresh.Click        += _BtnRefresh_Click;
        }
Ejemplo n.º 3
0
        private void Rebuild()
        {
            _SourceComponents.Controls.Clear();
            _DestinationComponents.Controls.Clear();

            if (_Source.Object != null && _Destination.Object != null)
            {
                EnableControls(true);

                Component[] sourceComponents = _Source.Object.GetComponents <Component>();
                Component[] destComponents   = _Destination.Object.GetComponents <Component>();

                _MatchedComponents.Clear();
                for (int i = 0; i < sourceComponents.Length; i++)
                {
                    MatchComponent match = new MatchComponent();
                    match.Source      = sourceComponents[i];
                    match.Destination = FindMatch(destComponents, match.Source.GetType());
                    match.Copy        = true;
                    if (match.Source is Transform)
                    {
                        match.Copy = false;
                    }
                    _MatchedComponents.Add(match);
                }

                Skill.Framework.UI.Thickness margin = new Skill.Framework.UI.Thickness(2, 2, 2, 6);
                foreach (var item in _MatchedComponents)
                {
                    Skill.Editor.UI.ToggleButton tb = new Skill.Editor.UI.ToggleButton()
                    {
                        Margin = margin, Left = true
                    };
                    tb.IsChecked  = item.Copy;
                    tb.UserData   = item;
                    tb.Label.text = item.Source.GetType().Name;
                    _SourceComponents.Controls.Add(tb);

                    Skill.Framework.UI.Label lbl = new Skill.Framework.UI.Label()
                    {
                        Margin = margin
                    };
                    if (item.Destination != null)
                    {
                        lbl.Text = item.Destination.GetType().Name;
                    }
                    _DestinationComponents.Controls.Add(lbl);

                    tb.Changed += ToggleButton_Changed;
                }
            }
            else
            {
                EnableControls(false);
            }
        }
Ejemplo n.º 4
0
        void OnEnable()
        {
            _ScreenShot = base.serializedObject.targetObject as ScreenShot;

            _Frame = new Skill.Framework.UI.Frame("Frame");
            _Frame.Grid.RowDefinitions.Add(1, Skill.Framework.UI.GridUnitType.Star);
            _Frame.Grid.RowDefinitions.Add(1, Skill.Framework.UI.GridUnitType.Star);
            _Frame.Grid.RowDefinitions.Add(1, Skill.Framework.UI.GridUnitType.Star);

            _BtnCustomSize = new Skill.Editor.UI.ToggleButton()
            {
                Row = 0, Column = 0, IsChecked = _ScreenShot.CustomSize
            };
            _BtnCustomSize.Label.text = "Custom size";

            Skill.Framework.UI.Thickness margin = new Skill.Framework.UI.Thickness(20, 0, 0, 0);

            _IFieldWidth = new Skill.Editor.UI.IntField()
            {
                Row = 1, Column = 0, Value = _ScreenShot.Width, Margin = margin
            };
            _IFieldWidth.Label.text = "Width";

            _IFieldHeight = new Skill.Editor.UI.IntField()
            {
                Row = 2, Column = 0, Value = _ScreenShot.Height, Margin = margin
            };
            _IFieldHeight.Label.text = "Height";

            _FFieldScale = new Skill.Editor.UI.FloatField()
            {
                Row = 1, Column = 0, Value = _ScreenShot.Scale, Margin = margin
            };
            _FFieldScale.Label.text = "Scale";

            _Frame.Grid.Controls.Add(_BtnCustomSize);
            _Frame.Grid.Controls.Add(_IFieldWidth);
            _Frame.Grid.Controls.Add(_IFieldHeight);
            _Frame.Grid.Controls.Add(_FFieldScale);

            _BtnCustomSize.Changed     += _BtnCustomSize_Changed;
            _IFieldWidth.ValueChanged  += _Width_ValueChanged;
            _IFieldHeight.ValueChanged += _Height_ValueChanged;
            _FFieldScale.ValueChanged  += _Scale_ValueChanged;

            ManageControls();
        }