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
        /// <summary>
        /// 加载配置
        /// </summary>
        private void Load()
        {
            TextAsset textAsset = EditorAssets.LoadAssetAtPath <TextAsset>(_fullpath);

            if (textAsset != null)
            {
                _config = ConfigHelper.LoadFromXmlText <T>(textAsset.text);
            }
        }
Ejemplo n.º 3
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);
        }