コード例 #1
0
ファイル: LinkerHandle.cs プロジェクト: swaphack/effect
        protected override void InitSceneGUI(UIWidget layout)
        {
            EditorVerticalLayout vLayout = new EditorVerticalLayout();

            {
                vLayout.Add(new UILabelFieldWidget("Name", _behaviour.name));
                vLayout.Add(new UILabelFieldWidget("Tag", _behaviour.tag));
                vLayout.Add(new UIVector3FieldWidget("Local Position", _behaviour.transform.localPosition));
                vLayout.Add(new UIVector3FieldWidget("Local Rotation", _behaviour.transform.localEulerAngles));
                vLayout.Add(new UIVector3FieldWidget("Local Scale", _behaviour.transform.localScale));

                vLayout.Add(new UIVector3FieldWidget("World Position", _behaviour.transform.position));
                vLayout.Add(new UIVector3FieldWidget("World Rotation", _behaviour.transform.eulerAngles));
                vLayout.Add(new UIVector3FieldWidget("World Scale", _behaviour.transform.lossyScale));
            }
            layout.Add(vLayout);
        }
コード例 #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);
        }
コード例 #3
0
ファイル: ImageSettingWindow.cs プロジェクト: swaphack/effect
        protected override void InitUI(UIWidget layout)
        {
            EditorVerticalLayout vLayout = new EditorVerticalLayout();

            layout.Add(vLayout);

            UIIntPopupFieldWidget textureType = new UIIntPopupFieldWidget("Texture Type", setting.textureType);

            textureType.Describes      = TextureTypeString;
            textureType.Indexs         = TextureIntArray;
            textureType.OnValueChanged = (object value) =>
            {
                setting.textureType = (TextureImporterType)value;
            };
            vLayout.Add(textureType);

            UIIntPopupFieldWidget spriteMode = new UIIntPopupFieldWidget("Sprite Mode", setting.spriteMode);

            spriteMode.Describes      = SpriteModeString;
            spriteMode.Indexs         = IntArray;
            spriteMode.OnValueChanged = (object value) =>
            {
                setting.spriteMode = (SpriteImportMode)value;
            };
            vLayout.Add(spriteMode);


            UIBooleanFieldWidget sRGGUITexture = new UIBooleanFieldWidget("sRGGUITexture", setting.sRGGUITexture);

            sRGGUITexture.OnValueChanged = (object value) =>
            {
                setting.sRGGUITexture = (bool)value;
            };
            vLayout.Add(sRGGUITexture);

            UIIntPopupFieldWidget alphaSource = new UIIntPopupFieldWidget("Alpha Source", setting.alphaSource);

            alphaSource.Describes      = AlphaSourceString;
            alphaSource.Indexs         = IntArray;
            alphaSource.OnValueChanged = (object value) =>
            {
                setting.alphaSource = (TextureImporterAlphaSource)value;
            };
            vLayout.Add(alphaSource);

            UIBooleanFieldWidget alphaIsTransparency = new UIBooleanFieldWidget("Alpha Is Transparency", setting.alphaIsTransparency);

            alphaIsTransparency.OnValueChanged = (object value) =>
            {
                setting.alphaIsTransparency = (bool)value;
            };
            vLayout.Add(alphaIsTransparency);

            UIIntPopupFieldWidget filterMode = new UIIntPopupFieldWidget("Filter Mode", setting.filterMode);

            filterMode.Describes      = FilterModeString;
            filterMode.Indexs         = IntArray;
            filterMode.OnValueChanged = (object value) =>
            {
                setting.filterMode = (FilterMode)value;
            };
            vLayout.Add(filterMode);

            UIIntPopupFieldWidget wrapMode = new UIIntPopupFieldWidget("Wrap Mode", setting.wrapMode);

            wrapMode.Describes      = WrapModeString;
            wrapMode.Indexs         = IntArray;
            wrapMode.OnValueChanged = (object value) =>
            {
                setting.wrapMode = (TextureWrapMode)value;
            };
            vLayout.Add(wrapMode);


            UIIntSlideFieldWidget anisoLevel = new UIIntSlideFieldWidget("Aniso Level", setting.anisoLevel);

            anisoLevel.MinValue       = 0;
            anisoLevel.MaxValue       = 9;
            anisoLevel.OnValueChanged = (object value) =>
            {
                setting.anisoLevel = (int)value;
            };
            vLayout.Add(anisoLevel);

            UIIntPopupFieldWidget maxTextureSize = new UIIntPopupFieldWidget("Max Size", setting.maxTextureSize);

            maxTextureSize.Describes      = MaxSizeString;
            maxTextureSize.Indexs         = SizeIntArray;
            maxTextureSize.OnValueChanged = (object value) =>
            {
                setting.maxTextureSize = (int)value;
            };
            vLayout.Add(maxTextureSize);

            UIIntPopupFieldWidget textureCompression = new UIIntPopupFieldWidget("Texture Compression", setting.textureCompression);

            textureCompression.Describes      = FormatString;
            textureCompression.Indexs         = IntArray;
            textureCompression.OnValueChanged = (object value) =>
            {
                setting.textureCompression = (TextureImporterCompression)value;
            };
            vLayout.Add(maxTextureSize);

            EditorHorizontalLine line = new EditorHorizontalLine();

            vLayout.Add(line);

            GUIButton btn = new GUIButton();

            btn.Text           = "Format";
            btn.TriggerHandler = (Widget w) =>
            {
                FormatTextures();
            };
            vLayout.Add(btn);
        }
コード例 #4
0
        /// <summary>
        /// 创建图片预览
        /// </summary>
        /// <param name="allpath"></param>
        /// <returns></returns>
        private Widget CreateImagePreviewWidget(string[] allpath)
        {
            EditorScrollView scrollView = new EditorScrollView();

            scrollView.InnerSpace = InnerSpace;

            if (allpath == null || allpath.Length == 0)
            {
                return(scrollView);
            }

            var frameSize = this.position.size;

            float w = frameSize.x - 40;

            w -= InnerSpace;
            int count = (int)(w / (ImageSize.x + InnerSpace));

            EditorHorizontalLayout hLayout = null;

            for (int i = 0; i < allpath.Length; i++)
            {
                if (i % count == 0)
                {
                    hLayout            = new EditorHorizontalLayout();
                    hLayout.InnerSpace = InnerSpace;
                    scrollView.Add(hLayout);
                }

                EditorVerticalLayout vLayout = new EditorVerticalLayout();
                vLayout.Option.Width = ImageSize.x;
                hLayout.Add(vLayout);

                {
                    string fullpath = allpath[i];

                    string filename = fullpath.Substring(fullpath.LastIndexOf('/') + 1);

                    GUIButton button = new GUIButton();
                    button.Option.Width   = ImageSize.x;
                    button.Option.Height  = ImageSize.y;
                    button.ImagePosition  = ImagePosition.ImageAbove;
                    button.ImagePath      = fullpath;
                    button.Tooltip        = fullpath;
                    button.TriggerHandler = (Widget widget) =>
                    {
                        SetSelectImageSprite(button.ImagePath);
                    };
                    vLayout.Add(button);

                    var label = new GUILabel();
                    label.Option.Height = 25;
                    label.Option.Width  = ImageSize.x;
                    label.Text          = filename;
                    label.FontSize      = 10;
                    label.Alignment     = TextAnchor.MiddleCenter;
                    vLayout.Add(label);
                }
            }
            return(scrollView);
        }
コード例 #5
0
        protected override void InitUI(UIWidget layout)
        {
            EditorVerticalLayout innerLayout = new EditorVerticalLayout();

            innerLayout.InnerSpace = 10;
            layout.Add(innerLayout);

            {
                EditorHorizontalLayout hLayout = new EditorHorizontalLayout();
                hLayout.InnerSpace = 10;

                EditorPrefixLabel label = new EditorPrefixLabel();
                label.Text = "Asset Path :";
                hLayout.Add(label);

                bundleFolder.Text = "Open";
                string bundles = FilePath.BundlesPath;
                bundleFolder.Filepath = Path.Combine(EditorAssets.Root, bundles).Replace("\\", "/");
                hLayout.Add(bundleFolder);

                innerLayout.Add(hLayout);
            }
            {
                EditorHorizontalLayout hLayout = new EditorHorizontalLayout();
                hLayout.InnerSpace = 10;

                EditorPrefixLabel label = new EditorPrefixLabel();
                label.Text = "Out Path :";
                hLayout.Add(label);

                outputFolder.Filepath = Path.Combine(EditorAssets.Root, "Output").Replace("\\", "/");
                outputFolder.Text     = "Open";
                hLayout.Add(outputFolder);

                innerLayout.Add(hLayout);
            }

            {
                VerticalLayout vLayout = new VerticalLayout();
                vLayout.InnerSpace = 10;

                EditorIntPopup popup = new EditorIntPopup();
                popup.Text           = "Choose Platform :";
                popup.Value          = platformIndex;
                popup.TriggerHandler = (Widget w) =>
                {
                    platformIndex = popup.Value;
                };

                for (int i = 0; i < PlatformInfo.Count; i++)
                {
                    popup.Add(new EditorIntPopup.DisplayItem(PlatformInfo[i].name, PlatformInfo[i].index));
                }

                vLayout.Add(popup);

                GUIButton button = new GUIButton();
                button.Text           = "Pack";
                button.TriggerHandler = (Widget w) =>
                {
                    Pack((Platform)PlatformInfo[platformIndex].value, PlatformInfo[platformIndex].name);
                };
                vLayout.Add(button);

                innerLayout.Add(vLayout);
            }
        }