예제 #1
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.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.ValueRef = winPlatformInfo.Icon;

                titleField.OnChanged += x => winPlatformInfo.TitleText = x;
                iconField.OnChanged  += x => winPlatformInfo.Icon = x;
            }
            break;
            }
        }