Ejemplo n.º 1
0
        protected override void InitUI(UIWidget layout)
        {
            var tex    = EditorAssets.LoadAssetAtPath <Texture>(EditorAssets.GetResourcePath("Textures/wooden-box.png"));
            var shader = Shader.Find("UI/Default");
            var mat    = new Material(shader);

            EditorPreviewTexture previewTexture = new EditorPreviewTexture();

            previewTexture.Image    = tex;
            previewTexture.Position = new Rect(0, 0, 128, 128);
            previewTexture.Mat      = mat;

            layout.Add(previewTexture);

            var fields = shader.GetType().GetFields();

            var shaderKeywords = mat.shaderKeywords;

            if (shaderKeywords != null || shaderKeywords.Length != 0)
            {
                for (var i = 0; i < shaderKeywords.Length; i++)
                {
                    var lable = new GUILabel();
                    lable.Text = shaderKeywords[i];
                    layout.Add(lable);
                }
            }
        }
Ejemplo n.º 2
0
        protected override void InitUI(UIWidget layout)
        {
            var tex    = EditorAssets.LoadAssetAtPath <Texture>(EditorAssets.GetResourcePath("Textures/wooden-box.png"));
            var shader = Shader.Find("UI/Default");
            var mat    = new Material(shader);

            EditorVerticalLayout vLayout = new EditorVerticalLayout();

            vLayout.Option.Height = 128;
            vLayout.Option.Width  = 128;

            layout.Add(vLayout);

            EditorPreviewTexture previewTexture = new EditorPreviewTexture();

            previewTexture.Image    = tex;
            previewTexture.Position = new Rect(0, 0, 128, 128);
            previewTexture.Mat      = mat;

            vLayout.Add(previewTexture);

            var textureField = new UITextureFieldWidget("Texture", tex);

            textureField.OnValueChanged = (object value) =>
            {
                previewTexture.Image = (Texture)value;
            };
            layout.Add(textureField);

            var shaderField = new UIShaderFieldWidget("Shader", shader);

            shaderField.OnValueChanged = (object value) =>
            {
                previewTexture.Mat = new Material((Shader)value);
            };
            layout.Add(shaderField);

            var matField = new UIMaterialFieldWidget("Material", mat);

            matField.OnValueChanged = (object value) =>
            {
                previewTexture.Mat = (Material)value;
            };
            layout.Add(matField);
        }
Ejemplo n.º 3
0
        protected override void InitUI(UIWidget layout)
        {
            UIFloatFieldWidget distance = new UIFloatFieldWidget("Distance", _distance);

            distance.OnValueChanged = (object value) =>
            {
                _distance = (float)value;
            };
            layout.Add(distance);

            layout.Add(new EditorHorizontalLine());

            UITextFieldWidget axis = new UITextFieldWidget("AXIS:", GetText());

            layout.Add(axis);

            EditorHorizontalLayout hlayout1 = new EditorHorizontalLayout();

            layout.Add(hlayout1);
            GUIButton axisX = new GUIButton();

            axisX.Text           = "X";
            axisX.TriggerHandler = (Widget w) =>
            {
                this.OrderBy(OrderAxis.X);
                this.SetText(axis);
            };
            hlayout1.Add(axisX);

            GUIButton axisY = new GUIButton();

            axisY.Text           = "Y";
            axisY.TriggerHandler = (Widget w) =>
            {
                this.OrderBy(OrderAxis.Y);
                this.SetText(axis);
            };
            hlayout1.Add(axisY);

            GUIButton axisZ = new GUIButton();

            axisZ.Text           = "Z";
            axisZ.TriggerHandler = (Widget w) =>
            {
                this.OrderBy(OrderAxis.Z);
                this.SetText(axis);
            };
            hlayout1.Add(axisZ);

            EditorPrefixLabel alignment = new EditorPrefixLabel();

            alignment.Text = "Alignment:";
            layout.Add(alignment);

            EditorHorizontalLayout hlayout2 = new EditorHorizontalLayout();

            layout.Add(hlayout2);

            GUIButton left = new GUIButton();

            left.ImagePath      = EditorAssets.GetResourcePath("Icons/layout_alignment_left.png");
            left.TriggerHandler = (Widget w) =>
            {
                this.OrderBy(TextAlignment.Left);
            };
            hlayout2.Add(left);

            GUIButton center = new GUIButton();

            center.ImagePath      = EditorAssets.GetResourcePath("Icons/layout_alignment_center.png");
            center.TriggerHandler = (Widget w) =>
            {
                this.OrderBy(TextAlignment.Center);
            };
            hlayout2.Add(center);

            GUIButton right = new GUIButton();

            right.ImagePath      = EditorAssets.GetResourcePath("Icons/layout_alignment_right.png");
            right.TriggerHandler = (Widget w) =>
            {
                this.OrderBy(TextAlignment.Right);
            };
            hlayout2.Add(right);
        }