コード例 #1
0
        /// <summary>
        /// Creates a new material parameter GUI.
        /// </summary>
        /// <param name="shaderParam">Shader parameter to create the GUI for. Must be of texture type.</param>
        /// <param name="material">Material the parameter is a part of.</param>
        /// <param name="layout">Layout to append the GUI elements to.</param>
        internal MaterialParamTextureGUI(ShaderParameter shaderParam, Material material, GUILayout layout)
            : base(shaderParam)
        {
            LocString title = new LocEdString(shaderParam.name);

            guiElem = new GUITextureField(title);

            switch (shaderParam.type)
            {
            case ShaderParameterType.Texture2D:
            case ShaderParameterType.Texture3D:
            case ShaderParameterType.TextureCube:
                guiElem.OnChanged += (x) =>
                {
                    Resource resource = x.Value;

                    if (resource is Texture tex)
                    {
                        material.SetTexture(shaderParam.name, tex);
                    }
                    else if (resource is SpriteTexture spriteTex)
                    {
                        material.SetSpriteTexture(shaderParam.name, spriteTex);
                    }

                    EditorApplication.SetDirty(material);
                };
                break;
            }

            layout.AddElement(guiElem);
        }
コード例 #2
0
        /// <summary>
        /// Creates a new material parameter GUI.
        /// </summary>
        /// <param name="shaderParam">Shader parameter to create the GUI for. Must be of texture type.</param>
        /// <param name="material">Material the parameter is a part of.</param>
        /// <param name="layout">Layout to append the GUI elements to.</param>
        internal MaterialParamTextureGUI(ShaderParameter shaderParam, Material material, GUILayout layout)
            : base(shaderParam)
        {
            LocString title = new LocEdString(shaderParam.Name);

            guiElem = new GUITextureField(title);

            switch (shaderParam.Type)
            {
            case ShaderParameterType.Texture2D:
                guiElem.OnChanged += (x) =>
                {
                    Texture2D texture = Resources.Load <Texture2D>(x);

                    material.SetTexture2D(shaderParam.Name, texture);
                    EditorApplication.SetDirty(material);
                };
                break;

            case ShaderParameterType.Texture3D:
                guiElem.OnChanged += (x) =>
                {
                    Texture3D texture = Resources.Load <Texture3D>(x);

                    material.SetTexture3D(shaderParam.Name, texture);
                    EditorApplication.SetDirty(material);
                };
                break;

            case ShaderParameterType.TextureCube:
                guiElem.OnChanged += (x) =>
                {
                    TextureCube texture = Resources.Load <TextureCube>(x);

                    material.SetTextureCube(shaderParam.Name, texture);
                    EditorApplication.SetDirty(material);
                };
                break;
            }

            layout.AddElement(guiElem);
        }
コード例 #3
0
        /// <summary>
        /// (Re)creates GUI with platform-specific options.
        /// </summary>
        private void BuildPlatformOptionsGUI()
        {
            optionsScrollArea.Layout.Clear();
            GUILayout layout = optionsScrollArea.Layout;

            PlatformInfo platformInfo = BuildManager.GetPlatformInfo(selectedPlatform);

            GUILabel options = new GUILabel(new LocEdString("Platform options"), EditorStyles.LabelCentered);

            GUIResourceField sceneField = new GUIResourceField(typeof(Prefab), new LocEdString("Startup scene"));
            GUIToggleField debugToggle = new GUIToggleField(new LocEdString("Debug"));

            GUIToggleField fullscreenField = new GUIToggleField(new LocEdString("Fullscreen"));
            GUIIntField widthField = new GUIIntField(new LocEdString("Window width"));
            GUIIntField heightField = new GUIIntField(new LocEdString("Window height"));

            GUITextField definesField = new GUITextField(new LocEdString("Defines"));

            layout.AddSpace(5);
            layout.AddElement(options);
            layout.AddSpace(5);
            layout.AddElement(sceneField);
            layout.AddElement(debugToggle);
            layout.AddElement(fullscreenField);
            layout.AddElement(widthField);
            layout.AddElement(heightField);
            layout.AddSpace(5);
            layout.AddElement(definesField);
            layout.AddSpace(5);

            sceneField.ValueRef = platformInfo.MainScene;
            debugToggle.Value = platformInfo.Debug;
            definesField.Value = platformInfo.Defines;
            fullscreenField.Value = platformInfo.Fullscreen;
            widthField.Value = platformInfo.WindowedWidth;
            heightField.Value = platformInfo.WindowedHeight;

            if (platformInfo.Fullscreen)
            {
                widthField.Active = false;
                heightField.Active = false;
            }

            sceneField.OnChanged += x => platformInfo.MainScene = x;
            debugToggle.OnChanged += x => platformInfo.Debug = x;
            definesField.OnChanged += x => platformInfo.Defines = x;
            fullscreenField.OnChanged += x =>
            {
                widthField.Active = !x;
                heightField.Active = !x;

                platformInfo.Fullscreen = x;
            };
            widthField.OnChanged += x => platformInfo.WindowedWidth = x;
            heightField.OnChanged += x => platformInfo.WindowedHeight = x;

            switch (platformInfo.Type)
            {
                case PlatformType.Windows:
                {
                    WinPlatformInfo winPlatformInfo = (WinPlatformInfo) platformInfo;

                    GUITextField titleField = new GUITextField(new LocEdString("Title"));

                    layout.AddElement(titleField);
                    layout.AddSpace(5);

                    GUITextureField iconField = new GUITextureField(new LocEdString("Icon"));
                    layout.AddElement(iconField);

                    titleField.Value = winPlatformInfo.TitleText;
                    iconField.ValueRef = winPlatformInfo.Icon;

                    titleField.OnChanged += x => winPlatformInfo.TitleText = x;
                    iconField.OnChanged += x => winPlatformInfo.Icon = x;
                }
                    break;
            }
        }
コード例 #4
0
ファイル: GUITextureField.cs プロジェクト: Ruu/BansheeEngine
 private static extern void Internal_CreateInstance(GUITextureField instance, GUIContent title, int titleWidth,
     string style, GUIOption[] options, bool withTitle);
コード例 #5
0
 private static extern void Internal_CreateInstance(GUITextureField instance, GUITextureFieldType type,
                                                    ref GUIContent title, int titleWidth, string style, GUIOption[] options, bool withTitle);
コード例 #6
0
ファイル: BuildWindow.cs プロジェクト: xuebai5/BansheeEngine
        /// <summary>
        /// (Re)creates GUI with platform-specific options.
        /// </summary>
        private void BuildPlatformOptionsGUI()
        {
            optionsScrollArea.Layout.Clear();
            GUILayout layout = optionsScrollArea.Layout;

            PlatformInfo platformInfo = BuildManager.GetPlatformInfo(selectedPlatform);

            GUILabel options = new GUILabel(new LocEdString("Platform options"), EditorStyles.LabelCentered);

            GUIResourceField sceneField  = new GUIResourceField(typeof(Prefab), new LocEdString("Startup scene"));
            GUIToggleField   debugToggle = new GUIToggleField(new LocEdString("Debug"));

            GUIToggleField fullscreenField = new GUIToggleField(new LocEdString("Fullscreen"));
            GUIIntField    widthField      = new GUIIntField(new LocEdString("Window width"));
            GUIIntField    heightField     = new GUIIntField(new LocEdString("Window height"));

            GUITextField definesField = new GUITextField(new LocEdString("Defines"));

            layout.AddSpace(5);
            layout.AddElement(options);
            layout.AddSpace(5);
            layout.AddElement(sceneField);
            layout.AddElement(debugToggle);
            layout.AddElement(fullscreenField);
            layout.AddElement(widthField);
            layout.AddElement(heightField);
            layout.AddSpace(5);
            layout.AddElement(definesField);
            layout.AddSpace(5);

            sceneField.ValueRef   = platformInfo.MainScene;
            debugToggle.Value     = platformInfo.Debug;
            definesField.Value    = platformInfo.Defines;
            fullscreenField.Value = platformInfo.Fullscreen;
            widthField.Value      = platformInfo.WindowedWidth;
            heightField.Value     = platformInfo.WindowedHeight;

            if (platformInfo.Fullscreen)
            {
                widthField.Active  = false;
                heightField.Active = false;
            }

            sceneField.OnChanged      += x => platformInfo.MainScene = x.As <Prefab>();
            debugToggle.OnChanged     += x => platformInfo.Debug = x;
            definesField.OnChanged    += x => platformInfo.Defines = x;
            fullscreenField.OnChanged += x =>
            {
                widthField.Active  = !x;
                heightField.Active = !x;

                platformInfo.Fullscreen = x;
            };
            widthField.OnChanged  += x => platformInfo.WindowedWidth = x;
            heightField.OnChanged += x => platformInfo.WindowedHeight = x;

            switch (platformInfo.Type)
            {
            case PlatformType.Windows:
            {
                WinPlatformInfo winPlatformInfo = (WinPlatformInfo)platformInfo;

                GUITextField titleField = new GUITextField(new LocEdString("Title"));

                layout.AddElement(titleField);
                layout.AddSpace(5);

                GUITextureField iconField = new GUITextureField(new LocEdString("Icon"));
                layout.AddElement(iconField);

                titleField.Value     = winPlatformInfo.TitleText;
                iconField.TextureRef = winPlatformInfo.Icon;

                titleField.OnChanged += x => winPlatformInfo.TitleText = x;
                iconField.OnChanged  += x => winPlatformInfo.Icon = x.As <Texture>();
            }
            break;
            }
        }
コード例 #7
0
        /// <summary>
        /// Creates a new material parameter GUI.
        /// </summary>
        /// <param name="shaderParam">Shader parameter to create the GUI for. Must be of texture type.</param>
        /// <param name="material">Material the parameter is a part of.</param>
        /// <param name="layout">Layout to append the GUI elements to.</param>
        internal MaterialParamTextureGUI(ShaderParameter shaderParam, Material material, GUILayout layout)
            : base(shaderParam)
        {
            LocString title = new LocEdString(shaderParam.Name);
            guiElem = new GUITextureField(title);

            switch (shaderParam.Type)
            {
                case ShaderParameterType.Texture2D:
                    guiElem.OnChanged += (x) =>
                    {
                        Texture2D texture = Resources.Load<Texture2D>(x);

                        material.SetTexture2D(shaderParam.Name, texture);
                        EditorApplication.SetDirty(material);
                    };
                    break;
                case ShaderParameterType.Texture3D:
                    guiElem.OnChanged += (x) =>
                    {
                        Texture3D texture = Resources.Load<Texture3D>(x);

                        material.SetTexture3D(shaderParam.Name, texture);
                        EditorApplication.SetDirty(material);
                    };
                    break;
                case ShaderParameterType.TextureCube:
                    guiElem.OnChanged += (x) =>
                    {
                        TextureCube texture = Resources.Load<TextureCube>(x);

                        material.SetTextureCube(shaderParam.Name, texture);
                        EditorApplication.SetDirty(material);
                    };
                    break;
            }

            layout.AddElement(guiElem);
        }