예제 #1
0
            public void Draw()
            { //DrawArrowedLine( fullRect.x, fullRect.y, fullRect.x + 100, fullRect.y + 100, ACTIVE_COLOR );
              // DrawArrowedLine( fullRect.x, fullRect.y, fullRect.x + 100, fullRect.y + 100 , PASSIVE_COLOR );
              // DRAW_TEXTURE("i_RGB", fullRect);



                { if (!target.target.compiler || !target.target.compiler.material)
                  {
                      return;
                  }

                  // GUI.Label( new Rect( fullRect.x, fullRect.y, fullRect.width, FastWaterModel20ControllerEditor.H ), "Independent common settings:" );
                  // fullRect.y += FastWaterModel20ControllerEditor.H;
                  GUILayout.Label("Common settings:");


                  var r      = EditorGUILayout.GetControlRect(GUILayout.Width(390), GUILayout.Height(70));
                  var resetX = r.x;

                  var S = 10;
                  r.width  = 0;
                  r.height = 31;

                  target.DRAW_TOGGLE(r, "Fog", FIELDS.SKIP_FOG, true, out tV);
                  r.x = tV.x + S;
                  target.DRAW_TOGGLE(r, "Force Opaque", "FORCE_OPAQUE", !target.target.compiler.IsKeywordEnabled("USE_SHADOWS"), out tV);
                  GUI_TOOLTIP(r, "You may tor try Opaque shader with baked refraction and zdepth");

                  //  GUI_TOOLTIP(r, "Not sure that disabled option always works");
                  r.x = tV.x + S;

                  target.DRAW_TOGGLE(r, "Receive Shadows", "USE_SHADOWS", !target.MODE_MINIMUM, out tV);
                  GUI_TOOLTIP(r, "Works only with non transparent shader");
                  r.x = tV.x + S;
                  target.DRAW_TOGGLE(r, "Ambient", FIELDS.SKIP_AMBIENT_COLOR, true, out tV);



                  r.y += 35;
                  r.x  = resetX;

                  /*  var oldUFM = target.target.compiler.IsKeywordEnabled("ULTRA_FAST_MODE");
                   * target.DRAW_TOGGLE(r, "Ultra Fast Mode", "ULTRA_FAST_MODE", true, out tV);
                   * var newUFM = target.target.compiler.IsKeywordEnabled("ULTRA_FAST_MODE");
                   * if (oldUFM != newUFM)
                   * {
                   *    target.target.Undo(target.target.compiler);
                   *    target.target.compiler.WaterType = newUFM ? FastWaterModel20Compiler.WaterShaderType.UltraFast : FastWaterModel20Compiler.WaterShaderType.Standard;
                   *    FastWaterModel20Controller.SetDirty(target.target.compiler);
                   *    target.target.compiler.UpdateCompiler();
                   * }
                   * GUI_TOOLTIP(r, "Special Option for Mobile platforms");
                   *
                   *
                   * r.x = tV.x + S;*/
                  target.DRAW_TOGGLE(r, "LightMaps (test)", FIELDS.SKIP_LIGHTMAPS, true, out tV);
                  // GUI_TOOLTIP(r, "If there're no genrated lightmaps then water plane will be black");
                  r.x = tV.x + S;



                  r.x = (tV.x + S - resetX) * 2 + resetX;

                  r.x = tV.x + S;
                  target.DRAW_TOGGLE(r, "GPU Instance", FIELDS.USE_GPU_INSTANCE_FEATURE, true, out tV);
                  GUI_TOOLTIP(r, "DirectX 11+/ES3.0+");
                  r.x = tV.x + S;
                  target.DRAW_TOGGLE(r, "Stereo Mode", FIELDS.USE_VERTEX_OUTPUT_STEREO, true, out tV);
                  GUI_TOOLTIP(r, "USE_VERTEX_OUTPUT_STEREO");

                  r.x = tV.x + S;
                  bool?v = target.target.UseTextureConverter;
                  target.DRAW_TOGGLE(r, "Textures Converter", null, true, out tV, ref v);
                  GUI_TOOLTIP(r, @"This option affects automatically baked textures
- If it's OFF then the original Render Textures will be assigned to the shader, this little slowdown the shader's work on mobile devices
- However, if you Enable this option, the conversion will take much longer time during the level initialization or the manual baking, will be better if you test it itself and try to use 32 or 64 texture's size");
                  if (v != target.target.UseTextureConverter)
                  {
                      target.target.Undo();
                      target.target.UseTextureConverter = v.Value;
                      target.target.SetDirty();
                  }
                }



                GUILayout.BeginHorizontal();
                var oc = GUI.color;

                GUI.color *= target.IS_GRABPASS ? (Color) new Color32(54, 181, 255, 255) : Color.white;
                var HR = EditorGUILayout.GetControlRect(GUILayout.Height(FastWaterModel20ControllerEditor.H), GUILayout.Width(390));

                HR.width /= 2;
                EditorGUI.HelpBox(HR, target.IS_GRABPASS ? "GrabPass Enabled" : "GrabPass Disabled", target.IS_GRABPASS ? MessageType.Warning : MessageType.Info);
                if (target.IS_GRABPASS)
                {
                    GUI_TOOLTIP(GUILayoutUtility.GetLastRect(),
                                "This means that the shader will render in real time the objects behind material (Use the refraction settings to disable it)");                     //r.x += r.width;
                }
                GUI.color  = oc;
                GUI.color *= target.IS_OPAQUE ? (Color) new Color32(54, 181, 255, 255) : Color.white;
                HR.x      += HR.width;
                EditorGUI.HelpBox(HR, target.IS_OPAQUE ? "Opaque Enabled" : "Opaque Disabled", target.IS_OPAQUE ? MessageType.Warning : MessageType.Info);
                if (target.IS_OPAQUE)
                {
                    GUI_TOOLTIP(GUILayoutUtility.GetLastRect(), "This means that the shader will not be transparent (Disable shadows to disable it)");
                }
                GUI.color = oc;
                GUILayout.EndHorizontal();



                GUILayout.BeginVertical(GUILayout.Width(390));

                if (target.IS_OPAQUE)
                { /* var cont = new GUIContent("Material is Opaque. Basically it is required that the material receives shadows. Opaque makes Real-time ZDepth mode not available.");
                   * // r.height = EditorStyles.helpBox.CalcHeight( cont, LAST_GROUP_R.width );
                   * EditorGUILayout.HelpBox(cont.text, MessageType.None); //r.y += r.height;*/
                }

                /* if (target.pop_depth.keys[target.pop_depth.VALUE] == FIELDS.ALLOW_MANUAL_DEPTH && !target.IS_OPAQUE) {
                 * var cont = new GUIContent("You are using a mobile's devices target, the Real-time ZDepth may not work correctly, you just to make sure is it working fine or change the ZDepth \"Camera Render Realtime\" option to Baked");
                 * // r.height = EditorStyles.helpBox.CalcHeight( cont, LAST_GROUP_R.width );
                 * // r.height = FastWaterModel20ControllerEditor.H * 3;
                 * EditorGUILayout.HelpBox( cont.text, MessageType.Warning ); //r.y += r.height;
                 * }*/
            #if MOBILE_TARGET
                if (target.IS_GRABPASS)
                {
                    var cont = new
                               GUIContent("Note that, GrabPass does not work on the openGLES 2.0, for 2.0 it is better to use an opaque shader with baked refraction, you may make a separate material for different platforms");
                    //var cont = new GUIContent("Material has GrabPass. For mobile it is better to use an opaque shader with baked refraction. if you do not need GrabPass");
                    // r.height = EditorStyles.helpBox.CalcHeight( cont, LAST_GROUP_R.width );
                    EditorGUILayout.HelpBox(cont.text, MessageType.Warning); //r.y += r.height;
                }

                if (target.target.compiler.IsKeywordEnabled("REFLECTION_PLANAR"))
                { // var cont = new GUIContent("Material has Plannar reflection. Please change material reflection settings for mobile devices");
                    var cont = new GUIContent("Material has Plannar reflection. PLease try to keep minimum resolution for reflection");
                    // r.height = EditorStyles.helpBox.CalcHeight( cont, LAST_GROUP_R.width );
                    EditorGUILayout.HelpBox(cont.text, MessageType.Info); //r.y += r.height;
                }
                if (target.pop_reflection.keys[target.pop_reflection.VALUE] == FIELDS.REFLECTION_PROBE_AND_INTENSITY || target.pop_reflection.keys[target.pop_reflection.VALUE] == FIELDS.REFLECTION_PROBE)
                {
                    var cp = target.target.transform.GetComponentInChildren <ReflectionProbe>();
                    if (cp && cp.mode == UnityEngine.Rendering.ReflectionProbeMode.Realtime)
                    {
                        var cont = new GUIContent("Note that, Mobile platform does not support RealTime reflection probes, you shoud go to the probes settings and change RealTime options to Bake");
                        // r.height = EditorStyles.helpBox.CalcHeight( cont, LAST_GROUP_R.width );
                        EditorGUILayout.HelpBox(cont.text, MessageType.Warning); //r.y += r.height;
                    }
                }
            #endif

                GUILayout.EndVertical();



                {
                    // GUI.Label( new Rect( fullRect.x, fullRect.y, fullRect.width, FastWaterModel20ControllerEditor.H ), "Water settings:" );
                    // fullRect.y += FastWaterModel20ControllerEditor.H;
                    GUILayout.Space(10);
                    GUILayout.Label("Water settings:");

                    var r = EditorGUILayout.GetControlRect(GUILayout.Width(390), GUILayout.Height(60));
                    var S = 10;
                    r.width = 90;
                    // r.x = resetX;
                    // r.y += 35;
                    r        = target.DRAW_BG_TEXTURE(r, "Waves Normal", FIELDS._BumpMap, true, out tV, null);
                    V_NORMAL = new Vector2(r.x, r.y + r.height / 2);
                    r.x     += TOGGLE_WIDTH + S;
                    // r.y += r.height;
                    r             = target.DRAW_BG_TEXTURE(r, "Main Texture", FIELDS._MainTex, true, out tV, null);
                    V_MAINTEXTURE = new Vector2(r.x + r.width * .66f, r.y + r.height);
                    r.x          += TOGGLE_WIDTH + S;


                    if (target.MODE_ADVANCEPC)
                    {
                        r       = target.DRAW_BG_TEXTURE(r, "Utils Texture", FIELDS._Utility, true, out tV, null);// r.y += r.height;
                        V_UTILS = new Vector2(r.x + r.width * .33f, r.y + r.height);
                        r.x    += TOGGLE_WIDTH + S;
                        // r.height = FastWaterModel20ControllerEditor.H * 6;
                        //  EditorGUI.HelpBox(r, "(R) - Fresnel Gradient\n(G|B) - Foam Gradient", MessageType.None);// r.y += r.height;

                        r = target.DRAW_BG_TEXTURE(r, "Noise", FIELDS._NoiseHQ, target.HAS_NOISEHQ_TEX, out tV, null);// r.y += r.height;
                    }
                    else
                    {
                        r       = target.DRAW_BG_TEXTURE(r, "Second Texture", "_UF_NMASK_Texture", target.HAS_SECOND_TEX, out tV, null);// r.y += r.height;
                        V_UTILS = new Vector2(r.x + r.width * .33f, r.y + r.height);
                        r.x    += TOGGLE_WIDTH + S;
                        // r.height = FastWaterModel20ControllerEditor.H * 6;
                        //  EditorGUI.HelpBox(r, "(R) - Fresnel Gradient\n(G|B) - Foam Gradient", MessageType.None);// r.y += r.height;

                        r = target.DRAW_BG_TEXTURE(r, "Utils Texture", FIELDS._Utility, true, out tV, null);// r.y += r.height;
                    }


                    tV = new Vector2(r.x + r.width, r.y + r.height + FastWaterModel20ControllerEditor.H);

                    GUILayout.Space(FastWaterModel20ControllerEditor.H * 1.5f);
                    //EditorGUILayout.GetControlRect()
                }
            }
예제 #2
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            if (toolbars != null && toolbars.Count > 1)
            {
                GUILayout.BeginVertical(headerAttribute != null ? headerAttribute.header : target.GetType().Name, skin.window);
                GUILayout.Label(m_Logo, skin.label, GUILayout.MaxHeight(25));
                if (headerAttribute.openClose)
                {
                    openCloseWindow = GUILayout.Toggle(openCloseWindow, openCloseWindow ? "Close Properties" : "Open Properties", EditorStyles.toolbarButton);
                }

                if (!headerAttribute.openClose || openCloseWindow)
                {
                    var titles = getToobarTitles();
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Script"));

                    var customToolbar = skin.GetStyle("customToolbar");
                    if (headerAttribute.useHelpBox)
                    {
                        EditorGUILayout.HelpBox(headerAttribute.helpBoxText, MessageType.Info);
                    }
                    GUILayout.Space(10);
                    selectedToolBar = GUILayout.SelectionGrid(selectedToolBar, titles, titles.Length > 2?3: titles.Length, customToolbar, GUILayout.MinWidth(250));
                    if (!(selectedToolBar < toolbars.Count))
                    {
                        selectedToolBar = 0;
                    }
                    GUILayout.Space(10);
                    //GUILayout.Box(toolbars[selectedToolBar].title, skin.box, GUILayout.ExpandWidth(true));
                    var ignore           = getIgnoreProperties(toolbars[selectedToolBar]);
                    var ignoreProperties = ignore.Append(ignore_vMono);
                    DrawPropertiesExcluding(serializedObject, ignoreProperties);
                }
                GUILayout.EndVertical();
            }
            else
            {
                if (headerAttribute == null)
                {
                    if (((vMonoBehaviour)target) != null)
                    {
                        DrawPropertiesExcluding(serializedObject, ignore_vMono);
                    }
                    else
                    {
                        base.OnInspectorGUI();
                    }
                }
                else
                {
                    GUILayout.BeginVertical(headerAttribute.header, skin.window);
                    GUILayout.Label(m_Logo, skin.label, GUILayout.MaxHeight(25));
                    if (headerAttribute.openClose)
                    {
                        openCloseWindow = GUILayout.Toggle(openCloseWindow, openCloseWindow ? "Close Properties" : "Open Properties", EditorStyles.toolbarButton);
                    }

                    if (!headerAttribute.openClose || openCloseWindow)
                    {
                        if (headerAttribute.useHelpBox)
                        {
                            EditorGUILayout.HelpBox(headerAttribute.helpBoxText, MessageType.Info);
                        }

                        if (ignoreEvents != null && ignoreEvents.Length > 0)
                        {
                            var ignoreProperties = ignoreEvents.Append(ignore_vMono);
                            DrawPropertiesExcluding(serializedObject, ignoreProperties);
                            openCloseEvents = GUILayout.Toggle(openCloseEvents, (openCloseEvents ? "Close " : "Open ") + "Events ", skin.button);

                            if (openCloseEvents)
                            {
                                foreach (string propName in ignoreEvents)
                                {
                                    var prop = serializedObject.FindProperty(propName);
                                    if (prop != null)
                                    {
                                        EditorGUILayout.PropertyField(prop);
                                    }
                                }
                            }
                        }
                        else
                        {
                            var ignoreProperties = ignoreEvents.Append(ignore_vMono);
                            DrawPropertiesExcluding(serializedObject, ignoreProperties);
                        }
                    }
                    EditorGUILayout.EndVertical();
                }
            }

            if (GUI.changed)
            {
                serializedObject.ApplyModifiedProperties();
                EditorUtility.SetDirty(serializedObject.targetObject);
            }
        }
예제 #3
0
        override public void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            GUILayout.Space(3);
            EditorGUIUtils.SetGUIStyles();

            bool playMode = Application.isPlaying;

            _runtimeEditMode = _runtimeEditMode && playMode;

            GUILayout.BeginHorizontal();
            EditorGUIUtils.InspectorLogo();
            GUILayout.Label(_src.animationType.ToString() + (string.IsNullOrEmpty(_src.id) ? "" : " [" + _src.id + "]"), EditorGUIUtils.sideLogoIconBoldLabelStyle);
            // Up-down buttons
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("▲", DeGUI.styles.button.toolIco))
            {
                UnityEditorInternal.ComponentUtility.MoveComponentUp(_src);
            }
            if (GUILayout.Button("▼", DeGUI.styles.button.toolIco))
            {
                UnityEditorInternal.ComponentUtility.MoveComponentDown(_src);
            }
            GUILayout.EndHorizontal();

            if (playMode)
            {
                if (_runtimeEditMode)
                {
                }
                else
                {
                    GUILayout.Space(8);
                    GUILayout.Label("Animation Editor disabled while in play mode", EditorGUIUtils.wordWrapLabelStyle);
                    if (!_src.isActive)
                    {
                        GUILayout.Label("This animation has been toggled as inactive and won't be generated", EditorGUIUtils.wordWrapLabelStyle);
                        GUI.enabled = false;
                    }
                    if (GUILayout.Button(new GUIContent("Activate Edit Mode", "Switches to Runtime Edit Mode, where you can change animations values and restart them")))
                    {
                        _runtimeEditMode = true;
                    }
                    GUILayout.Label("NOTE: when using DOPlayNext, the sequence is determined by the DOTweenAnimation Components order in the target GameObject's Inspector", EditorGUIUtils.wordWrapLabelStyle);
                    GUILayout.Space(10);
                    if (!_runtimeEditMode)
                    {
                        return;
                    }
                }
            }

            Undo.RecordObject(_src, "DOTween Animation");

//            _src.isValid = Validate(); // Moved down

            EditorGUIUtility.labelWidth = 110;

            if (playMode)
            {
                GUILayout.Space(4);
                DeGUILayout.Toolbar("Edit Mode Commands");
                DeGUILayout.BeginVBox(DeGUI.styles.box.stickyTop);
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("TogglePause"))
                {
                    _src.tween.TogglePause();
                }
                if (GUILayout.Button("Rewind"))
                {
                    _src.tween.Rewind();
                }
                if (GUILayout.Button("Restart"))
                {
                    _src.tween.Restart();
                }
                GUILayout.EndHorizontal();
                if (GUILayout.Button("Commit changes and restart"))
                {
                    _src.tween.Rewind();
                    _src.tween.Kill();
                    if (_src.isValid)
                    {
                        _src.CreateTween();
                        _src.tween.Play();
                    }
                }
                GUILayout.Label("To apply your changes when exiting Play mode, use the Component's upper right menu and choose \"Copy Component\", then \"Paste Component Values\" after exiting Play mode", DeGUI.styles.label.wordwrap);
                DeGUILayout.EndVBox();
            }
            else
            {
                bool hasManager = _src.GetComponent <DOTweenVisualManager>() != null;
                if (!hasManager)
                {
                    if (GUILayout.Button(new GUIContent("Add Manager", "Adds a manager component which allows you to choose additional options for this gameObject")))
                    {
                        _src.gameObject.AddComponent <DOTweenVisualManager>();
                    }
                }
            }

            GUILayout.BeginHorizontal();
            DOTweenAnimationType prevAnimType = _src.animationType;

//                _src.animationType = (DOTweenAnimationType)EditorGUILayout.EnumPopup(_src.animationType, EditorGUIUtils.popupButton);
            _src.isActive      = EditorGUILayout.Toggle(new GUIContent("", "If unchecked, this animation will not be created"), _src.isActive, GUILayout.Width(16));
            GUI.enabled        = _src.isActive;
            _src.animationType = AnimationToDOTweenAnimationType(_AnimationType[EditorGUILayout.Popup(DOTweenAnimationTypeToPopupId(_src.animationType), _AnimationType)]);
            _src.autoPlay      = DeGUILayout.ToggleButton(_src.autoPlay, new GUIContent("AutoPlay", "If selected, the tween will play automatically"));
            _src.autoKill      = DeGUILayout.ToggleButton(_src.autoKill, new GUIContent("AutoKill", "If selected, the tween will be killed when it completes, and won't be reusable"));
            GUILayout.EndHorizontal();
            if (prevAnimType != _src.animationType)
            {
                // Set default optional values based on animation type
                _src.endValueTransform = null;
                _src.useTargetAsV3     = false;
                switch (_src.animationType)
                {
                case DOTweenAnimationType.Move:
                case DOTweenAnimationType.LocalMove:
                case DOTweenAnimationType.Rotate:
                case DOTweenAnimationType.LocalRotate:
                case DOTweenAnimationType.Scale:
                    _src.endValueV3    = Vector3.zero;
                    _src.endValueFloat = 0;
                    _src.optionalBool0 = _src.animationType == DOTweenAnimationType.Scale;
                    break;

                case DOTweenAnimationType.UIWidthHeight:
                    _src.endValueV3    = Vector3.zero;
                    _src.endValueFloat = 0;
                    _src.optionalBool0 = _src.animationType == DOTweenAnimationType.UIWidthHeight;
                    break;

                case DOTweenAnimationType.Color:
                case DOTweenAnimationType.Fade:
                    _isLightSrc        = _src.GetComponent <Light>() != null;
                    _src.endValueFloat = 0;
                    break;

                case DOTweenAnimationType.Text:
                    _src.optionalBool0 = true;
                    break;

                case DOTweenAnimationType.PunchPosition:
                case DOTweenAnimationType.PunchRotation:
                case DOTweenAnimationType.PunchScale:
                    _src.endValueV3     = _src.animationType == DOTweenAnimationType.PunchRotation ? new Vector3(0, 180, 0) : Vector3.one;
                    _src.optionalFloat0 = 1;
                    _src.optionalInt0   = 10;
                    _src.optionalBool0  = false;
                    break;

                case DOTweenAnimationType.ShakePosition:
                case DOTweenAnimationType.ShakeRotation:
                case DOTweenAnimationType.ShakeScale:
                    _src.endValueV3     = _src.animationType == DOTweenAnimationType.ShakeRotation ? new Vector3(90, 90, 90) : Vector3.one;
                    _src.optionalInt0   = 10;
                    _src.optionalFloat0 = 90;
                    _src.optionalBool0  = false;
                    break;

                case DOTweenAnimationType.CameraAspect:
                case DOTweenAnimationType.CameraFieldOfView:
                case DOTweenAnimationType.CameraOrthoSize:
                    _src.endValueFloat = 0;
                    break;

                case DOTweenAnimationType.CameraPixelRect:
                case DOTweenAnimationType.CameraRect:
                    _src.endValueRect = new Rect(0, 0, 0, 0);
                    break;
                }
            }
            if (_src.animationType == DOTweenAnimationType.None)
            {
                _src.isValid = false;
                if (GUI.changed)
                {
                    EditorUtility.SetDirty(_src);
                }
                return;
            }

            if (prevAnimType != _src.animationType || ComponentsChanged())
            {
                _src.isValid = Validate();
                // See if we need to choose between multiple targets
                if (_src.animationType == DOTweenAnimationType.Fade && _src.GetComponent <CanvasGroup>() != null && _src.GetComponent <Image>() != null)
                {
                    _chooseTargetMode = ChooseTargetMode.BetweenCanvasGroupAndImage;
                    // Reassign target and forcedTargetType if lost
                    if (_src.forcedTargetType == TargetType.Unset)
                    {
                        _src.forcedTargetType = _src.targetType;
                    }
                    switch (_src.forcedTargetType)
                    {
                    case TargetType.CanvasGroup:
                        _src.target = _src.GetComponent <CanvasGroup>();
                        break;

                    case TargetType.Image:
                        _src.target = _src.GetComponent <Image>();
                        break;
                    }
                }
                else
                {
                    _chooseTargetMode     = ChooseTargetMode.None;
                    _src.forcedTargetType = TargetType.Unset;
                }
            }

            if (!_src.isValid)
            {
                GUI.color = Color.red;
                GUILayout.BeginVertical(GUI.skin.box);
                GUILayout.Label("No valid Component was found for the selected animation", EditorGUIUtils.wordWrapLabelStyle);
                GUILayout.EndVertical();
                GUI.color = Color.white;
                if (GUI.changed)
                {
                    EditorUtility.SetDirty(_src);
                }
                return;
            }

            // Special cases in which multiple target types could be used (set after validation)
            if (_chooseTargetMode == ChooseTargetMode.BetweenCanvasGroupAndImage && _src.forcedTargetType != TargetType.Unset)
            {
                FadeTargetType fadeTargetType = (FadeTargetType)Enum.Parse(typeof(FadeTargetType), _src.forcedTargetType.ToString());
                TargetType     prevTargetType = _src.forcedTargetType;
                _src.forcedTargetType = (TargetType)Enum.Parse(typeof(TargetType), EditorGUILayout.EnumPopup(_src.animationType + " Target", fadeTargetType).ToString());
                if (_src.forcedTargetType != prevTargetType)
                {
                    // Target type change > assign correct target
                    switch (_src.forcedTargetType)
                    {
                    case TargetType.CanvasGroup:
                        _src.target = _src.GetComponent <CanvasGroup>();
                        break;

                    case TargetType.Image:
                        _src.target = _src.GetComponent <Image>();
                        break;
                    }
                }
            }

            GUILayout.BeginHorizontal();
            _src.duration = EditorGUILayout.FloatField("Duration", _src.duration);
            if (_src.duration < 0)
            {
                _src.duration = 0;
            }
            _src.isSpeedBased = DeGUILayout.ToggleButton(_src.isSpeedBased, new GUIContent("SpeedBased", "If selected, the duration will count as units/degree x second"), DeGUI.styles.button.tool, GUILayout.Width(75));
            GUILayout.EndHorizontal();
            _src.delay = EditorGUILayout.FloatField("Delay", _src.delay);
            if (_src.delay < 0)
            {
                _src.delay = 0;
            }
            _src.isIndependentUpdate = EditorGUILayout.Toggle("Ignore TimeScale", _src.isIndependentUpdate);
            _src.easeType            = EditorGUIUtils.FilteredEasePopup(_src.easeType);
            if (_src.easeType == Ease.INTERNAL_Custom)
            {
                _src.easeCurve = EditorGUILayout.CurveField("   Ease Curve", _src.easeCurve);
            }
            _src.loops = EditorGUILayout.IntField(new GUIContent("Loops", "Set to -1 for infinite loops"), _src.loops);
            if (_src.loops < -1)
            {
                _src.loops = -1;
            }
            if (_src.loops > 1 || _src.loops == -1)
            {
                _src.loopType = (LoopType)EditorGUILayout.EnumPopup("   Loop Type", _src.loopType);
            }
            _src.id = EditorGUILayout.TextField("ID", _src.id);

            bool canBeRelative = true;

            // End value and eventual specific options
            switch (_src.animationType)
            {
            case DOTweenAnimationType.Move:
            case DOTweenAnimationType.LocalMove:
                GUIEndValueV3(_src.animationType == DOTweenAnimationType.Move);
                _src.optionalBool0 = EditorGUILayout.Toggle("    Snapping", _src.optionalBool0);
                canBeRelative      = !_src.useTargetAsV3;
                break;

            case DOTweenAnimationType.Rotate:
            case DOTweenAnimationType.LocalRotate:
                if (_src.GetComponent <Rigidbody2D>())
                {
                    GUIEndValueFloat();
                }
                else
                {
                    GUIEndValueV3();
                    _src.optionalRotationMode = (RotateMode)EditorGUILayout.EnumPopup("    Rotation Mode", _src.optionalRotationMode);
                }
                break;

            case DOTweenAnimationType.Scale:
                if (_src.optionalBool0)
                {
                    GUIEndValueFloat();
                }
                else
                {
                    GUIEndValueV3();
                }
                _src.optionalBool0 = EditorGUILayout.Toggle("Uniform Scale", _src.optionalBool0);
                break;

            case DOTweenAnimationType.UIWidthHeight:
                if (_src.optionalBool0)
                {
                    GUIEndValueFloat();
                }
                else
                {
                    GUIEndValueV2();
                }
                _src.optionalBool0 = EditorGUILayout.Toggle("Uniform Scale", _src.optionalBool0);
                break;

            case DOTweenAnimationType.Color:
                GUIEndValueColor();
                canBeRelative = false;
                break;

            case DOTweenAnimationType.Fade:
                GUIEndValueFloat();
                if (_src.endValueFloat < 0)
                {
                    _src.endValueFloat = 0;
                }
                if (!_isLightSrc && _src.endValueFloat > 1)
                {
                    _src.endValueFloat = 1;
                }
                canBeRelative = false;
                break;

            case DOTweenAnimationType.Text:
                GUIEndValueString();
                _src.optionalBool0        = EditorGUILayout.Toggle("Rich Text Enabled", _src.optionalBool0);
                _src.optionalScrambleMode = (ScrambleMode)EditorGUILayout.EnumPopup("Scramble Mode", _src.optionalScrambleMode);
                _src.optionalString       = EditorGUILayout.TextField(new GUIContent("Custom Scramble", "Custom characters to use in case of ScrambleMode.Custom"), _src.optionalString);
                break;

            case DOTweenAnimationType.PunchPosition:
            case DOTweenAnimationType.PunchRotation:
            case DOTweenAnimationType.PunchScale:
                GUIEndValueV3();
                canBeRelative       = false;
                _src.optionalInt0   = EditorGUILayout.IntSlider(new GUIContent("    Vibrato", "How much will the punch vibrate"), _src.optionalInt0, 1, 50);
                _src.optionalFloat0 = EditorGUILayout.Slider(new GUIContent("    Elasticity", "How much the vector will go beyond the starting position when bouncing backwards"), _src.optionalFloat0, 0, 1);
                if (_src.animationType == DOTweenAnimationType.PunchPosition)
                {
                    _src.optionalBool0 = EditorGUILayout.Toggle("    Snapping", _src.optionalBool0);
                }
                break;

            case DOTweenAnimationType.ShakePosition:
            case DOTweenAnimationType.ShakeRotation:
            case DOTweenAnimationType.ShakeScale:
                GUIEndValueV3();
                canBeRelative       = false;
                _src.optionalInt0   = EditorGUILayout.IntSlider(new GUIContent("    Vibrato", "How much will the shake vibrate"), _src.optionalInt0, 1, 50);
                _src.optionalFloat0 = EditorGUILayout.Slider(new GUIContent("    Randomness", "The shake randomness"), _src.optionalFloat0, 0, 90);
                if (_src.animationType == DOTweenAnimationType.ShakePosition)
                {
                    _src.optionalBool0 = EditorGUILayout.Toggle("    Snapping", _src.optionalBool0);
                }
                break;

            case DOTweenAnimationType.CameraAspect:
            case DOTweenAnimationType.CameraFieldOfView:
            case DOTweenAnimationType.CameraOrthoSize:
                GUIEndValueFloat();
                canBeRelative = false;
                break;

            case DOTweenAnimationType.CameraBackgroundColor:
                GUIEndValueColor();
                canBeRelative = false;
                break;

            case DOTweenAnimationType.CameraPixelRect:
            case DOTweenAnimationType.CameraRect:
                GUIEndValueRect();
                canBeRelative = false;
                break;
            }

            // Final settings
            if (canBeRelative)
            {
                _src.isRelative = EditorGUILayout.Toggle("    Relative", _src.isRelative);
            }


            // Events   注释掉,不需要事件的编辑窗口
//            AnimationInspectorGUI.AnimationEvents(this, _src);

            if (GUI.changed)
            {
                EditorUtility.SetDirty(_src);
            }
        }
예제 #4
0
        public void OnGUI()
        {
            GUILayout.Space(10f);

            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            GUILayout.Label(string.Format("Version {0}", SVGImporterSettings.version), new GUILayoutOption[0]);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            GUILayout.Label(AboutWindow.s_Header, GUIStyle.none, new GUILayoutOption[0]);

            OnLastRectClick(delegate() { Application.OpenURL("http://www.svgimporter.com"); });

            this.ListenForSecretCodes();

            GUILayout.Space(4f);
            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.TextArea(kSpecialThanksNames + "\n" + kSpecialThanksNamesTesters, GUI.skin.label);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Label(AboutWindow.s_ClipperLogo, new GUILayoutOption[0]);
            OnLastRectClick(delegate() { Application.OpenURL("http://www.angusj.com/delphi/clipper.php"); });
            GUILayout.Label("Clipping powered by Clipper.\n\n(c) 2010-2014 Angus Johnson", "MiniLabel", new GUILayoutOption[]
            {
                GUILayout.Width(200f)
            });
            OnLastRectClick(delegate() { Application.OpenURL("http://www.angusj.com/delphi/clipper.php"); });

            GUILayout.Label(AboutWindow.s_SGILogo, new GUILayoutOption[0]);
            OnLastRectClick(delegate() { Application.OpenURL("https://github.com/speps/LibTessDotNet"); });
            GUILayout.Label("Tesselation powered by LibTessDotNet.\n\n(c) 2011 Silicon Graphics, Inc.", "MiniLabel", new GUILayoutOption[]
            {
                GUILayout.Width(200f)
            });
            OnLastRectClick(delegate() { Application.OpenURL("https://github.com/speps/LibTessDotNet"); });

            GUILayout.EndHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(5f);
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            GUILayout.Label("\n" + "Copyright (c) 2015 Jaroslav Stehlik", "MiniLabel", new GUILayoutOption[0]);
            GUILayout.EndVertical();
            GUILayout.Space(10f);
            GUILayout.FlexibleSpace();
            GUILayout.Space(5f);
            GUILayout.EndHorizontal();
            GUILayout.Space(5f);
        }
    void DrawSpriteList()
    {
        if (spriteCollectionProxy != null && spriteCollectionProxy.Empty)
        {
            DrawDropZone();
            return;
        }

        int spriteListControlId = GUIUtility.GetControlID("tk2d.SpriteList".GetHashCode(), FocusType.Keyboard);

        HandleListKeyboardShortcuts(spriteListControlId);

        spriteListScroll = GUILayout.BeginScrollView(spriteListScroll, GUILayout.Width(leftBarWidth));
        GUILayout.BeginVertical(tk2dEditorSkin.SC_ListBoxBG, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));

        bool multiSelectKey = (Application.platform == RuntimePlatform.OSXEditor)?Event.current.command:Event.current.control;
        bool shiftSelectKey = Event.current.shift;

        bool selectionChanged = false;

        SpriteCollectionEditorEntry.Type lastType = SpriteCollectionEditorEntry.Type.None;
        foreach (var entry in entries)
        {
            if (lastType != entry.type)
            {
                if (lastType != SpriteCollectionEditorEntry.Type.None)
                {
                    GUILayout.Space(8);
                }
                else
                {
                    GUI.SetNextControlName("firstLabel");
                }

                GUILayout.Label(GetEntryTypeString(entry.type), tk2dEditorSkin.SC_ListBoxSectionHeader, GUILayout.ExpandWidth(true));
                lastType = entry.type;
            }

            bool newSelected = GUILayout.Toggle(entry.selected, entry.name, tk2dEditorSkin.SC_ListBoxItem, GUILayout.ExpandWidth(true));
            if (newSelected != entry.selected)
            {
                GUI.FocusControl("firstLabel");

                entry.selectionKey = spriteListSelectionKey++;
                if (multiSelectKey)
                {
                    // Only allow multiselection with sprites
                    bool selectionAllowed = entry.type == SpriteCollectionEditorEntry.Type.Sprite;
                    foreach (var e in entries)
                    {
                        if (e != entry && e.selected && e.type != entry.type)
                        {
                            selectionAllowed = false;
                            break;
                        }
                    }

                    if (selectionAllowed)
                    {
                        entry.selected   = newSelected;
                        selectionChanged = true;
                    }
                    else
                    {
                        foreach (var e in entries)
                        {
                            e.selected = false;
                        }
                        entry.selected   = true;
                        selectionChanged = true;
                    }
                }
                else if (shiftSelectKey)
                {
                    // find first selected entry in list
                    int firstSelection = int.MaxValue;
                    foreach (var e in entries)
                    {
                        if (e.selected && e.listIndex < firstSelection)
                        {
                            firstSelection = e.listIndex;
                        }
                    }
                    int lastSelection = entry.listIndex;
                    if (lastSelection < firstSelection)
                    {
                        lastSelection  = firstSelection;
                        firstSelection = entry.listIndex;
                    }
                    // Filter for multiselection
                    if (entry.type == SpriteCollectionEditorEntry.Type.Sprite)
                    {
                        for (int i = firstSelection; i <= lastSelection; ++i)
                        {
                            if (entries[i].type != entry.type)
                            {
                                firstSelection = entry.listIndex;
                                lastSelection  = entry.listIndex;
                            }
                        }
                    }
                    else
                    {
                        firstSelection = lastSelection = entry.listIndex;
                    }
                    foreach (var e in entries)
                    {
                        e.selected = (e.listIndex >= firstSelection && e.listIndex <= lastSelection);
                    }
                    selectionChanged = true;
                }
                else
                {
                    foreach (var e in entries)
                    {
                        e.selected = false;
                    }
                    entry.selected   = true;
                    selectionChanged = true;
                }
            }
        }

        if (selectionChanged)
        {
            GUIUtility.keyboardControl = spriteListControlId;
            UpdateSelection();
            Repaint();
        }

        GUILayout.EndVertical();
        GUILayout.EndScrollView();

        Rect viewRect = GUILayoutUtility.GetLastRect();

        tk2dPreferences.inst.spriteCollectionListWidth = (int)tk2dGuiUtility.DragableHandle(4819283,
                                                                                            viewRect, tk2dPreferences.inst.spriteCollectionListWidth,
                                                                                            tk2dGuiUtility.DragDirection.Horizontal);
    }
예제 #6
0
        public static void DrawThemePopup(ThemesDatabase database, ThemeData themeData, string[] themeNames, int themeIndex,
                                          ColorName componentColorName, SerializedObject serializedObject, Object[] targets, ThemeTarget target, Color initialGUIColor,
                                          Action updateIds, Action updateLists)
        {
            GUILayout.BeginHorizontal();
            {
                DGUI.Line.Draw(false, componentColorName, true,
                               () =>
                {
                    GUILayout.Space(DGUI.Properties.Space(2));
                    DGUI.Label.Draw(UILabels.SelectedTheme, Size.S, componentColorName, DGUI.Properties.SingleLineHeight);
                    GUILayout.Space(DGUI.Properties.Space());
                    GUILayout.BeginVertical(GUILayout.Height(DGUI.Properties.SingleLineHeight));
                    {
                        GUILayout.Space(0);
                        GUI.color = DGUI.Colors.PropertyColor(componentColorName);
                        EditorGUI.BeginChangeCheck();
                        themeIndex = EditorGUILayout.Popup(GUIContent.none, themeIndex, themeNames);
                        GUI.color  = initialGUIColor;
                    }
                    GUILayout.EndVertical();
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (serializedObject.isEditingMultipleObjects)
                        {
                            DoozyUtils.UndoRecordObjects(targets, UILabels.UpdateValue);
                            themeData = database.Themes[themeIndex];
                            foreach (Object o in targets)
                            {
                                var themeTarget = (ThemeTarget)o;
                                if (themeTarget == null)
                                {
                                    continue;
                                }
                                themeTarget.ThemeId = themeData.Id;
                            }

                            updateIds.Invoke();
                            updateLists.Invoke();

                            foreach (Object o in targets)
                            {
                                var themeTarget = (ThemeTarget)o;
                                if (themeTarget == null)
                                {
                                    continue;
                                }

                                if (!themeData.ContainsColorProperty(themeTarget.PropertyId))
                                {
                                    themeTarget.PropertyId = themeData.ColorLabels.Count > 0
                                                                                ? themeData.ColorLabels[0].Id
                                                                                : Guid.Empty;
                                }

                                themeTarget.UpdateTarget(themeData);
                            }
                        }
                        else
                        {
                            DoozyUtils.UndoRecordObject(target, UILabels.UpdateValue);
                            themeData      = database.Themes[themeIndex];
                            target.ThemeId = themeData.Id;
                            updateIds.Invoke();
                            updateLists.Invoke();
                            target.UpdateTarget(themeData);
                        }
                    }
                });

                GUILayout.Space(DGUI.Properties.Space());

                ThemeTargetEditorUtils.DrawButtonTheme(themeData, componentColorName);
            }
            GUILayout.EndHorizontal();
        }
예제 #7
0
    void GameObjectGroupsGUI()
    {
        for (int i = 0; i < objectGroups.arraySize; i++)
        {
            SerializedProperty gameobjects = objectGroups.GetArrayElementAtIndex(i).FindPropertyRelative("GOs");
            SerializedProperty groupParent = objectGroups.GetArrayElementAtIndex(i).FindPropertyRelative("GroupParent");
            SerializedProperty foldoutBool = objectGroups.GetArrayElementAtIndex(i).FindPropertyRelative("IsOpen");
            SerializedProperty groupName   = objectGroups.GetArrayElementAtIndex(i).FindPropertyRelative("GroupName");

            GUILayout.Box(GUIContent.none, GUILayout.Height(2), GUILayout.ExpandWidth(true));

            if (groupName.stringValue == "")
            {
                groupName.stringValue = "ObjectGroup" + i;
            }
            // start foldout for object group
            if (foldoutBool.boolValue = EditorGUILayout.Foldout(foldoutBool.boolValue, groupName.stringValue, EditorStyles.foldout))
            {
                EditorGUI.indentLevel++;
                GUILayout.BeginVertical();

                // group name, remove group button
                GUILayout.BeginHorizontal();

                groupName.stringValue = EditorGUILayout.TextField("Group Name", groupName.stringValue);
                if (groupName.stringValue == "")
                {
                    groupName.stringValue = " ";
                }
                if (GUILayout.Button("Remove Object Group"))
                {
                    objectGroups.DeleteArrayElementAtIndex(i);
                    if (i == selectedObjectId.vector2Value.x)
                    {
                        selectedObjectId.vector2Value = disabledId;
                    }

                    break;
                }
                GUILayout.EndHorizontal();

                // parent transform
                EditorGUILayout.PropertyField(groupParent);
//				if(groupParent.objectReferenceValue != null)
//				{
//					Transform parentTrans = groupParent.objectReferenceValue as Transform;
//				}

                AddObjectDropZone(gameobjects);

                // draw the game objects
                GameObjectListGUI(i, gameobjects);


                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Add a game object"))
                {
                    gameobjects.InsertArrayElementAtIndex(gameobjects.arraySize);
                }
                if (GUILayout.Button("Remove all objects"))
                {
                    for (int k = gameobjects.arraySize - 1; k >= 0; k--)
                    {
                        RemoveGameObjectFromList(gameobjects, i, k);
                        groupParent.objectReferenceValue = null;
                    }
                }
                GUILayout.EndHorizontal();

                GUILayout.EndVertical();
                EditorGUI.indentLevel--;
            }
            GUILayout.Box(GUIContent.none, GUILayout.Height(2), GUILayout.ExpandWidth(true));
            //EditorGUILayout.Space ();
        }
    }
예제 #8
0
    protected virtual void UiMainWizard()
    {
        GUILayout.Space(15);

        // title
        UiTitleBox(CurrentLang.PUNWizardLabel, BackgroundImage);

        // wizard info text
        GUILayout.Label("This window should help you find important settings for PUN, as well as documentation.");
        GUILayout.Space(15);


        // pun+ info
        if (isPunPlus)
        {
            GUILayout.Label(CurrentLang.MobilePunPlusExportNoteLabel);
            GUILayout.Space(15);
        }
        else if (!InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.Android) || !InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.iOS))
        {
            GUILayout.Label(CurrentLang.MobileExportNoteLabel);
            GUILayout.Space(15);
        }


        // settings button
        GUILayout.BeginHorizontal();
        GUILayout.Label(CurrentLang.SettingsButton, EditorStyles.boldLabel, GUILayout.Width(100));
        GUILayout.BeginVertical();
        if (GUILayout.Button(new GUIContent(CurrentLang.LocateSettingsButton, CurrentLang.SettingsHighlightLabel)))
        {
            HighlightSettings();
        }
        if (GUILayout.Button(new GUIContent(CurrentLang.OpenCloudDashboardText, CurrentLang.OpenCloudDashboardTooltip)))
        {
            EditorUtility.OpenWithDefaultApp(UrlCloudDashboard + Uri.EscapeUriString(this.mailOrAppId));
        }
        if (GUILayout.Button(new GUIContent(CurrentLang.SetupButton, CurrentLang.SetupServerCloudLabel)))
        {
            this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud;
        }
        GUILayout.EndVertical();
        GUILayout.EndHorizontal();
        GUILayout.Space(15);


        // converter
        GUILayout.BeginHorizontal();
        GUILayout.Label(CurrentLang.ConverterLabel, EditorStyles.boldLabel, GUILayout.Width(100));
        if (GUILayout.Button(new GUIContent(CurrentLang.StartButton, CurrentLang.UNtoPUNLabel)))
        {
            PhotonConverter.RunConversion();
        }

        GUILayout.EndHorizontal();
        EditorGUILayout.Separator();


        // documentation
        GUILayout.BeginHorizontal();
        GUILayout.Label(CurrentLang.DocumentationLabel, EditorStyles.boldLabel, GUILayout.Width(100));
        GUILayout.BeginVertical();
        if (GUILayout.Button(new GUIContent(CurrentLang.OpenPDFText, CurrentLang.OpenPDFTooltip)))
        {
            EditorUtility.OpenWithDefaultApp(DocumentationLocation);
        }

        if (GUILayout.Button(new GUIContent(CurrentLang.OpenDevNetText, CurrentLang.OpenDevNetTooltip)))
        {
            EditorUtility.OpenWithDefaultApp(UrlDevNet);
        }

        GUI.skin.label.wordWrap = true;
        GUILayout.Label(CurrentLang.OwnHostCloudCompareLabel);
        if (GUILayout.Button(CurrentLang.ComparisonPageButton))
        {
            Application.OpenURL(UrlCompare);
        }


        if (GUILayout.Button(new GUIContent(CurrentLang.OpenForumText, CurrentLang.OpenForumTooltip)))
        {
            EditorUtility.OpenWithDefaultApp(UrlForum);
        }

        GUILayout.EndVertical();
        GUILayout.EndHorizontal();
    }
    void DrawNewGUI()
    {
        #region Preparations for unity versions and skin

        c  = Color.Lerp(GUI.color * new Color(0.8f, 0.8f, 0.8f, 0.7f), GUI.color, Mathf.InverseLerp(0f, 0.15f, Get.SpineAnimatorAmount));
        bc = GUI.backgroundColor;

        RectOffset zeroOff = new RectOffset(0, 0, 0, 0);
        float      bgAlpha = 0.05f; if (EditorGUIUtility.isProSkin)
        {
            bgAlpha = 0.1f;
        }

#if UNITY_2019_3_OR_NEWER
        int headerHeight = 22;
#else
        int headerHeight = 25;
#endif

        if (Get.SpineBones == null)
        {
            Get.SpineBones = new System.Collections.Generic.List <FIMSpace.FSpine.FSpineAnimator.SpineBone>();
        }

        #endregion

        GUILayout.BeginVertical(FGUI_Resources.BGBoxStyle); GUILayout.Space(1f);


        // ------------------------------------------------------------------------

        // If spine setup is not finished, then not drawing rest of the inspector
        if (Get.SpineBones.Count <= 1)
        {
            Get._Editor_Category = FIMSpace.FSpine.FSpineAnimator.EFSpineEditorCategory.Setup;
            GUILayout.BeginVertical(FGUI_Inspector.Style(zeroOff, zeroOff, new Color(.7f, .7f, 0.7f, bgAlpha), Vector4.one * 3, 3));

            EditorGUILayout.BeginHorizontal(FGUI_Resources.HeaderBoxStyle);

            GUILayout.Label(new GUIContent(" "), GUILayout.Width(1));
            if (GUILayout.Button(new GUIContent(FGUI_Resources.Tex_GearSetup), EditorStyles.label, new GUILayoutOption[2] {
                GUILayout.Width(headerHeight), GUILayout.Height(headerHeight)
            }))
            {
            }
            if (GUILayout.Button(Lang("Prepare Spine Chain"), LangBig() ? FGUI_Resources.HeaderStyleBig : FGUI_Resources.HeaderStyle, GUILayout.Height(headerHeight)))
            {
            }
            if (GUILayout.Button(new GUIContent(FGUI_Resources.Tex_Repair), EditorStyles.label, new GUILayoutOption[2] {
                GUILayout.Width(headerHeight), GUILayout.Height(headerHeight)
            }))
            {
            }
            GUILayout.Label(new GUIContent(" "), GUILayout.Width(1));

            EditorGUILayout.EndHorizontal();

            Tab_DrawPreSetup();

            GUILayout.EndVertical();
            GUILayout.EndVertical();
            return;
        }


        GUILayout.Space(2);
        EditorGUILayout.BeginHorizontal();
        DrawCategoryButton(FIMSpace.FSpine.FSpineAnimator.EFSpineEditorCategory.Setup, FGUI_Resources.Tex_GearSetup, "Setup");
        DrawCategoryButton(FIMSpace.FSpine.FSpineAnimator.EFSpineEditorCategory.Tweak, FGUI_Resources.Tex_Sliders, "Tweak");
        DrawCategoryButton(FIMSpace.FSpine.FSpineAnimator.EFSpineEditorCategory.Adjust, FGUI_Resources.Tex_Repair, "Adjust");
        DrawCategoryButton(FIMSpace.FSpine.FSpineAnimator.EFSpineEditorCategory.Physical, FGUI_Resources.Tex_Collider, "Physical");
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(4);


        switch (Get._Editor_Category)
        {
        case FIMSpace.FSpine.FSpineAnimator.EFSpineEditorCategory.Setup:

            GUILayout.BeginVertical(FGUI_Inspector.Style(zeroOff, zeroOff, new Color(.7f, .7f, 0.7f, bgAlpha), Vector4.one * 3, 3));

            FGUI_Inspector.HeaderBox(Lang("Character Setup"), true, FGUI_Resources.Tex_GearSetup, headerHeight, headerHeight - 1, LangBig());
            Tab_DrawSetup();

            GUILayout.EndVertical();
            break;

        case FIMSpace.FSpine.FSpineAnimator.EFSpineEditorCategory.Tweak:
            GUILayout.BeginVertical(FGUI_Inspector.Style(zeroOff, zeroOff, new Color(.3f, .4f, 1f, bgAlpha), Vector4.one * 3, 3));
            FGUI_Inspector.HeaderBox(Lang("Tweak Animation"), true, FGUI_Resources.Tex_Sliders, headerHeight, headerHeight - 1, LangBig());

            Tab_DrawTweaking();

            GUILayout.EndVertical();
            break;

        case FIMSpace.FSpine.FSpineAnimator.EFSpineEditorCategory.Adjust:
            GUILayout.BeginVertical(FGUI_Inspector.Style(zeroOff, zeroOff, new Color(.825f, .825f, 0.225f, bgAlpha * 0.8f), Vector4.one * 3, 3));
            FGUI_Inspector.HeaderBox(Lang("Adjustements"), true, FGUI_Resources.Tex_Repair, headerHeight, headerHeight - 1, LangBig());

            Tab_DrawCorrections();

            GUILayout.EndVertical();
            break;

        case FIMSpace.FSpine.FSpineAnimator.EFSpineEditorCategory.Physical:
            GUILayout.BeginVertical(FGUI_Inspector.Style(zeroOff, zeroOff, new Color(.4f, 1f, .7f, bgAlpha), Vector4.one * 3, 3));
            FGUI_Inspector.HeaderBox(Lang("Physical Parameters"), true, FGUI_Resources.Tex_Physics, headerHeight, headerHeight - 1, LangBig());
            Tab_DrawPhysics();

            GUILayout.EndVertical();
            break;
        }


        GUILayout.EndVertical();
    }
예제 #10
0
        private void DrawNodes()
        {
            Event e = Event.current;

            if (e.type == EventType.Layout)
            {
                selectionCache = new List <UnityEngine.Object>(Selection.objects);
            }

            System.Reflection.MethodInfo onValidate = null;
            if (Selection.activeObject != null && Selection.activeObject is XNode.Node)
            {
                onValidate = Selection.activeObject.GetType().GetMethod("OnValidate");
                if (onValidate != null)
                {
                    EditorGUI.BeginChangeCheck();
                }
            }

            BeginZoomed(position, zoom, topPadding);

            Vector2 mousePos = Event.current.mousePosition;

            if (e.type != EventType.Layout)
            {
                hoveredNode = null;
                hoveredPort = null;
            }

            List <UnityEngine.Object> preSelection = preBoxSelection != null ? new List <UnityEngine.Object>(preBoxSelection) : new List <UnityEngine.Object>();

            // Selection box stuff
            Vector2 boxStartPos = GridToWindowPositionNoClipped(dragBoxStart);
            Vector2 boxSize     = mousePos - boxStartPos;

            if (boxSize.x < 0)
            {
                boxStartPos.x += boxSize.x; boxSize.x = Mathf.Abs(boxSize.x);
            }
            if (boxSize.y < 0)
            {
                boxStartPos.y += boxSize.y; boxSize.y = Mathf.Abs(boxSize.y);
            }
            Rect selectionBox = new Rect(boxStartPos, boxSize);

            //Save guiColor so we can revert it
            Color guiColor = GUI.color;

            List <XNode.NodePort> removeEntries = new List <XNode.NodePort>();

            if (e.type == EventType.Layout)
            {
                culledNodes = new List <XNode.Node>();
            }
            for (int n = 0; n < graph.nodes.Count; n++)
            {
                // Skip null nodes. The user could be in the process of renaming scripts, so removing them at this point is not advisable.
                if (graph.nodes[n] == null)
                {
                    continue;
                }
                if (n >= graph.nodes.Count)
                {
                    return;
                }
                XNode.Node node = graph.nodes[n];

                // Culling
                if (e.type == EventType.Layout)
                {
                    // Cull unselected nodes outside view
                    if (!Selection.Contains(node) && ShouldBeCulled(node))
                    {
                        culledNodes.Add(node);
                        continue;
                    }
                }
                else if (culledNodes.Contains(node))
                {
                    continue;
                }

                if (e.type == EventType.Repaint)
                {
                    removeEntries.Clear();
                    foreach (var kvp in _portConnectionPoints)
                    {
                        if (kvp.Key.node == node)
                        {
                            removeEntries.Add(kvp.Key);
                        }
                    }
                    foreach (var k in removeEntries)
                    {
                        _portConnectionPoints.Remove(k);
                    }
                }

                NodeEditor nodeEditor = NodeEditor.GetEditor(node, this);

                NodeEditor.portPositions.Clear();

                // Set default label width. This is potentially overridden in OnBodyGUI
                EditorGUIUtility.labelWidth = nodeEditor.GetLabelWidth();

                //Get node position
                Vector2 nodePos = GridToWindowPositionNoClipped(node.position);

                GUILayout.BeginArea(new Rect(nodePos, new Vector2(nodeEditor.GetWidth(), 4000)));

                bool selected = selectionCache.Contains(graph.nodes[n]);

                if (selected)
                {
                    GUIStyle style          = new GUIStyle(nodeEditor.GetBodyStyle());
                    GUIStyle highlightStyle = new GUIStyle(nodeEditor.GetBodyHighlightStyle());
                    highlightStyle.padding = style.padding;
                    style.padding          = new RectOffset();
                    GUI.color = nodeEditor.GetTint();
                    GUILayout.BeginVertical(style);
                    GUI.color = NodeEditorPreferences.GetSettings().highlightColor;
                    GUILayout.BeginVertical(new GUIStyle(highlightStyle));
                }
                else
                {
                    GUIStyle style = new GUIStyle(nodeEditor.GetBodyStyle());
                    GUI.color = nodeEditor.GetTint();
                    GUILayout.BeginVertical(style);
                }

                GUI.color = guiColor;
                EditorGUI.BeginChangeCheck();

                //Draw node contents
                nodeEditor.OnHeaderGUI();
                nodeEditor.OnBodyGUI();

                //If user changed a value, notify other scripts through onUpdateNode
                if (EditorGUI.EndChangeCheck())
                {
                    if (NodeEditor.onUpdateNode != null)
                    {
                        NodeEditor.onUpdateNode(node);
                    }
                    EditorUtility.SetDirty(node);
                    nodeEditor.serializedObject.ApplyModifiedProperties();
                }

                GUILayout.EndVertical();

                //Cache data about the node for next frame
                if (e.type == EventType.Repaint)
                {
                    Vector2 size = GUILayoutUtility.GetLastRect().size;
                    if (nodeSizes.ContainsKey(node))
                    {
                        nodeSizes[node] = size;
                    }
                    else
                    {
                        nodeSizes.Add(node, size);
                    }

                    foreach (var kvp in NodeEditor.portPositions)
                    {
                        Vector2 portHandlePos = kvp.Value;
                        portHandlePos += node.position;
                        Rect rect = new Rect(portHandlePos.x - 8, portHandlePos.y - 8, 16, 16);
                        portConnectionPoints[kvp.Key] = rect;
                    }
                }

                if (selected)
                {
                    GUILayout.EndVertical();
                }

                if (e.type != EventType.Layout)
                {
                    //Check if we are hovering this node
                    Vector2 nodeSize   = GUILayoutUtility.GetLastRect().size;
                    Rect    windowRect = new Rect(nodePos, nodeSize);
                    if (windowRect.Contains(mousePos))
                    {
                        hoveredNode = node;
                    }

                    //If dragging a selection box, add nodes inside to selection
                    if (currentActivity == NodeActivity.DragGrid)
                    {
                        if (windowRect.Overlaps(selectionBox))
                        {
                            preSelection.Add(node);
                        }
                    }

                    //Check if we are hovering any of this nodes ports
                    //Check input ports
                    foreach (XNode.NodePort input in node.Inputs)
                    {
                        //Check if port rect is available
                        if (!portConnectionPoints.ContainsKey(input))
                        {
                            continue;
                        }
                        Rect r = GridToWindowRectNoClipped(portConnectionPoints[input]);
                        if (r.Contains(mousePos))
                        {
                            hoveredPort = input;
                        }
                    }
                    //Check all output ports
                    foreach (XNode.NodePort output in node.Outputs)
                    {
                        //Check if port rect is available
                        if (!portConnectionPoints.ContainsKey(output))
                        {
                            continue;
                        }
                        Rect r = GridToWindowRectNoClipped(portConnectionPoints[output]);
                        if (r.Contains(mousePos))
                        {
                            hoveredPort = output;
                        }
                    }
                }

                GUILayout.EndArea();
            }

            if (e.type != EventType.Layout && currentActivity == NodeActivity.DragGrid)
            {
                Selection.objects = preSelection.ToArray();
            }
            EndZoomed(position, zoom, topPadding);

            //If a change in is detected in the selected node, call OnValidate method.
            //This is done through reflection because OnValidate is only relevant in editor,
            //and thus, the code should not be included in build.
            if (onValidate != null && EditorGUI.EndChangeCheck())
            {
                onValidate.Invoke(Selection.activeObject, null);
            }
        }
예제 #11
0
    void OnGUI()
    {
        float BOX_WIDTH  = Screen.width - SPACE_LEFT * 2;
        float BOX_HEIGHT = Screen.height - SPACE_TOP * 2;

        float BUTTON_HEIGHT = (BOX_WIDTH - 200f) / 24f;

        Rect rect = new Rect(SPACE_LEFT, SPACE_TOP, BOX_WIDTH, BOX_HEIGHT);

        GUI.DrawTexture(rect, background);
        GUI.Box(rect, "");
        {
            GUILayout.BeginArea(rect, "");
            {
                #region LINE 1
                GUILayout.BeginHorizontal(GUILayout.Height(BOX_HEIGHT / 3));
                {
                    GUILayout.FlexibleSpace();
                    foreach (PlayerControllerPhom p in GameModelPhom.ListPlayer)
                    {
                        GUILayout.BeginVertical();
                        {
                            GUILayout.BeginHorizontal();
                            {
                                float contentWidth = BOX_WIDTH - 100f;
                                GUILayout.Space(30f);
                                GUILayout.Label(p.username, GUILayout.Width(100f));
                                GUILayout.TextField(playerPick[p.slotServer] == null ? "" : playerPick[p.slotServer], GUILayout.Width(contentWidth - 150f - (BUTTON_HEIGHT * 2)));

                                if (GUILayout.Button("CLEAR", new GUILayoutOption[] { GUILayout.Width(BUTTON_HEIGHT * 2) }))
                                {
                                    playerPick[p.slotServer] = "";
                                }
                            }
                            GUILayout.EndHorizontal();
                        }
                        GUILayout.BeginVertical();
                    }
                }
                GUILayout.EndHorizontal();
                #endregion

                GUILayout.FlexibleSpace();

                #region LINE 2
                GUILayout.BeginHorizontal(GUILayout.Height(BOX_HEIGHT / 3));
                {
                    float contentWidth = BOX_WIDTH - 20f;
                    GUILayout.BeginVertical(GUILayout.Width(contentWidth / 4));
                    {
                        #region
                        if (GameModelPhom.CurrentState > GameModelPhom.EGameState.deal && GameManager.Instance.mInfo.role >= User.ERole.Tester)
                        {
                            //GUILayout.FlexibleSpace();
                            //GUILayout.BeginHorizontal(GUILayout.Width(BOX_WIDTH - 200f));
                            GUILayout.Space(BUTTON_HEIGHT * 2);
                            if (GUILayout.Button("YÊU CẦU ĐÁNH BÀI", new GUILayoutOption[] { GUILayout.Width(BUTTON_HEIGHT * 4), GUILayout.Height(BUTTON_HEIGHT) }))
                            {
                                OnClickRequestHandRobot();
                            }
                            if (GUILayout.Button("YÊU CẦU BỐC BÀI", new GUILayoutOption[] { GUILayout.Width(BUTTON_HEIGHT * 4), GUILayout.Height(BUTTON_HEIGHT) }))
                            {
                                IS_TYPE_FORCE_ROBOT = false;
                            }
                            //GUILayout.EndHorizontal();
                        }
                        else
                        {
                            GUILayout.Label(" ", GUILayout.Height(BUTTON_HEIGHT));
                        }
                        #endregion
                    }
                    GUILayout.EndVertical();

                    GUILayout.BeginVertical(GUILayout.Width(contentWidth / 3));
                    {
                        string[] lst = strPick.Split(" ".ToCharArray(), StringSplitOptions.None);
                        GUILayout.Label("BẠN ĐANG CHỌN: " + (lst.Length - 1) + " PhomCard.", GUILayout.Width(contentWidth / 3));
                        GUILayout.TextField(strPick);
                        if (GUILayout.Button("CLEAR", GUILayout.Height(BUTTON_HEIGHT)))
                        {
                            strPick = "";
                        }

                        foreach (PlayerControllerPhom p in GameModelPhom.ListPlayer)
                        {
                            if (GUILayout.Button("SET TO " + p.username, GUILayout.Height(BUTTON_HEIGHT)))
                            {
                                playerPick[p.slotServer] = strPick;
                                strPick = "";
                                lastPicks.Clear();
                            }
                        }
                    }
                    GUILayout.EndVertical();

                    GUILayout.BeginVertical(GUILayout.Width(contentWidth / 3));
                    {
                        GUILayout.Label(" ");

                        if (GUILayout.Button("ĐÃ XONG", new GUILayoutOption[] { GUILayout.Width(contentWidth / 3 / 2), GUILayout.Height(contentWidth / 3 / 2) }))
                        {
                            OnClickDone();
                            lastPicks.Clear();
                        }
                    }
                    GUILayout.EndVertical();
                }
                GUILayout.EndHorizontal();
                #endregion

                GUILayout.FlexibleSpace();

                #region LINE 3
                GUILayout.BeginHorizontal(GUILayout.Height(BOX_HEIGHT / 3));
                {
                    int index = 0;
                    for (int i = 0; i < 13; i++)
                    {
                        GUILayout.BeginVertical();
                        for (int j = 0; j < 4; j++)
                        {
                            string str = GameModelPhom.game.cardController.Deck.PeekCard(index).ToString();

                            if (strPick.IndexOf(str) >= 0)
                            {
                                str = "";
                            }

                            if (IS_TYPE_FORCE_ROBOT == false)
                            {
                                if (cardPlaying.Find(c => c.CardId == index) != null)
                                {
                                    str = "";
                                }
                            }
                            else
                            {
                                if (GameModelPhom.CurrentState >= GameModelPhom.EGameState.deal && GameModelPhom.GetNextPlayer(GameModelPhom.IndexInTurn).mCardHand.Find(c => c.CardId == index) == null)
                                {
                                    str = "";
                                }
                            }

                            if (Array.TrueForAll <string>(playerPick, p => p == null || (p != null && p.IndexOf(str) == -1)))
                            {
                                if (GUILayout.Button(str, new GUILayoutOption[] { GUILayout.Width(BUTTON_HEIGHT * 2), GUILayout.Height(BUTTON_HEIGHT) }))
                                {
                                    if (string.IsNullOrEmpty(str) == false &&

                                        ((GameModelPhom.CurrentState >= GameModelPhom.EGameState.deal)
                                        ?
                                         GameManager.GAME == EGame.Phom ?
                                         strPick.Split(" ".ToCharArray(), StringSplitOptions.None).Length <= 1
                                        :
                                         strPick.Split(" ".ToCharArray(), StringSplitOptions.None).Length <= MAX_CARD_ON_HAND
                                        :
                                         strPick.Split(" ".ToCharArray(), StringSplitOptions.None).Length <= MAX_CARD_ON_HAND)
                                        )
                                    {
                                        if (!lastPicks.Contains(index))
                                        {
                                            lastPicks.Add(index);
                                        }

                                        lastPick = index;
                                        strPick += str + " ";
                                    }
                                }
                            }
                            else
                            {
                                GUILayout.Button("", new GUILayoutOption[] { GUILayout.Width(BUTTON_HEIGHT * 2), GUILayout.Height(BUTTON_HEIGHT) });
                            }
                            index++;
                        }
                        GUILayout.EndVertical();
                    }
                }
                GUILayout.EndHorizontal();
                #endregion
            }
            GUILayout.EndArea();
        }
    }
        void WindowGUI(int windowID)
        {
            ELStyles.Init();

            SelectPad_start();

            GUILayout.BeginVertical();
            VesselName();
            SelectPad();

            switch (control.state)
            {
            case ELBuildControl.State.Idle:
                SelectCraft();
                break;

            case ELBuildControl.State.Planning:
                SelectCraft();
                SelectedCraft();
                if (control.lockedParts)
                {
                    LockedParts();
                }
                else
                {
                    resScroll.Begin();
                    RequiredResources();
                    CraftBoM();
                    resScroll.End();
                    BuildButton();
                }
                break;

            case ELBuildControl.State.Building:
                SelectedCraft();
                resScroll.Begin();
                BuildProgress(true);
                resScroll.End();
                PauseButton();
                break;

            case ELBuildControl.State.Canceling:
                SelectedCraft();
                resScroll.Begin();
                BuildProgress(false);
                resScroll.End();
                PauseButton();
                break;

            case ELBuildControl.State.Complete:
                SelectedCraft();
                FinalizeButton();
                break;

            case ELBuildControl.State.Transfer:
                SelectedCraft();
                resScroll.Begin();
                OptionalResources();
                resScroll.End();
                ReleaseButton();
                break;
            }

            GUILayout.EndVertical();

            CloseButton();

            SelectPad_end();

            GUI.DragWindow(new Rect(0, 0, 10000, 20));
        }
예제 #13
0
    public override void OnInspectorGUI()
    {
        SMBuilder maker = target as SMBuilder;

        EditorGUIUtility.labelWidth = 100f;
        GUI.changed = false;

        GUILayout.Space(5f);

        GUILayout.BeginVertical("Matcap Maker", "Window", GUILayout.MinHeight(200f));

        GUILayout.Label(maker.sphereMap, "Button", GUILayout.MinHeight(200f), GUILayout.ExpandWidth(true));

        /*
         * Rect r = EditorGUILayout.BeginHorizontal();
         * GUILayout.BeginVertical();
         * EditorGUI.ProgressBar(r, 1f, "Rendering...");
         * GUILayout.Space(20f);
         * GUILayout.EndVertical();
         * EditorGUILayout.EndHorizontal();
         */

        {
            GUILayout.Space(5f);

            maker.aaQuality = (int)EditorGUILayout.IntSlider("Samples", maker.aaQuality, 1, 5);
            showTools       = EditorGUILayout.Toggle("Show properties", showTools);
        }

        if (showTools)
        {
            // Surface
            {
                GUILayout.Space(10f);
                GUILayout.BeginVertical("Surface", "Window");
                EditorGUI.indentLevel++;

                // Diffuse
                {
                    if (GUILayout.Button("Diffuse", "Foldout"))
                    {
                        diffuseFoldout = !diffuseFoldout;
                    }

                    if (diffuseFoldout)
                    {
                        EditorGUI.indentLevel++;
                        maker.diffuseColor     = EditorGUILayout.ColorField("Diffuse", maker.diffuseColor);
                        maker.diffuseWeight    = EditorGUILayout.Slider("Weight", maker.diffuseWeight, 0f, 1f);
                        maker.diffuseRoughness = EditorGUILayout.Slider("Roughness", maker.diffuseRoughness, 0f, 1f);
                        maker.diffuseFresnel   = EditorGUILayout.Toggle("Fresnel", maker.diffuseFresnel);

                        if (maker.diffuseFresnel)
                        {
                            EditorGUI.indentLevel++;

                            maker.diffuseFresnelWeight = EditorGUILayout.Slider("Weight", maker.diffuseFresnelWeight, 0f, 1f);
                            maker.diffuseFresnelCurve  = EditorGUILayout.CurveField("Curve", maker.diffuseFresnelCurve, GUILayout.MinHeight(50f));
                            EditorGUI.indentLevel--;
                        }

                        EditorGUI.indentLevel--;
                    }
                }

                // Specular
                {
                    if (GUILayout.Button("Specular", "Foldout"))
                    {
                        specularFoldout = !specularFoldout;
                    }

                    if (specularFoldout)
                    {
                        EditorGUI.indentLevel++;
                        maker.specularColor     = EditorGUILayout.ColorField("Specular", maker.specularColor);
                        maker.specularWeight    = EditorGUILayout.Slider("Weight", maker.specularWeight, 0f, 1f);
                        maker.specularRoughness = EditorGUILayout.Slider("Roughness", maker.specularRoughness, 0f, 1f);
                        maker.specularFresnel   = EditorGUILayout.Toggle("Fresnel", maker.specularFresnel);

                        if (maker.specularFresnel)
                        {
                            EditorGUI.indentLevel++;
                            maker.specularFresnelWeight = EditorGUILayout.Slider("Weight", maker.specularFresnelWeight, 0f, 1f);
                            maker.specularFresnelCurve  = EditorGUILayout.CurveField("Curve", maker.specularFresnelCurve, GUILayout.MinHeight(50f));
                            EditorGUI.indentLevel--;
                        }

                        EditorGUI.indentLevel--;
                    }
                }

                // Emissive
                {
                    if (GUILayout.Button("Emissive", "Foldout"))
                    {
                        emissiveFoldout = !emissiveFoldout;
                    }

                    if (emissiveFoldout)
                    {
                        EditorGUI.indentLevel++;
                        maker.emissiveColor   = EditorGUILayout.ColorField("Emissive", maker.emissiveColor);
                        maker.emissiveWeight  = EditorGUILayout.Slider("Weight", maker.emissiveWeight, 0f, 1f);
                        maker.emissiveFresnel = EditorGUILayout.Toggle("Fresnel", maker.emissiveFresnel);

                        if (maker.emissiveFresnel)
                        {
                            EditorGUI.indentLevel++;
                            maker.emissiveFresnelWeight = EditorGUILayout.Slider("Weight", maker.emissiveFresnelWeight, 0f, 1f);
                            maker.emissiveFresnelCurve  = EditorGUILayout.CurveField("Curve", maker.emissiveFresnelCurve, GUILayout.MinHeight(50f));
                            EditorGUI.indentLevel--;
                        }

                        EditorGUI.indentLevel--;
                    }
                }

                EditorGUI.indentLevel--;
                GUILayout.EndVertical();
            }

            // Lights
            {
                GUILayout.Space(20f);
                GUILayout.BeginVertical("Lights", "Window");

                GUILayout.BeginHorizontal();

                if (GUILayout.Button("+", GUILayout.MaxWidth(25f), GUILayout.MinHeight(15f)))
                {
                    SMLight l = null;

                    switch (lightType)
                    {
                    case LightType.Point:
                        l = maker.gameObject.AddComponent <SMLight>();
                        break;

                    case LightType.Directional:
                        l = maker.gameObject.AddComponent <SMDirLight>();
                        break;

                    case LightType.Sphere:
                        l = maker.gameObject.AddComponent <SMSphereLight>();
                        break;
                    }

                    l.theta = Random.value * Mathf.PI * 2f;
                    l.phi   = Random.value * Mathf.PI;

                    EditorUtility.SetDirty(target);
                }

                lightType = (LightType)EditorGUILayout.EnumPopup(lightType);

                GUILayout.EndHorizontal();

                if (GUILayout.Button("Remove all lights"))
                {
                    SMLight[] lights = maker.GetComponents <SMLight>();

                    foreach (SMLight l in lights)
                    {
                        GameObject.DestroyImmediate(l);
                    }
                }

                GUILayout.EndVertical();
            }
        }


        if (GUI.changed)
        {
            maker.BuildPreviewTexture();
            //Undo.RecordObject(target, "Matcap");
        }


        GUILayout.Space(5f);

        if (GUILayout.Button("Build"))
        {
            maker.BuildTexture();
        }

        if (GUILayout.Button("Save"))
        {
            Texture2D t     = maker.GetTexture();
            byte[]    bytes = t.EncodeToPNG();

            if (!System.IO.Directory.Exists(Application.dataPath + "/SphereMaps"))
            {
                System.IO.Directory.CreateDirectory(Application.dataPath + "/SphereMaps");
            }

            if (bytes != null)
            {
                System.IO.File.WriteAllBytes(Application.dataPath + "/SphereMaps/" + maker.name + ".png", bytes);
            }

            AssetDatabase.Refresh();
        }

        if (GUILayout.Button("Debug"))
        {
            //EditorGUI.ProgressBar()
            //EditorUtility.ClearProgressBar();
            //   EditorUtility.DisplayCancelableProgressBar("Waiting", "Rendering...", .5f);
        }

        GUILayout.EndVertical();


        // Dirty (heh) trick to get an update interval!
        EditorUtility.SetDirty(target);
    }
예제 #14
0
//	//场景发生变更时清空数据
//	void OnHierarchyChange(){
//		if(!Application.isPlaying)
//			_resultList.Clear();
//	}

    public void OnGUI()
    {
        GUILayout.Label("Enter shader to find:");

        EditorGUILayout.BeginHorizontal();
        _shaderName    = EditorGUILayout.TextField(_shaderName, GUILayout.Width(200f));
        _wholeWordOnly = EditorGUILayout.Toggle("WholeWordOnly", _wholeWordOnly);
        EditorGUILayout.EndHorizontal();

        GUILayout.Space(20f);

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("FindInScene", GUILayout.Height(50f)))
        {
            FindShaderInScene(_shaderName);
        }
        if (GUILayout.Button("FindInFolder", GUILayout.Height(50f)))
        {
            FindShaderInFolder(_shaderName);
        }
        if (GUILayout.Button("FindErrorInFolder", GUILayout.Height(50f)))
        {
            FindErrorShaderInFolder();
        }
        if (GUILayout.Button("FindInSelecttion", GUILayout.Height(50f)))
        {
            FindShaderInSelection(_shaderName);
        }
        if (GUILayout.Button("FindErrorInSelecttion", GUILayout.Height(50f)))
        {
            FindErrorShaderInSelection();
        }

        GUILayout.Space(5f);
        if (GUILayout.Button("SelectAll", GUILayout.Height(50f)))
        {
            if (_resultList != null && _resultList.Count > 0)
            {
                Selection.objects = _resultList.ToArray();
            }
        }
        GUILayout.EndHorizontal();

        EditorHelper.DrawHeader(string.Format("Result: {0}", _resultList.Count));
        GUILayout.BeginHorizontal();
        GUILayout.Space(3f);
        GUILayout.BeginVertical();
        if (_resultList != null && _resultList.Count > 0)
        {
            _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos);
            for (int i = 0; i < _resultList.Count; ++i)
            {
                Object target = _resultList [i];
                if (target != null)
                {
                    GUILayout.Space(-1f);
                    GUI.backgroundColor = Selection.activeObject == target ? Color.white : new Color(0.8f, 0.8f, 0.8f);

                    GUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(20f));

                    GUI.backgroundColor = Color.white;
                    GUILayout.Label(i.ToString(), GUILayout.Width(40f));

                    if (GUILayout.Button(target.name, "OL TextField", GUILayout.Height(20f)))
                    {
                        Selection.activeObject = target;
                    }
                    GUILayout.EndHorizontal();
                }
            }
            EditorGUILayout.EndScrollView();
        }
        else
        {
            GUILayout.Box(string.Format("Unable to find <{0}>", _shaderName));
        }
        GUILayout.EndVertical();
        GUILayout.Space(3f);
        GUILayout.EndHorizontal();
    }
예제 #15
0
    void OnGUI()
    {
        GUILayout.BeginVertical("box");
        for (int i = 0; i < GUIContents.Length; i++)
        {
            if (GUILayout.Button(GUIContents[i]))
            {
                currentState = GUIContents[i].text;
            }

            AnimatorStateInfo stateInfo = animator[0].GetCurrentAnimatorStateInfo(0);

            if (!stateInfo.IsName("Base Layer.idle2"))
            {
                for (int j = 0; j < animator.Length; j++)
                {
                    animator[j].SetBool("idle2ToIdle0", false);
                    animator[j].SetBool("idle2ToIdle1", false);
                    animator[j].SetBool("idle2ToWalk", false);
                    animator[j].SetBool("idle2ToRun", false);
                    animator[j].SetBool("idle2ToWound", false);
                    animator[j].SetBool("idle2ToSkill1", false);
                    animator[j].SetBool("idle2ToSkill0", false);
                    animator[j].SetBool("idle2ToAttack1", false);
                    animator[j].SetBool("idle2ToAttack0", false);
                    animator[j].SetBool("idle2ToDeath", false);
                }
            }
            else
            {
                for (int j = 0; j < animator.Length; j++)
                {
                    animator[j].SetBool("walkToIdle2", false);
                    animator[j].SetBool("runToIdle2", false);
                    animator[j].SetBool("deathToIdle2", false);
                }
            }

            if (currentState != "")
            {
                if (stateInfo.IsName("Base Layer.walk") && currentState != "walk")
                {
                    for (int j = 0; j < animator.Length; j++)
                    {
                        animator[j].SetBool("walkToIdle2", true);
                    }
                }

                if (stateInfo.IsName("Base Layer.run") && currentState != "run")
                {
                    for (int j = 0; j < animator.Length; j++)
                    {
                        animator[j].SetBool("runToIdle2", true);
                    }
                }

                if (stateInfo.IsName("Base Layer.death") && currentState != "death")
                {
                    for (int j = 0; j < animator.Length; j++)
                    {
                        animator[j].SetBool("deathToIdle2", true);
                    }
                }

                switch (currentState)
                {
                case "idle0":
                    for (int j = 0; j < animator.Length; j++)
                    {
                        animator[j].SetBool("idle2ToIdle0", true);
                    }
                    break;

                case "idle1":
                    for (int j = 0; j < animator.Length; j++)
                    {
                        animator[j].SetBool("idle2ToIdle1", true);
                    }
                    break;

                case "idle2":

                    break;

                case "walk":
                    for (int j = 0; j < animator.Length; j++)
                    {
                        animator[j].SetBool("idle2ToWalk", true);
                    }
                    break;

                case "run":
                    for (int j = 0; j < animator.Length; j++)
                    {
                        animator[j].SetBool("idle2ToRun", true);
                    }
                    break;

                case "attack0":
                    for (int j = 0; j < animator.Length; j++)
                    {
                        animator[j].SetBool("idle2ToAttack0", true);
                    }
                    break;

                case "attack1":
                    for (int j = 0; j < animator.Length; j++)
                    {
                        animator[j].SetBool("idle2ToAttack1", true);
                    }
                    break;

                case "skill0":
                    for (int j = 0; j < animator.Length; j++)
                    {
                        animator[j].SetBool("idle2ToSkill0", true);
                    }
                    break;

                case "skill1":
                    for (int j = 0; j < animator.Length; j++)
                    {
                        animator[j].SetBool("idle2ToSkill1", true);
                    }
                    break;

                case "wound":
                    for (int j = 0; j < animator.Length; j++)
                    {
                        animator[j].SetBool("idle2ToWound", true);
                    }
                    break;

                case "death":
                    for (int j = 0; j < animator.Length; j++)
                    {
                        animator[j].SetBool("idle2ToDeath", true);
                    }
                    break;

                default:
                    break;
                }
                currentState = "";
            }
        }
        GUILayout.EndVertical();
    }
예제 #16
0
        public void OnGUI(Rect pos)
        {
            m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition);
            bool newState      = false;
            var  centeredStyle = GUI.skin.GetStyle("Label");

            centeredStyle.alignment = TextAnchor.UpperCenter;
            GUILayout.Label(new GUIContent("Example build setup"), centeredStyle);
            //basic options
            EditorGUILayout.Space();
            GUILayout.BeginVertical();

            // build target
            using (new EditorGUI.DisabledScope(!AssetBundleModel.Model.DataSource.CanSpecifyBuildTarget)) {
                ValidBuildTarget tgt = (ValidBuildTarget)EditorGUILayout.EnumPopup(m_TargetContent, m_UserData.m_BuildTarget);
                if (tgt != m_UserData.m_BuildTarget)
                {
                    m_UserData.m_BuildTarget = tgt;
                    if (m_UserData.m_UseDefaultPath)
                    {
                        m_UserData.m_OutputPath  = "AssetBundles/";
                        m_UserData.m_OutputPath += m_UserData.m_BuildTarget.ToString();
                        //EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath", m_OutputPath);
                    }
                }
            }


            ////output path
            using (new EditorGUI.DisabledScope(!AssetBundleModel.Model.DataSource.CanSpecifyBuildOutputDirectory)) {
                EditorGUILayout.Space();
                GUILayout.BeginHorizontal();
                var newPath = EditorGUILayout.TextField("Output Path", m_UserData.m_OutputPath);
                if ((newPath != m_UserData.m_OutputPath) &&
                    (newPath != string.Empty))
                {
                    m_UserData.m_UseDefaultPath = false;
                    m_UserData.m_OutputPath     = newPath;
                    //EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath", m_OutputPath);
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Browse", GUILayout.MaxWidth(75f)))
                {
                    BrowseForFolder();
                }
                if (GUILayout.Button("Reset", GUILayout.MaxWidth(75f)))
                {
                    ResetPathToDefault();
                }
                //if (string.IsNullOrEmpty(m_OutputPath))
                //    m_OutputPath = EditorUserBuildSettings.GetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath");
                GUILayout.EndHorizontal();
                EditorGUILayout.Space();

                newState = GUILayout.Toggle(
                    m_ForceRebuild.state,
                    m_ForceRebuild.content);
                if (newState != m_ForceRebuild.state)
                {
                    if (newState)
                    {
                        m_UserData.m_OnToggles.Add(m_ForceRebuild.content.text);
                    }
                    else
                    {
                        m_UserData.m_OnToggles.Remove(m_ForceRebuild.content.text);
                    }
                    m_ForceRebuild.state = newState;
                }
                newState = GUILayout.Toggle(
                    m_CopyToStreaming.state,
                    m_CopyToStreaming.content);
                if (newState != m_CopyToStreaming.state)
                {
                    if (newState)
                    {
                        m_UserData.m_OnToggles.Add(m_CopyToStreaming.content.text);
                    }
                    else
                    {
                        m_UserData.m_OnToggles.Remove(m_CopyToStreaming.content.text);
                    }
                    m_CopyToStreaming.state = newState;
                }
            }

            // advanced options
            using (new EditorGUI.DisabledScope(!AssetBundleModel.Model.DataSource.CanSpecifyBuildOptions)) {
                EditorGUILayout.Space();
                m_AdvancedSettings = EditorGUILayout.Foldout(m_AdvancedSettings, "Advanced Settings");
                if (m_AdvancedSettings)
                {
                    var indent = EditorGUI.indentLevel;
                    EditorGUI.indentLevel = 1;
                    CompressOptions cmp = (CompressOptions)EditorGUILayout.IntPopup(
                        m_CompressionContent,
                        (int)m_UserData.m_Compression,
                        m_CompressionOptions,
                        m_CompressionValues);

                    if (cmp != m_UserData.m_Compression)
                    {
                        m_UserData.m_Compression = cmp;
                    }
                    foreach (var tog in m_ToggleData)
                    {
                        newState = EditorGUILayout.ToggleLeft(
                            tog.content,
                            tog.state);
                        if (newState != tog.state)
                        {
                            if (newState)
                            {
                                m_UserData.m_OnToggles.Add(tog.content.text);
                            }
                            else
                            {
                                m_UserData.m_OnToggles.Remove(tog.content.text);
                            }
                            tog.state = newState;
                        }
                    }
                    EditorGUILayout.Space();
                    EditorGUI.indentLevel = indent;
                }
            }

            // build.
            EditorGUILayout.Space();
            if (GUILayout.Button("Build"))
            {
                EditorApplication.delayCall += ExecuteBuild;
            }
            GUILayout.EndVertical();
            EditorGUILayout.EndScrollView();
        }
예제 #17
0
    public override void OnInspectorGUI()
    {
        GUILayout.Space(10.0f);
        serializedObject.Update();

        GUILayout.BeginVertical("box");

        var usesNormalLight = serializedObject.FindProperty("IsAddedToNormalLight");

        if (usesNormalLight.boolValue)
        {
            EditorGUILayout.HelpBox("This light will use the settings of the light on this GameObject.\n\nRemove this component if the light should not be recognized by Fog Volume 3", MessageType.Info);
        }
        else
        {
            var enabled = serializedObject.FindProperty("Enabled");
            if (GUILayout.Button(enabled.boolValue ? "Disable the light" : "Enable the light"))
            {
                enabled.boolValue = !enabled.boolValue;
            }

            if (enabled.boolValue == true)
            {
                GUILayout.Space(10.0f);

                var isPointLight      = serializedObject.FindProperty("IsPointLight");
                int selectedLightType = isPointLight.boolValue ? 0 : 1;

                selectedLightType =
                    EditorGUILayout.Popup("Light Type: ",
                                          selectedLightType,
                                          m_lightTypes,
                                          EditorStyles.toolbarButton);

                if (selectedLightType == 0)
                {
                    isPointLight.boolValue = true;
                }
                else
                {
                    isPointLight.boolValue = false;
                }

                GUILayout.Space(10.0f);

                var color = serializedObject.FindProperty("Color");
                EditorGUILayout.PropertyField(color, new GUIContent("Color:"));

                GUILayout.Space(10.0f);

                var intensity = serializedObject.FindProperty("Intensity");
                EditorGUILayout.Slider(intensity,
                                       MinIntensity,
                                       MaxIntenstity,
                                       new GUIContent("Intensity:"));

                GUILayout.Space(10.0f);

                var range = serializedObject.FindProperty("Range");
                EditorGUILayout.Slider(range, MinRange, MaxRange, new GUIContent("Range:"));



                if (selectedLightType == 1)
                {
                    GUILayout.Space(10.0f);
                    var angle = serializedObject.FindProperty("Angle");
                    EditorGUILayout.Slider(angle,
                                           MinSpotAngle,
                                           MaxSpotAngle,
                                           new GUIContent("SpotAngle:"));
                }
            }
        }
        GUILayout.EndVertical();

        serializedObject.ApplyModifiedProperties();
    }
예제 #18
0
    public override void OnInspectorGUI()
    {
        bool isEnabled = _dsp.IsInstantiated();

        if (!isEnabled)
        {
            EditorGUILayout.LabelField("Press Play!", EditorStyles.centeredGreyMiniLabel);
        }
        GUILayout.BeginVertical();
        // EVENTS
        GUI.enabled = isEnabled;
        EditorGUILayout.Space();

        // bass
        if (GUILayout.Button("bass"))
        {
            _dsp.SendEvent(Hv_heavy_AudioLib.Event.Bass);
        }

        // checkpoint0
        if (GUILayout.Button("checkpoint0"))
        {
            _dsp.SendEvent(Hv_heavy_AudioLib.Event.Checkpoint0);
        }

        // checkpoint1
        if (GUILayout.Button("checkpoint1"))
        {
            _dsp.SendEvent(Hv_heavy_AudioLib.Event.Checkpoint1);
        }

        // checkpoint2
        if (GUILayout.Button("checkpoint2"))
        {
            _dsp.SendEvent(Hv_heavy_AudioLib.Event.Checkpoint2);
        }

        // checkpoint3
        if (GUILayout.Button("checkpoint3"))
        {
            _dsp.SendEvent(Hv_heavy_AudioLib.Event.Checkpoint3);
        }

        // drum1
        if (GUILayout.Button("drum1"))
        {
            _dsp.SendEvent(Hv_heavy_AudioLib.Event.Drum1);
        }

        // drum2
        if (GUILayout.Button("drum2"))
        {
            _dsp.SendEvent(Hv_heavy_AudioLib.Event.Drum2);
        }

        // engine
        if (GUILayout.Button("engine"))
        {
            _dsp.SendEvent(Hv_heavy_AudioLib.Event.Engine);
        }

        // fill1
        if (GUILayout.Button("fill1"))
        {
            _dsp.SendEvent(Hv_heavy_AudioLib.Event.Fill1);
        }

        // fill2
        if (GUILayout.Button("fill2"))
        {
            _dsp.SendEvent(Hv_heavy_AudioLib.Event.Fill2);
        }

        // finishline
        if (GUILayout.Button("finishline"))
        {
            _dsp.SendEvent(Hv_heavy_AudioLib.Event.Finishline);
        }

        // startendvol
        if (GUILayout.Button("startendvol"))
        {
            _dsp.SendEvent(Hv_heavy_AudioLib.Event.Startendvol);
        }

        // startstopseq
        if (GUILayout.Button("startstopseq"))
        {
            _dsp.SendEvent(Hv_heavy_AudioLib.Event.Startstopseq);
        }

        // wall
        if (GUILayout.Button("wall"))
        {
            _dsp.SendEvent(Hv_heavy_AudioLib.Event.Wall);
        }
        // PARAMETERS
        GUI.enabled = true;
        EditorGUILayout.Space();
        EditorGUI.indentLevel++;

        // frequency
        GUILayout.BeginHorizontal();
        float frequency    = _dsp.GetFloatParameter(Hv_heavy_AudioLib.Parameter.Frequency);
        float newFrequency = EditorGUILayout.Slider("frequency", frequency, 0.0f, 1000.0f);

        if (frequency != newFrequency)
        {
            _dsp.SetFloatParameter(Hv_heavy_AudioLib.Parameter.Frequency, newFrequency);
        }
        GUILayout.EndHorizontal();

        EditorGUI.indentLevel--;



        GUILayout.EndVertical();
    }
예제 #19
0
    void OnGUI()
    {
        GUIStyle boldNumberFieldStyle = new GUIStyle(EditorStyles.numberField);

        boldNumberFieldStyle.font = EditorStyles.boldFont;

        GUIStyle boldToggleStyle = new GUIStyle(EditorStyles.toggle);

        boldToggleStyle.font = EditorStyles.boldFont;

        GUI.enabled = !waitTillPlistHasBeenWritten;

        //Toolbar
        EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
        {
            Rect optionsRect = GUILayoutUtility.GetRect(0, 20, GUILayout.ExpandWidth(false));

            if (GUILayout.Button(new GUIContent("Sort   " + (sortAscending ? "▼" : "▲"), "Change sorting to " + (sortAscending ? "descending" : "ascending")), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
            {
                OnChangeSortModeClicked();
            }

            if (GUILayout.Button(new GUIContent("Options", "Contains additional functionality like \"Add new entry\" and \"Delete all entries\" "), EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(false)))
            {
                GenericMenu options = new GenericMenu();
                options.AddItem(new GUIContent("New Entry..."), false, OnNewEntryClicked);
                options.AddSeparator("");
                options.AddItem(new GUIContent("Delete Selected Entries"), false, OnDeleteSelectedClicked);
                options.AddItem(new GUIContent("Delete All Entries"), false, OnDeleteAllClicked);
                options.DropDown(optionsRect);
            }

            GUILayout.FlexibleSpace();

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                string refreshTooltip = "Should all entries be automaticly refreshed every " + UpdateIntervalInSeconds + " seconds?";
                autoRefresh = GUILayout.Toggle(autoRefresh, new GUIContent("Auto Refresh ", refreshTooltip), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false), GUILayout.MinWidth(20));
            }

            if (GUILayout.Button(new GUIContent(RefreshIcon, "Force a refresh, could take a few seconds."), EditorStyles.toolbarButton, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false)))
            {
                RefreshKeys();
            }

            Rect r;
            if (Application.platform == RuntimePlatform.OSXEditor)
            {
                r = GUILayoutUtility.GetRect(16, 16);
            }
            else
            {
                r = GUILayoutUtility.GetRect(9, 16);
            }

            if (waitTillPlistHasBeenWritten)
            {
                Texture2D t = AssetDatabase.LoadAssetAtPath(IconsPath + "loader/" + (Mathf.FloorToInt(rotation % 12) + 1) + ".png", typeof(Texture2D)) as Texture2D;

                GUI.DrawTexture(new Rect(r.x + 3, r.y, 16, 16), t);
            }
        }
        EditorGUILayout.EndHorizontal();

        GUI.enabled = !waitTillPlistHasBeenWritten;

        if (showNewEntryBox)
        {
            GUILayout.BeginHorizontal(GUI.skin.box);
            {
                GUILayout.BeginVertical(GUILayout.ExpandWidth(true));
                {
                    newKey = EditorGUILayout.TextField("Key", newKey);
                    switch (selectedType)
                    {
                    default:
                    case ValueType.String:
                        newValueString = EditorGUILayout.TextField("Value", newValueString);
                        break;

                    case ValueType.Float:
                        newValueFloat = EditorGUILayout.FloatField("Value", newValueFloat);
                        break;

                    case ValueType.Int:
                        newValueInt = EditorGUILayout.IntField("Value", newValueInt);
                        break;
                    }

                    selectedType = (ValueType)EditorGUILayout.EnumPopup("Type", selectedType);
                }
                GUILayout.EndVertical();

                GUILayout.BeginVertical(GUILayout.Width(1));
                {
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.FlexibleSpace();

                        if (GUILayout.Button(new GUIContent("X", "Close"), EditorStyles.boldLabel, GUILayout.ExpandWidth(false)))
                        {
                            showNewEntryBox = false;
                        }
                    }
                    GUILayout.EndHorizontal();

                    if (GUILayout.Button(new GUIContent(AddIcon, "Add a new key-value.")))
                    {
                        if (!string.IsNullOrEmpty(newKey))
                        {
                            switch (selectedType)
                            {
                            case ValueType.Int:
                                PlayerPrefs.SetInt(newKey, newValueInt);
                                ppeList.Add(new PlayerPrefsEntry(newKey, newValueInt));
                                break;

                            case ValueType.Float:
                                PlayerPrefs.SetFloat(newKey, newValueFloat);
                                ppeList.Add(new PlayerPrefsEntry(newKey, newValueFloat));
                                break;

                            default:
                            case ValueType.String:
                                PlayerPrefs.SetString(newKey, newValueString);
                                ppeList.Add(new PlayerPrefsEntry(newKey, newValueString));
                                break;
                            }
                            PlayerPrefs.Save();
                        }

                        newKey        = newValueString = "";
                        newValueInt   = 0;
                        newValueFloat = 0;
                        GUIUtility.keyboardControl = 0; //move focus from textfield, else the text won't be cleared
                        showNewEntryBox            = false;
                    }
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();
        }

        GUILayout.Space(2);


        GUI.backgroundColor = Color.white;
        EditorGUI.indentLevel++;
        scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
        {
            EditorGUILayout.BeginVertical();
            {
                for (int i = 0; i < ppeList.Count; i++)
                {
                    if (ppeList[i].Value != null)
                    {
                        EditorGUILayout.BeginHorizontal();
                        {
                            ppeList[i].IsSelected = GUILayout.Toggle(ppeList[i].IsSelected, new GUIContent(ppeList[i].Key, "Toggle selection."), ppeList[i].HasChanged ? boldToggleStyle : EditorStyles.toggle, GUILayout.MinWidth(40), GUILayout.MaxWidth(125), GUILayout.ExpandWidth(true));

                            GUIStyle numberFieldStyle = ppeList[i].HasChanged ? boldNumberFieldStyle : EditorStyles.numberField;

                            switch (ppeList[i].Type)
                            {
                            default:
                            case ValueType.String:
                                ppeList[i].Value = EditorGUILayout.TextField("", (string)ppeList[i].Value, numberFieldStyle, GUILayout.MinWidth(40));
                                break;

                            case ValueType.Float:
                                ppeList[i].Value = EditorGUILayout.FloatField("", (float)ppeList[i].Value, numberFieldStyle, GUILayout.MinWidth(40));
                                break;

                            case ValueType.Int:
                                ppeList[i].Value = EditorGUILayout.IntField("", (int)ppeList[i].Value, numberFieldStyle, GUILayout.MinWidth(40));
                                break;
                            }

                            GUI.enabled = ppeList[i].HasChanged && !waitTillPlistHasBeenWritten;
                            if (GUILayout.Button(new GUIContent(SaveIcon, "Save changes made to this value."), GUILayout.ExpandWidth(false)))
                            {
                                ppeList[i].SaveChanges();
                            }

                            if (GUILayout.Button(new GUIContent(UndoIcon, "Discard changes made to this value."), GUILayout.ExpandWidth(false)))
                            {
                                ppeList[i].RevertChanges();
                            }

                            GUI.enabled = !waitTillPlistHasBeenWritten;

                            if (GUILayout.Button(new GUIContent(DeleteIcon, "Delete this key-value."), GUILayout.ExpandWidth(false)))
                            {
                                PlayerPrefs.DeleteKey(ppeList[i].Key);
                                ppeList.Remove(ppeList[i]);
                                PlayerPrefs.Save();
                                break;
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                }
            }
            EditorGUILayout.EndVertical();
        }
        EditorGUILayout.EndScrollView();
        EditorGUI.indentLevel--;
    }
예제 #20
0
        void DrawMainWindow(int windowID)
        {
            //help button
            if (GUI.Button(new Rect(WindowPos.width - 23f, 2f, 20f, 18f),
                           new GUIContent("?", "Help")))
            {
                TCAManual.Toggle();
            }
            if (TCA.Controllable)
            {
                //options button
                if (GUI.Button(new Rect(2f, 2f, 70f, 18f),
                               new GUIContent("advanced", "Advanced configuration"),
                               adv_options? Styles.enabled_button : Styles.normal_button))
                {
                    adv_options = !adv_options;
                }
                GUILayout.BeginVertical();
                GUILayout.BeginHorizontal();
                //tca toggle
                var enabled_style = Styles.inactive_button;
                if (CFG.Enabled)
                {
                    enabled_style = Styles.enabled_button;
                }
                else if (!VSL.LandedOrSplashed)
                {
                    if (EnabledBlinker.On)
                    {
                        enabled_style = Styles.danger_button;
                    }
                    Status(0.1, "red", "<b>TCA is disabled</b>");
                }
                if (GUILayout.Button("Enabled", enabled_style, GUILayout.Width(70)))
                {
                    if (SQD == null)
                    {
                        TCA.ToggleTCA();
                    }
                    else
                    {
                        SQD.Apply(tca => tca.ToggleTCA());
                    }
                }
                //squad mode switch
                SquadControls.Draw();
                GUILayout.FlexibleSpace();
                StatusString();
                GUILayout.EndHorizontal();
                SelectConfig_start();
                AdvancedOptions();
                AttitudeControls.Draw();
                InOrbitControls.Draw();
                OnPlanetControls.Draw();
                NavigationControls.Draw();
                MacroControls.Draw();
                NavigationControls.WaypointList();
                EnginesControl();
                                #if DEBUG
                DebugInfo();
//				EnginesInfo();
                                #endif
                if (!string.IsNullOrEmpty(StatusMessage))
                {
                    if (GUILayout.Button(new GUIContent(StatusMessage, "Click to dismiss"),
                                         Styles.boxed_label, GUILayout.ExpandWidth(true)) ||
                        StatusEndTime > DateTime.MinValue && DateTime.Now > StatusEndTime)
                    {
                        StatusMessage = "";
                    }
                }
                SelectConfig_end();
                GUILayout.EndVertical();
            }
            else
            {
                GUILayout.Label("Vessel is Uncontrollable", Styles.label, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
            }
            TooltipsAndDragWindow(WindowPos);
        }
        public override void DrawGUI(Rect position, BuildInfo buildReportToDisplay)
        {
            BuildSettingCategory b = ReportGenerator.GetBuildSettingCategoryFromBuildValues(buildReportToDisplay);

            _buildTargetOfReport = UnityBuildSettingsUtility.GetReadableBuildSettingCategory(b);

            UnityBuildSettings settings = buildReportToDisplay.UnityBuildSettings;

            if (settings == null)
            {
                Utility.DrawCentralMessage(position, "No \"Project Settings\" recorded in this build report.");
                return;
            }

            // ----------------------------------------------------------
            // top bar

            GUILayout.Space(1);
            GUILayout.BeginHorizontal();

            GUILayout.Label(" ", BuildReportTool.Window.Settings.TOP_BAR_BG_STYLE_NAME);

            GUILayout.Space(8);
            GUILayout.Label("Build Target: ", BuildReportTool.Window.Settings.TOP_BAR_LABEL_STYLE_NAME);

            InitializeDropdownBoxLabelsIfNeeded();
            _selectedSettingsIdxFromDropdownBox = EditorGUILayout.Popup(_selectedSettingsIdxFromDropdownBox, _settingDropdownBoxLabels, BuildReportTool.Window.Settings.FILE_FILTER_POPUP_STYLE_NAME);
            GUILayout.Space(15);

            GUILayout.Label("Note: Project was built in " + _buildTargetOfReport + " target", BuildReportTool.Window.Settings.TOP_BAR_LABEL_STYLE_NAME);

            GUILayout.FlexibleSpace();

            _settingsShown = UnityBuildSettingsUtility.GetSettingsCategoryFromIdx(_selectedSettingsIdxFromDropdownBox);

            GUILayout.EndHorizontal();

            // ----------------------------------------------------------

            _scrollPos = GUILayout.BeginScrollView(_scrollPos);

            GUILayout.BeginHorizontal();

            GUILayout.Space(10);
            GUILayout.BeginVertical();


            GUILayout.Space(10);



            // =================================================================
            DrawProjectSettings(buildReportToDisplay, settings);
            GUILayout.Space(SETTINGS_GROUP_SPACING);


            // =================================================================
            DrawPathSettings(buildReportToDisplay, settings);
            GUILayout.Space(SETTINGS_GROUP_SPACING);


            // =================================================================
            DrawBuildSettings(buildReportToDisplay, settings);
            GUILayout.Space(SETTINGS_GROUP_SPACING);


            // =================================================================
            DrawRuntimeSettings(buildReportToDisplay, settings);


            // --------------------------------------------------
            // security settings
            if (IsShowingMacSettings)
            {
                DrawSetting("Use App Store validation:", settings.MacUseAppStoreValidation);
            }
            else if (IsShowingAndroidSettings)
            {
                DrawSetting("Use license verification:", settings.AndroidUseLicenseVerification);
            }


            GUILayout.Space(SETTINGS_GROUP_SPACING);


            // =================================================================
            DrawDebugSettings(buildReportToDisplay, settings);
            GUILayout.Space(SETTINGS_GROUP_SPACING);


            // =================================================================
            DrawCodeSettings(buildReportToDisplay, settings);
            GUILayout.Space(SETTINGS_GROUP_SPACING);


            // =================================================================
            DrawGraphicsSettings(buildReportToDisplay, settings);
            GUILayout.Space(SETTINGS_GROUP_SPACING);


            GUILayout.Space(10);
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            GUILayout.EndScrollView();
        }
예제 #22
0
        public override void DoWindowContents(Rect inRect)
        {
            // close on world map, on committed maps
            var mapState = RerollToolbox.GetStateForMap();

            if (Find.World.renderer.wantedMode != WorldRenderMode.None || Find.CurrentMap == null || mapState.MapCommitted)
            {
                Close();
                return;
            }
            float diceButtonSize = MapRerollController.Instance.WidgetSizeSetting;
            var   buttonRect     = new Rect((inRect.width - diceButtonSize) + Margin, -Margin, diceButtonSize, diceButtonSize);

            if (Widgets.ButtonImage(buttonRect, Resources.Textures.UIDiceActive))
            {
                Close();
            }
            var contentsRect = inRect.ContractedBy(ContentsPadding);

            Text.Anchor = TextAnchor.MiddleCenter;
            Text.Font   = GameFont.Medium;
            var headerRect = new Rect(contentsRect.x, contentsRect.y, contentsRect.width, 30f);

            Widgets.Label(headerRect, "MapReroll_windowTitle".Translate());
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;

            var layoutRect = new Rect(contentsRect.x, contentsRect.y + headerRect.yMax, contentsRect.width, contentsRect.height - headerRect.yMax);

            GUILayout.BeginArea(layoutRect);
            GUILayout.BeginVertical();
            var extraResourcesHeight = 0f;
            var separatorHeight      = ContentsPadding + 1;
            var controlHeight        = (layoutRect.height - (ControlSpacing * 2f + separatorHeight + extraResourcesHeight)) / 4f;

            balanceWidget.DrawLayout(controlHeight + extraResourcesHeight);

            GUILayout.Space(ControlSpacing);
            DoRerollTabButton(Resources.Textures.UIRerollMapOn, Resources.Textures.UIRerollMapOff, MapRerollUtility.WithCostSuffix("Reroll2_rerollMap", PaidOperationType.GeneratePreviews), null, controlHeight, () => {
                if (RerollToolbox.GetOperationCost(PaidOperationType.GeneratePreviews) > 0)
                {
                    RerollToolbox.ChargeForOperation(PaidOperationType.GeneratePreviews);
                }
                Find.WindowStack.Add(new Dialog_MapPreviews());
            });

            GUILayout.Space(ControlSpacing);
            DoRerollTabButton(Resources.Textures.UIRerollGeysersOn, Resources.Textures.UIRerollGeysersOff, MapRerollUtility.WithCostSuffix("Reroll2_rerollGeysers", PaidOperationType.RerollGeysers), null, controlHeight, () => {
                if (!MapRerollController.Instance.GeyserRerollInProgress)
                {
                    MapRerollController.Instance.RerollGeysers();
                }
                else
                {
                    Messages.Message("Reroll2_rerollInProgress".Translate(), MessageTypeDefOf.RejectInput);
                }
            });

            DrawSeparator(separatorHeight);

            DoRerollTabButton(Resources.Textures.UICommitMapOn, Resources.Textures.UICommitMapOff, MapRerollUtility.WithCostSuffix("Reroll2_commitMap", PaidOperationType.RerollGeysers), "Reroll2_commitMap_tip".Translate(), controlHeight, () => {
                RerollToolbox.GetStateForMap().MapCommitted = true;
                MapRerollController.Instance.UIController.ResetCache();
            });
            GUILayout.EndVertical();
            GUILayout.EndArea();
        }
예제 #23
0
        protected override void OnInspectorGUIOverride()
        {
            if (m_spline == null)
            {
                return;
            }

            rotationSpeedProp.floatValue = EditorGUILayout.FloatField("Rotation Speed", rotationSpeedProp.floatValue);

            if (ConvergingSpline)
            {
                if (GUILayout.Button("Cancel"))
                {
                    ConvergingSpline = null;
                }
                return;
            }
            GUILayout.BeginHorizontal();
            {
                GUILayout.BeginVertical();
                int curveIndex = (SelectedIndex - 1) / 3;

                if (GUILayout.Button("OUT -> Branch"))
                {
                    CreateBranch(m_spline, SelectedIndex, false);
                }


                if (curveIndex == m_spline.CurveCount - 1 && m_spline.NextSpline == null)
                {
                    if (m_spline.NextSpline == null)
                    {
                        if (GUILayout.Button("Append"))
                        {
                            SplineEditor.Append(m_spline);
                            Selection.activeGameObject = m_spline.GetSplineControlPoints().Last().gameObject;
                        }
                    }
                }

                if (curveIndex == 0 && m_spline.PrevSpline == null)
                {
                    if (m_spline.PrevSpline == null)
                    {
                        if (GUILayout.Button("Prepend"))
                        {
                            SplineEditor.Prepend(m_spline);
                            Selection.activeGameObject = m_spline.GetSplineControlPoints().First().gameObject;
                        }
                    }
                }

                if (GUILayout.Button("Insert"))
                {
                    SplineEditor.Insert(m_spline, SelectedIndex);
                    Selection.activeGameObject = m_spline.GetSplineControlPoints().ElementAt(SelectedIndex + 3).gameObject;
                }
                GUILayout.EndVertical();

                GUILayout.BeginVertical();

                if (GUILayout.Button("Branch -> IN"))
                {
                    CreateBranch(m_spline, SelectedIndex, true);
                }

                if (curveIndex == m_spline.CurveCount - 1 && m_spline.NextSpline == null)
                {
                    if (m_spline.NextSpline == null)
                    {
                        if (SceneView.lastActiveSceneView != null && SceneView.lastActiveSceneView.camera)
                        {
                            if (GUILayout.Button("To Cam"))
                            {
                                SplineEditor.AppendThrough(m_spline, SceneView.lastActiveSceneView.camera.transform);
                                Selection.activeGameObject = m_spline.GetSplineControlPoints().Last().gameObject;
                            }
                        }
                    }
                }

                if (curveIndex == 0 && m_spline.PrevSpline == null)
                {
                    if (m_spline.PrevSpline == null)
                    {
                        if (SceneView.lastActiveSceneView != null && SceneView.lastActiveSceneView.camera)
                        {
                            if (GUILayout.Button("To Cam"))
                            {
                                SplineEditor.PrependThrough(m_spline, SceneView.lastActiveSceneView.camera.transform);
                                Selection.activeGameObject = m_spline.GetSplineControlPoints().First().gameObject;
                            }
                        }
                    }
                }

                if (SelectedIndex >= 0 && curveIndex < m_spline.CurveCount)
                {
                    if (GUILayout.Button("Remove"))
                    {
                        Remove(m_spline, SelectedIndex);
                    }
                }

                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();

            if (SelectedIndex == 0 && m_spline.PrevSpline == null ||
                SelectedIndex == m_spline.ControlPointCount - 1 && m_spline.NextSpline == null)
            {
                if (!m_spline.HasBranches(SelectedIndex))
                {
                    if (GUILayout.Button("Converge"))
                    {
                        if (m_spline.Loop)
                        {
                            EditorUtility.DisplayDialog("Unable to converge", "Unable to converge. Selected spline has loop.", "OK");
                        }
                        else
                        {
                            ConvergingSpline = m_spline;
                        }
                    }
                }
            }
            if (SelectedIndex < m_spline.ControlPointCount && SelectedIndex >= 0)
            {
                if (m_spline.HasBranches(SelectedIndex))
                {
                    if (GUILayout.Button("Separate"))
                    {
                        Separate(m_spline, SelectedIndex);
                    }
                }
            }

            if (GUILayout.Button("Align View To Point"))
            {
                if (SceneView.lastActiveSceneView != null)
                {
                    SplineControlPoint controlPoint = (SplineControlPoint)target;


                    SceneView.lastActiveSceneView.AlignViewToObject(controlPoint.transform);
                    SceneView.lastActiveSceneView.Repaint();
                }
            }

            base.OnInspectorGUIOverride();
        }
예제 #24
0
        void OnGUIMapper()
        {
            TextAsset prevTextFile = mTextFileMapper;

            EditorGUIUtility.labelWidth = 80.0f;

            GUILayout.BeginHorizontal();

            bool doCreate = false;

            if (mTextFileMapper == null)
            {
                GUI.backgroundColor = Color.green;
                doCreate            = GUILayout.Button("Create", GUILayout.Width(76f));

                GUI.backgroundColor = Color.white;
                mTextNameMapper     = GUILayout.TextField(mTextNameMapper);
            }

            GUILayout.EndHorizontal();

            if (mTextFileMapper != null)
            {
                mTextNameMapper     = mTextFileMapper.name;
                mTextFilePathMapper = AssetDatabase.GetAssetPath(mTextFileMapper);
            }
            else if (!string.IsNullOrEmpty(mTextNameMapper))
            {
                mTextFilePathMapper = Utility.GetSelectionFolder() + mTextNameMapper + ".txt";
            }

            if (doCreate && !string.IsNullOrEmpty(mTextNameMapper))
            {
                File.WriteAllText(mTextFilePathMapper, "");

                AssetDatabase.Refresh();

                mTextFileMapper = (TextAsset)AssetDatabase.LoadAssetAtPath(mTextFilePathMapper, typeof(TextAsset));
            }

            GUILayout.BeginHorizontal();

            GUILayout.Label("Select: ");

            mTextFileMapper = (TextAsset)EditorGUILayout.ObjectField(mTextFileMapper, typeof(TextAsset), false);

            GUILayout.EndHorizontal();

            if (!string.IsNullOrEmpty(mTextFilePathMapper))
            {
                GUILayout.Label("Path: " + mTextFilePathMapper);
            }
            else
            {
                GUILayout.Label("Path: <none>" + mTextFilePathMapper);
            }

            GUILayout.BeginVertical(GUI.skin.box);

            mGenerateScript = GUILayout.Toggle(mGenerateScript, "Generate Script");
            if (mGenerateScript)
            {
                EditorGUIUtility.labelWidth = 46.0f;
                GUILayout.BeginHorizontal();
                mGenerateScriptFolder = EditorGUILayout.TextField("Folder", mGenerateScriptFolder);
                if (GUILayout.Button("Browse", GUILayout.Width(55f)))
                {
                    string path = EditorUtility.SaveFolderPanel("Select Directory", mGenerateScriptFolder, "");
                    if (!string.IsNullOrEmpty(path))
                    {
                        mGenerateScriptFolder = path;
                    }
                }
                GUILayout.EndHorizontal();
                GUILayout.Label("Path: " + mGenerateScriptFolder + "/InputAction.cs");
            }

            GUILayout.EndVertical();

            GUILayout.Space(6f);

            GUILayout.BeginVertical(GUI.skin.box);

            if (mTextFileMapper != null)
            {
                if (prevTextFile != mTextFileMapper || mActions == null)
                {
                    GetInputActions(mTextFileMapper);
                }

                //list actions
                int removeInd = -1;

                Regex r = new Regex("^[a-zA-Z0-9]*$");

                for (int i = 0; i < mActions.Count; i++)
                {
                    GUILayout.BeginHorizontal();

                    GUILayout.Label(i.ToString(), GUILayout.MaxWidth(20));

                    string text = GUILayout.TextField(mActions[i], 255);

                    if (text.Length > 0 && (r.IsMatch(text) && !char.IsDigit(text[0])))
                    {
                        mActions[i] = text;
                    }

                    if (GUILayout.Button("DEL", GUILayout.MaxWidth(40)))
                    {
                        removeInd = i;
                    }

                    GUILayout.EndHorizontal();
                }

                if (removeInd != -1)
                {
                    mActions.RemoveAt(removeInd);
                }

                if (GUILayout.Button("Add"))
                {
                    mActions.Add("Unknown" + (mUnknownCount++));
                }
            }

            GUILayout.EndVertical();

            EditorGUIUtility.labelWidth = 0.0f;
        }
    void OnGUI()
    {
        if (Event.current.type == EventType.DragUpdated)
        {
            if (IsValidDragPayload())
            {
                dragging = true;
            }
        }
        else if (Event.current.type == EventType.DragExited)
        {
            dragging = false;
            Repaint();
        }
        else
        {
            if (currentDraggingValue != dragging)
            {
                currentDraggingValue = dragging;
            }
        }

        if (Event.current.type == EventType.Layout && deferredDroppedObjects != null)
        {
            HandleDroppedPayload(deferredDroppedObjects);
            deferredDroppedObjects = null;
        }

        if (HandleAssetsInResources())
        {
            return;
        }

        GUILayout.BeginVertical();

        DrawToolbar();

        GUILayout.BeginHorizontal();

        if (currentDraggingValue)
        {
            DrawDropZone();
        }
        else
        {
            DrawSpriteList();
        }

        if (settingsView.show || (spriteCollectionProxy != null && spriteCollectionProxy.Empty))
        {
            settingsView.Draw();
        }
        else if (fontView.Draw(selectedEntries))
        {
        }
        else if (spriteSheetView.Draw(selectedEntries))
        {
        }
        else
        {
            spriteView.Draw(selectedEntries);
        }

        GUILayout.EndHorizontal();
        GUILayout.EndVertical();
    }
예제 #26
0
        void OnGUIBinder()
        {
            TextAsset prevTextFile = mTextFileBinder;

            EditorGUIUtility.labelWidth = 80.0f;

            GUILayout.BeginHorizontal();

            bool doCreate = false;

            if (mTextFileBinder == null)
            {
                GUI.backgroundColor = Color.green;
                doCreate            = GUILayout.Button("Create", GUILayout.Width(76f));

                GUI.backgroundColor = Color.white;
                mTextNameBinder     = GUILayout.TextField(mTextNameBinder);
            }

            GUILayout.EndHorizontal();

            if (mTextFileBinder != null)
            {
                mTextNameBinder     = mTextFileBinder.name;
                mTextFilePathBinder = AssetDatabase.GetAssetPath(mTextFileBinder);
            }
            else if (!string.IsNullOrEmpty(mTextNameBinder))
            {
                mTextFilePathBinder = Utility.GetSelectionFolder() + mTextNameBinder + ".txt";
            }

            if (doCreate && !string.IsNullOrEmpty(mTextNameBinder))
            {
                File.WriteAllText(mTextFilePathBinder, "");

                AssetDatabase.Refresh();

                mTextFileBinder = (TextAsset)AssetDatabase.LoadAssetAtPath(mTextFilePathBinder, typeof(TextAsset));
            }

            GUILayout.BeginHorizontal();

            GUILayout.Label("Select: ");

            mTextFileBinder = (TextAsset)EditorGUILayout.ObjectField(mTextFileBinder, typeof(TextAsset), false);

            GUILayout.EndHorizontal();

            if (!string.IsNullOrEmpty(mTextFilePathBinder))
            {
                GUILayout.Label("Path: " + mTextFilePathBinder);
            }
            else
            {
                GUILayout.Label("Path: <none>" + mTextFilePathBinder);
            }

            GUILayout.Space(6f);

            bool refreshBinds = mTextFileBinder != prevTextFile;

            if (mTextFileBinder != null && actions != null)
            {
                //initialize bind data
                if (mBinds == null || mBinds.Length != actions.Count)
                {
                    if (mBinds == null)
                    {
                        mBinds = new BindData[actions.Count];
                    }
                    else
                    {
                        System.Array.Resize <BindData>(ref mBinds, actions.Count);
                    }

                    refreshBinds = true;
                }

                //load from file
                if (refreshBinds && mTextFileBinder.text.Length > 0)
                {
                    //load data
                    List <InputManager.Bind> loadBinds = InputManager.BindList.FromJSON(mTextFileBinder.text);
                    foreach (InputManager.Bind bind in loadBinds)
                    {
                        if (bind.action < mBinds.Length)
                        {
                            mBinds[bind.action].bind = bind;
                            mBinds[bind.action].RefreshKeyTypes();
                        }
                    }
                }

                //display binds
                for (int i = 0; i < mBinds.Length; i++)
                {
                    if (mBinds[i].bind == null)
                    {
                        mBinds[i].bind = new InputManager.Bind();
                    }

                    mBinds[i].bind.action = i;

                    GUILayout.BeginVertical(GUI.skin.box);

                    GUILayout.BeginHorizontal();

                    GUILayout.Label(actions[i]);

                    GUILayout.FlexibleSpace();

                    mBinds[i].bind.control = (InputManager.Control)EditorGUILayout.EnumPopup(mBinds[i].bind.control);

                    GUILayout.EndHorizontal();

                    if (mBinds[i].bind.control == InputManager.Control.Axis)
                    {
                        mBinds[i].bind.deadZone = EditorGUILayout.FloatField("Deadzone", mBinds[i].bind.deadZone);
                        mBinds[i].bind.forceRaw = EditorGUILayout.Toggle("Force Raw", mBinds[i].bind.forceRaw);
                    }

                    int keyCount = mBinds[i].keyTypes != null ? mBinds[i].keyTypes.Length : 0;

                    mBinds[i].foldOut = EditorGUILayout.Foldout(mBinds[i].foldOut, string.Format("Binds [{0}]", keyCount));

                    if (mBinds[i].foldOut)
                    {
                        int delKey = -1;

                        for (int key = 0; key < keyCount; key++)
                        {
                            GUILayout.BeginVertical(GUI.skin.box);

                            GUILayout.BeginHorizontal();
                            mBinds[i].bind.keys[key].player = EditorGUILayout.IntField("Player", mBinds[i].bind.keys[key].player, GUILayout.MaxWidth(200));

                            GUILayout.FlexibleSpace();

                            if (GUILayout.Button("DEL", GUILayout.MaxWidth(40)))
                            {
                                delKey = key;
                            }

                            GUILayout.EndHorizontal();

                            GUILayout.BeginHorizontal();

                            //key bind
                            mBinds[i].keyTypes[key] = (InputType)EditorGUILayout.EnumPopup(mBinds[i].keyTypes[key]);

                            switch (mBinds[i].keyTypes[key])
                            {
                            case InputType.Unity:
                                mBinds[i].bind.keys[key].input = EditorGUILayout.TextField(mBinds[i].bind.keys[key].input, GUILayout.MinWidth(250));
                                break;

                            case InputType.KeyCode:
                                mBinds[i].bind.keys[key].code = (KeyCode)EditorGUILayout.EnumPopup(mBinds[i].bind.keys[key].code);
                                break;

                            case InputType.InputMap:
                                mBinds[i].bind.keys[key].map = (InputKeyMap)EditorGUILayout.EnumPopup(mBinds[i].bind.keys[key].map);
                                break;
                            }

                            GUILayout.EndHorizontal();

                            //other configs
                            if (mBinds[i].bind.control == InputManager.Control.Axis)
                            {
                                if (mBinds[i].keyTypes[key] != InputType.Unity)
                                {
                                    mBinds[i].bind.keys[key].axis = (InputManager.ButtonAxis)EditorGUILayout.EnumPopup("Axis", mBinds[i].bind.keys[key].axis, GUILayout.MaxWidth(200));
                                }

                                if (mBinds[i].keyTypes[key] == InputType.Unity || mBinds[i].bind.keys[key].axis == InputManager.ButtonAxis.Both)
                                {
                                    mBinds[i].bind.keys[key].invert = EditorGUILayout.Toggle("Invert", mBinds[i].bind.keys[key].invert);
                                }
                            }
                            else
                            {
                                mBinds[i].bind.keys[key].index = EditorGUILayout.IntField("Index", mBinds[i].bind.keys[key].index, GUILayout.MaxWidth(200));
                            }

                            GUILayout.EndVertical();
                        }

                        if (delKey != -1)
                        {
                            mBinds[i].DeleteKey(delKey);
                        }

                        if (GUILayout.Button("Add"))
                        {
                            mBinds[i].ResizeKeys(keyCount + 1);
                        }
                    }

                    GUILayout.EndVertical();
                }
            }

            EditorGUIUtility.labelWidth = 0.0f;
        }
예제 #27
0
    /// <summary>
    /// Draw the label's properties.
    /// </summary>

    protected override bool ShouldDrawProperties()
    {
        mIsDynamic  = false;
        mHasSymbols = false;
        mLabel      = mWidget as UILabel;

        GUILayout.BeginHorizontal();

#if DYNAMIC_FONT
        mFontType = (FontType)EditorGUILayout.EnumPopup(mFontType, "DropDown", GUILayout.Width(74f));
        if (NGUIEditorTools.DrawPrefixButton("Font", GUILayout.Width(64f)))
#else
        mFontType = FontType.NGUI;
        if (NGUIEditorTools.DrawPrefixButton("Font", GUILayout.Width(74f)))
#endif
        {
            if (mFontType == FontType.NGUI)
            {
                var bmf = mLabel.font;
                if (bmf != null && bmf is UIFont)
                {
                    ComponentSelector.Show <UIFont>(OnNGUIFont);
                }
                else
                {
                    ComponentSelector.Show <NGUIFont>(OnNGUIFont);
                }
            }
            else
            {
                ComponentSelector.Show <Font>(OnUnityFont, new string[] { ".ttf", ".otf" });
            }
        }

        bool isValid           = false;
        SerializedProperty fnt = null;
        SerializedProperty ttf = null;
        GUI.changed = false;

        if (mFontType == FontType.NGUI)
        {
            fnt = NGUIEditorTools.DrawProperty("", serializedObject, "mFont", GUILayout.MinWidth(40f));

            // Legacy font support
            if (fnt.objectReferenceValue != null && fnt.objectReferenceValue is GameObject)
            {
                fnt.objectReferenceValue = (fnt.objectReferenceValue as GameObject).GetComponent <UIFont>();
            }

            if (fnt.objectReferenceValue != null)
            {
                if (GUI.changed)
                {
                    serializedObject.FindProperty("mTrueTypeFont").objectReferenceValue = null;
                }
                NGUISettings.ambigiousFont = fnt.objectReferenceValue;
                isValid = true;
            }
        }
        else
        {
            ttf = NGUIEditorTools.DrawProperty("", serializedObject, "mTrueTypeFont", GUILayout.MinWidth(40f));

            if (ttf.objectReferenceValue != null)
            {
                if (GUI.changed)
                {
                    serializedObject.FindProperty("mFont").objectReferenceValue = null;
                }
                NGUISettings.ambigiousFont = ttf.objectReferenceValue;
                isValid = true;
            }
        }

        GUILayout.EndHorizontal();

#if UNITY_5_6
        if (mFontType == FontType.Unity)
        {
            EditorGUILayout.HelpBox("Dynamic fonts suffer from issues in Unity itself where your characters may disappear, get garbled, or just not show at times. Use this feature at your own risk.\n\n" +
                                    "When you do run into such issues, please submit a Bug Report to Unity via Help -> Report a Bug (as this is will be a Unity bug, not an NGUI one).", MessageType.Warning);
        }
#endif

        NGUIEditorTools.DrawProperty("Material", serializedObject, "mMat");

        EditorGUI.BeginDisabledGroup(!isValid);
        {
            var dynFont = (ttf != null) ? ttf.objectReferenceValue as Font : null;
            var bmFont  = (fnt != null) ? fnt.objectReferenceValue : null;
            var bm      = bmFont as INGUIFont;

            if (bm != null && bm.isDynamic)
            {
                dynFont     = bm.dynamicFont;
                mHasSymbols = bm.hasSymbols;
                bm          = null;
            }

            if (dynFont != null)
            {
                mIsDynamic = true;

                GUILayout.BeginHorizontal();
                {
                    EditorGUI.BeginDisabledGroup((ttf != null) ? ttf.hasMultipleDifferentValues : fnt.hasMultipleDifferentValues);

                    var prop = NGUIEditorTools.DrawProperty("Font Size", serializedObject, "mFontSize", GUILayout.Width(142f));
                    NGUISettings.fontSize = prop.intValue;

                    prop = NGUIEditorTools.DrawProperty("", serializedObject, "mFontStyle", GUILayout.MinWidth(40f));
                    NGUISettings.fontStyle = (FontStyle)prop.intValue;

                    NGUIEditorTools.DrawPadding();
                    EditorGUI.EndDisabledGroup();
                }
                GUILayout.EndHorizontal();
            }
            else if (bmFont != null)
            {
                GUILayout.BeginHorizontal();
                var prop = NGUIEditorTools.DrawProperty("Font Size", serializedObject, "mFontSize", GUILayout.Width(142f));

                EditorGUI.BeginDisabledGroup(true);

                if (!serializedObject.isEditingMultipleObjects)
                {
                    var printed = mLabel.finalFontSize;
                    var def     = mLabel.defaultFontSize;

                    if (mLabel.overflowMethod == UILabel.Overflow.ShrinkContent && printed != mLabel.fontSize)
                    {
                        GUILayout.Label(" Printed: " + printed);
                    }
                    else if (printed != def)
                    {
                        GUILayout.Label(" Default: " + def);
                    }
                }

                EditorGUI.EndDisabledGroup();

                NGUISettings.fontSize = prop.intValue;
                GUILayout.EndHorizontal();
            }

            bool ww = GUI.skin.textField.wordWrap;
            GUI.skin.textField.wordWrap = true;
            SerializedProperty sp = serializedObject.FindProperty("mText");

            if (sp.hasMultipleDifferentValues)
            {
                NGUIEditorTools.DrawProperty("", sp, GUILayout.Height(128f));
            }
            else
            {
                GUIStyle style = new GUIStyle(EditorStyles.textField);
                style.wordWrap = true;

                float height = style.CalcHeight(new GUIContent(sp.stringValue), Screen.width - 100f);
                bool  offset = true;

                if (height > 90f)
                {
                    offset = false;
                    height = style.CalcHeight(new GUIContent(sp.stringValue), Screen.width - 20f);
                }
                else
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.BeginVertical(GUILayout.Width(76f));
                    GUILayout.Space(3f);
                    GUILayout.Label("Text");
                    GUILayout.EndVertical();
                    GUILayout.BeginVertical();
                }
                Rect rect = EditorGUILayout.GetControlRect(GUILayout.Height(height));

                GUI.changed = false;
                string text = EditorGUI.TextArea(rect, sp.stringValue, style);
                if (GUI.changed)
                {
                    sp.stringValue = text;
                }

                if (offset)
                {
                    GUILayout.EndVertical();
                    GUILayout.EndHorizontal();
                }
            }

            GUI.skin.textField.wordWrap = ww;

            NGUIEditorTools.DrawPaddedProperty("Modifier", serializedObject, "mModifier");

            SerializedProperty ov = NGUIEditorTools.DrawPaddedProperty("Overflow", serializedObject, "mOverflow");
            NGUISettings.overflowStyle = (UILabel.Overflow)ov.intValue;
            if (NGUISettings.overflowStyle == UILabel.Overflow.ClampContent)
            {
                NGUIEditorTools.DrawProperty("Use Ellipsis", serializedObject, "mOverflowEllipsis", GUILayout.Width(110f));
            }

            if (NGUISettings.overflowStyle == UILabel.Overflow.ResizeFreely)
            {
                GUILayout.BeginHorizontal();
                SerializedProperty s = NGUIEditorTools.DrawPaddedProperty("Max Width", serializedObject, "mOverflowWidth");

                if (s != null)
                {
                    if (s.intValue < 0)
                    {
                        s.intValue = 0;
                    }
                    if (s.intValue == 0)
                    {
                        GUILayout.Label("unlimited");
                    }
                }

                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                s = NGUIEditorTools.DrawPaddedProperty("Max Height", serializedObject, "mOverflowHeight");

                if (s != null)
                {
                    if (s.intValue < 0)
                    {
                        s.intValue = 0;
                    }
                    if (s.intValue == 0)
                    {
                        GUILayout.Label("unlimited");
                    }
                }

                GUILayout.EndHorizontal();
            }

            NGUIEditorTools.DrawPaddedProperty("Alignment", serializedObject, "mAlignment");

            if (dynFont != null)
            {
                NGUIEditorTools.DrawPaddedProperty("Keep crisp", serializedObject, "keepCrispWhenShrunk");
            }

            if (bm != null)
            {
                EditorGUI.BeginDisabledGroup(bm.packedFontShader);
            }
            else
            {
                EditorGUI.BeginDisabledGroup(false);
            }

            GUILayout.BeginHorizontal();
            SerializedProperty gr = NGUIEditorTools.DrawProperty("Gradient", serializedObject, "mApplyGradient",
                                                                 GUILayout.Width(95f));

            EditorGUI.BeginDisabledGroup(!gr.hasMultipleDifferentValues && !gr.boolValue);
            {
                NGUIEditorTools.SetLabelWidth(30f);
                NGUIEditorTools.DrawProperty("Top", serializedObject, "mGradientTop", GUILayout.MinWidth(40f));
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                NGUIEditorTools.SetLabelWidth(50f);
                GUILayout.Space(79f);

                NGUIEditorTools.DrawProperty("Bottom", serializedObject, "mGradientBottom", GUILayout.MinWidth(40f));
                NGUIEditorTools.SetLabelWidth(80f);
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Effect", GUILayout.Width(76f));
            sp = NGUIEditorTools.DrawProperty("", serializedObject, "mEffectStyle", GUILayout.MinWidth(16f));

            EditorGUI.BeginDisabledGroup(!sp.hasMultipleDifferentValues && !sp.boolValue);
            {
                NGUIEditorTools.DrawProperty("", serializedObject, "mEffectColor", GUILayout.MinWidth(10f));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(" ", GUILayout.Width(56f));
                    NGUIEditorTools.SetLabelWidth(20f);
                    NGUIEditorTools.DrawProperty("X", serializedObject, "mEffectDistance.x", GUILayout.MinWidth(40f));
                    NGUIEditorTools.DrawProperty("Y", serializedObject, "mEffectDistance.y", GUILayout.MinWidth(40f));
                    NGUIEditorTools.DrawPadding();
                    NGUIEditorTools.SetLabelWidth(80f);
                }
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();

            sp = NGUIEditorTools.DrawProperty("Float spacing", serializedObject, "mUseFloatSpacing", GUILayout.Width(100f));

            if (!sp.boolValue)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Spacing", GUILayout.Width(56f));
                NGUIEditorTools.SetLabelWidth(20f);
                NGUIEditorTools.DrawProperty("X", serializedObject, "mSpacingX", GUILayout.MinWidth(40f));
                NGUIEditorTools.DrawProperty("Y", serializedObject, "mSpacingY", GUILayout.MinWidth(40f));
                NGUIEditorTools.DrawPadding();
                NGUIEditorTools.SetLabelWidth(80f);
                GUILayout.EndHorizontal();
            }
            else
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Spacing", GUILayout.Width(56f));
                NGUIEditorTools.SetLabelWidth(20f);
                NGUIEditorTools.DrawProperty("X", serializedObject, "mFloatSpacingX", GUILayout.MinWidth(40f));
                NGUIEditorTools.DrawProperty("Y", serializedObject, "mFloatSpacingY", GUILayout.MinWidth(40f));
                NGUIEditorTools.DrawPadding();
                NGUIEditorTools.SetLabelWidth(80f);
                GUILayout.EndHorizontal();
            }

            NGUIEditorTools.DrawProperty("Max Lines", serializedObject, "mMaxLineCount", GUILayout.Width(110f));

            GUILayout.BeginHorizontal();
            sp = NGUIEditorTools.DrawProperty("BBCode", serializedObject, "mEncoding", GUILayout.Width(100f));

            EditorGUI.BeginDisabledGroup(!mHasSymbols || !sp.boolValue);
            NGUIEditorTools.SetLabelWidth(60f);
            NGUIEditorTools.DrawPaddedProperty("Symbols", serializedObject, "mSymbols");
            NGUIEditorTools.SetLabelWidth(80f);
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();
        }
        EditorGUI.EndDisabledGroup();
        return(isValid);
    }
        void _drawGUI(int id)
        {
            UpArrow   = ResonantOrbitCalculator.Instance.upContent;
            DownArrow = ResonantOrbitCalculator.Instance.downContent;

            GUILayout.BeginHorizontal(GUILayout.Width(wnd_width));

            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal(GUILayout.Width(wnd_width));
            GUILayout.BeginVertical(GUILayout.Width(GRAPH_WIDTH + 10));
            // draw graph box
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label(OrbitCalc.header[0]);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label(OrbitCalc.header[1]);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.Box(graph_texture);
            GUILayout.EndVertical();


            // draw side text
            GUILayout.BeginVertical(GUILayout.Width(wnd_width - GRAPH_WIDTH - 30));
            bool draw = false;

            if (firstTime)
            {
                firstTime = false;
                draw      = true;
            }
            // if (!PlanetSelection.isActive)
            {
                if (GUILayout.Button("Select Planet"))
                {
                    if (!PlanetSelection.isActive)
                    {
                        planetSelection = new GameObject().AddComponent <PlanetSelection>();
                    }
                    else
                    {
                        planetSelection.DestroyThis();
                    }
                }
            }

            GUILayout.BeginHorizontal();

            GUILayout.Label(new GUIContent("Number of satellites:", "Total number of satellites to arrange"));

            var newsNumSats = GUILayout.TextField(sNumSats);

            int butW = 19;

            if (GUILayout.Button(UpArrow, GUILayout.Width(butW)))
            {
                numSats++;
                sNumSats    = numSats.ToString();
                newsNumSats = sNumSats;
                draw        = true;
            }
            if (GUILayout.Button(DownArrow, GUILayout.Width(butW)))
            {
                if (numSats > 1)
                {
                    numSats--;
                }
                sNumSats    = numSats.ToString();
                newsNumSats = sNumSats;
                draw        = true;
            }
            if (sNumSats != newsNumSats)
            {
                bValidNumSats = int.TryParse(newsNumSats, out iTmp);
                if (!bValidNumSats)
                {
                    sNumSats = numSats.ToString();
                }
                else
                {
                    numSats  = iTmp;
                    sNumSats = newsNumSats;
                    draw     = true;
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();

            GUILayout.Label(new GUIContent("Altitude:", "Orbital altitude"));
            GUI.SetNextControlName("altitude");
            string newsOrbitAltitude = GUILayout.TextField(sOrbitAltitude);

            if (newsOrbitAltitude != sOrbitAltitude)
            {
                bValidOrbitAltitude = double.TryParse(newsOrbitAltitude, out dTmp);
                if (bValidOrbitAltitude)
                {
                    selectedOrbit = SelectedOrbit.None;
                    orbitAltitude = dTmp;
                }
                sOrbitAltitude = orbitAltitude.ToString("F0");
                draw           = true;
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Orbital Period: ");
            GUILayout.FlexibleSpace();

            GUI.SetNextControlName("periodHour");
            string h = GUILayout.TextField(OrbitCalc.periodHour, bh ? textStyle : textErrorStyle, GUILayout.MinWidth(25));

            GUILayout.Label("h ");
            GUI.SetNextControlName("periodMin");
            string m = GUILayout.TextField(OrbitCalc.periodMin, bm ? textStyle : textErrorStyle, GUILayout.MinWidth(25));

            GUILayout.Label("m ");
            GUI.SetNextControlName("periodSec");
            string s = GUILayout.TextField(OrbitCalc.periodSec, bs ? textStyle : textErrorStyle, GUILayout.MinWidth(25));

            GUILayout.Label("s");
            OrbitCalc.periodEntry = GUI.GetNameOfFocusedControl() == "periodHour" ||
                                    GUI.GetNameOfFocusedControl() == "periodMin" ||
                                    GUI.GetNameOfFocusedControl() == "periodSec";


            bh = Double.TryParse(h, out dh);
            bm = Double.TryParse(m, out dm);
            bs = Double.TryParse(s, out ds);
            if (h != OrbitCalc.periodHour || m != OrbitCalc.periodMin || s != OrbitCalc.periodSec)
            {
                if (bh && bm && bs)
                {
                    double T = dh * 3600 + dm * 60 + ds;

                    orbitAltitude  = OrbitCalc.satelliteorbit.a(T);
                    sOrbitAltitude = orbitAltitude.ToString("F0");
                    draw           = true;
                }
                OrbitCalc.periodHour = h;
                OrbitCalc.periodMin  = m;
                OrbitCalc.periodSec  = s;
            }

            GUILayout.EndHorizontal();


            if (OrbitCalc.synchrorbit == "" || OrbitCalc.synchrorbit == "n/a")
            {
                GUI.enabled = false;
            }
            GUILayout.BeginHorizontal();
            if (GUILayout.Toggle(synchronousOrbit, new GUIContent("Synchronous orbit (" + OrbitCalc.synchrorbit + ")", "Set the altitude to have the satellites be in a geosynchronous orbit")))
            {
                selectedOrbit = SelectedOrbit.Synchronous;

                orbitAltitude         = OrbitCalc.body.geoAlt;
                sOrbitAltitude        = orbitAltitude.ToString();
                OrbitCalc.periodEntry = false;
                draw = true;
            }
            GUILayout.EndHorizontal();
            GUI.enabled = true;
            GUILayout.Space(10);
            GUILayout.BeginHorizontal();
            if (OrbitCalc.losorbit == "" || OrbitCalc.losorbit == "n/a")
            {
                GUI.enabled = false;
            }

            if (GUILayout.Toggle(minLOSorbit, new GUIContent("Minimum LOS orbit (" + OrbitCalc.losorbit + ")", "Set the altitude to the minimum altitude possible to maintain a Line of Sight"),
                                 OrbitCalc.losOrbitWarning ? toggleMinLOSWarning : toggleMinLOSNormal))
            {
                selectedOrbit         = SelectedOrbit.MinLOS;
                orbitAltitude         = OrbitCalc.minLOS;
                sOrbitAltitude        = orbitAltitude.ToString();
                OrbitCalc.periodEntry = false;
                draw = true;
            }
            GUILayout.EndHorizontal();
            GUI.enabled = true;
            if (HighLogic.LoadedSceneIsFlight)
            {
                GUILayout.Space(10);
                GUILayout.BeginHorizontal();
                bool warning = false;
                warning = (FlightGlobals.activeTarget.orbit.ApA < FlightGlobals.ActiveVessel.mainBody.atmosphereDepth);

                if (GUILayout.Toggle(currentAp, new GUIContent("Current Ap (" + FlightGlobals.activeTarget.orbit.ApA.ToString("N0") + ")", "Set the altitude to the current vessel's Ap"),
                                     warning ? toggleMinLOSWarning : GUI.skin.toggle))
                {
                    selectedOrbit         = SelectedOrbit.Ap;
                    orbitAltitude         = Math.Round(FlightGlobals.activeTarget.orbit.ApA);
                    sOrbitAltitude        = orbitAltitude.ToString();
                    OrbitCalc.periodEntry = false;
                    draw = true;
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(10);
                GUILayout.BeginHorizontal();
                warning = (FlightGlobals.activeTarget.orbit.PeA < FlightGlobals.ActiveVessel.mainBody.atmosphereDepth);
                if (FlightGlobals.activeTarget.orbit.PeA < 1)
                {
                    GUI.enabled = false;
                }
                if (GUILayout.Toggle(currentPe, new GUIContent("Current Pe (" + FlightGlobals.activeTarget.orbit.PeA.ToString("N0") + ")", "Set the altitude to the current vessel's Pe"),
                                     OrbitCalc.losOrbitWarning ? toggleMinLOSWarning : GUI.skin.toggle))
                {
                    selectedOrbit         = SelectedOrbit.Pe;
                    orbitAltitude         = Math.Round(FlightGlobals.activeTarget.orbit.PeA);
                    sOrbitAltitude        = orbitAltitude.ToString();
                    OrbitCalc.periodEntry = false;
                    draw = true;
                }
                GUI.enabled = true;
                GUILayout.EndHorizontal();
            }

            GUILayout.Space(10);
            GUILayout.BeginHorizontal();

            bool newshowLOSlines = GUILayout.Toggle(showLOSlines, new GUIContent("Show LOS lines", "Show the Line Of Sight lines"));

            if (newshowLOSlines != showLOSlines)
            {
                draw         = true;
                showLOSlines = newshowLOSlines;
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();

            bool newocclusionModifiers = GUILayout.Toggle(occlusionModifiers, new GUIContent("Occlusion modifiers", "Enable occlusion modifiers for vacuum and atmospheres"));

            GUILayout.EndHorizontal();
            if (occlusionModifiers)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("   Atm:", "Occlusion atmospheric modifier"));
                var newsAtmOcclusion = GUILayout.TextField(sAtmOcclusion);
                if (GUILayout.Button(UpArrow, GUILayout.Width(butW)))
                {
                    if (atmOcclusion < 1.1)
                    {
                        atmOcclusion += 0.01f;
                    }
                    sAtmOcclusion    = atmOcclusion.ToString("F2");
                    newsAtmOcclusion = sAtmOcclusion;
                    draw             = true;
                }
                if (GUILayout.Button(DownArrow, GUILayout.Width(butW)))
                {
                    if (atmOcclusion > 0)
                    {
                        atmOcclusion -= 0.01f;
                    }
                    sAtmOcclusion    = atmOcclusion.ToString("F2");
                    newsAtmOcclusion = sAtmOcclusion;
                    draw             = true;
                }
                if (newsAtmOcclusion != sAtmOcclusion)
                {
                    bValidAtmOcclusion = double.TryParse(newsAtmOcclusion, out dTmp);
                    if (!bValidAtmOcclusion)
                    {
                        sAtmOcclusion = atmOcclusion.ToString("F2");
                    }
                    else
                    {
                        atmOcclusion  = dTmp;
                        sAtmOcclusion = newsAtmOcclusion;
                        draw          = true;
                    }
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("   Vac:", "Occlusion vacuum modifier"));
                var newsVacOcclusion = GUILayout.TextField(sVacOcclusion);
                if (GUILayout.Button(UpArrow, GUILayout.Width(butW)))
                {
                    if (vacOcclusion < 1.1)
                    {
                        vacOcclusion += 0.01f;
                    }
                    sVacOcclusion    = vacOcclusion.ToString("F2");
                    newsVacOcclusion = sVacOcclusion;
                    draw             = true;
                }
                if (GUILayout.Button(DownArrow, GUILayout.Width(butW)))
                {
                    if (vacOcclusion > 0)
                    {
                        vacOcclusion -= 0.01f;
                    }
                    sVacOcclusion    = vacOcclusion.ToString("F2");
                    newsVacOcclusion = sVacOcclusion;
                    draw             = true;
                }
                if (newsVacOcclusion != sVacOcclusion)
                {
                    bValidVacOcclusion = Double.TryParse(newsVacOcclusion, out dTmp);
                    if (!bValidVacOcclusion)
                    {
                        sVacOcclusion = vacOcclusion.ToString("F2");
                    }
                    else
                    {
                        vacOcclusion  = dTmp;
                        sVacOcclusion = newsVacOcclusion;
                        draw          = true;
                    }
                }
                GUILayout.EndHorizontal();
            }
            if (occlusionModifiers != newocclusionModifiers)
            {
                draw = true;
            }
            occlusionModifiers = newocclusionModifiers;

            GUILayout.Space(15);
            GUILayout.BeginHorizontal();
            GUILayout.Label("Resonant Orbit", labelResonantOrbit);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            bool newflipOrbit = GUILayout.Toggle(flipOrbit, new GUIContent("Dive orbit", "Set Carrier orbit to be lower than target orbit"));

            if (newflipOrbit != flipOrbit)
            {
                draw      = true;
                flipOrbit = newflipOrbit;
            }
            GUILayout.EndHorizontal();

            if (draw)
            {
                UpdateGraph();
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label("Orbital Period: ");
            GUILayout.Label(OrbitCalc.carrierT);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Apoapsis: ");
            GUILayout.Label(OrbitCalc.carrierAp);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Periapsis: ");

            if (OrbitCalc.carrierPe != "")
            {
                GUILayout.Label(OrbitCalc.carrierPe, OrbitCalc.carrierPeWarning ? warningLabel : normalLabel);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Injection Δv: ");
            GUILayout.Label(OrbitCalc.burnDV);
            GUILayout.EndHorizontal();

            Log.Info("LoadedSceneIsFlight: " + HighLogic.LoadedSceneIsFlight + ",    patchedConicsUnlocked: " + FlightGlobals.ActiveVessel.patchedConicsUnlocked());
            if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ActiveVessel.patchedConicsUnlocked())
            {
                GUILayout.FlexibleSpace();
                Log.Info("selectedOrbit: " + selectedOrbit);
                if (selectedOrbit == SelectedOrbit.Ap)
                {
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button(new GUIContent("Create Maneuver Node at Ap", "Creates a maneuver node to put the current vessel into the resonant orbit")))
                    {
                        Vector3d circularizeDv = VesselOrbitalCalc.CircularizeAtAP(FlightGlobals.ActiveVessel);
                        // If a flip, then  subtract
                        double UT = Planetarium.GetUniversalTime();
                        UT += FlightGlobals.ActiveVessel.orbit.timeToAp;
                        var o = FlightGlobals.ActiveVessel.orbit;
                        if (flipOrbit)
                        {
                            circularizeDv -= OrbitCalc.dBurnDV * o.Horizontal(UT);
                        }
                        else
                        {
                            circularizeDv += OrbitCalc.dBurnDV * o.Horizontal(UT);
                        }
                        FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Clear();
                        VesselOrbitalCalc.PlaceManeuverNode(FlightGlobals.ActiveVessel, FlightGlobals.ActiveVessel.orbit, circularizeDv, UT);
                    }
                    GUILayout.EndHorizontal();
                }
                if (selectedOrbit == SelectedOrbit.Pe)
                {
                    if (OrbitCalc.carrierPeWarning)
                    {
                        buttonStyle = buttonRed;
                    }
                    else
                    {
                        buttonStyle = GUI.skin.button;
                    }
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button(new GUIContent("Create Maneuver Node at Pe", "Creates a maneuver node to put the current vessel into the resonant orbit"), buttonStyle))
                    {
                        double UT = Planetarium.GetUniversalTime();
                        UT += FlightGlobals.ActiveVessel.orbit.timeToPe;
                        var      o             = FlightGlobals.ActiveVessel.orbit;
                        Vector3d circularizeDv = VesselOrbitalCalc.CircularizeAtPE(FlightGlobals.ActiveVessel);
                        // If a flip, then  subtract
                        if (flipOrbit)
                        {
                            circularizeDv -= OrbitCalc.dBurnDV * o.Horizontal(UT);
                        }
                        else
                        {
                            circularizeDv += OrbitCalc.dBurnDV * o.Horizontal(UT);
                        }
                        FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Clear();
                        VesselOrbitalCalc.PlaceManeuverNode(FlightGlobals.ActiveVessel, FlightGlobals.ActiveVessel.orbit, circularizeDv, UT);
                    }
                    GUILayout.EndHorizontal();
                }
                Log.Info("FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Count(): " + FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Count());
                if (FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Count() > 0)
                {
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button("Clear all nodes"))
                    {
                        for (int i = FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Count - 1; i >= 0; i--)
                        {
                            FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes[i].RemoveSelf();
                        }
                    }
                    GUILayout.EndHorizontal();

                    if (selectedOrbit == SelectedOrbit.Ap || selectedOrbit == SelectedOrbit.Pe)
                    {
                        if (KACWrapper.APIReady)
                        {
                            GUILayout.BeginHorizontal();
                            if (GUILayout.Button("Add alarms to KAC"))
                            {
                                double timeToOrbit = FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes[0].UT;
                                double period      = OrbitCalc.satelliteorbit.T;
                                String aID;
                                if (!ResonantOrbitCalculator.Instance.mucore.Available)
                                {
                                    aID = KACWrapper.KAC.CreateAlarm(KACWrapper.KACAPI.AlarmTypeEnum.Maneuver, "Orbital Maneuver", timeToOrbit - 60);
                                    KACWrapper.KAC.Alarms.First(z => z.ID == aID).Notes       = "Put carrier craft into resonant orbit";
                                    KACWrapper.KAC.Alarms.First(z => z.ID == aID).AlarmMargin = 60;
                                }
                                timeToOrbit += period;
                                for (int i = 0; i < numSats; i++)
                                {
                                    aID = KACWrapper.KAC.CreateAlarm(KACWrapper.KACAPI.AlarmTypeEnum.Raw, "Detachment # " + (i + 1).ToString(), timeToOrbit - 60);

                                    KACWrapper.KAC.Alarms.First(z => z.ID == aID).Notes       = "Detach satellite # " + (i + 1) + " and circularize it's orbit";
                                    KACWrapper.KAC.Alarms.First(z => z.ID == aID).AlarmMargin = 60;
                                    timeToOrbit += period;
                                }
                            }
                            GUILayout.EndHorizontal();
                        }

                        if (ResonantOrbitCalculator.Instance.mucore.Available)
                        {
                            GUILayout.BeginHorizontal();
                            if (GUILayout.Button("Execute maneuver"))
                            {
                                ResonantOrbitCalculator.Instance.mucore.ExecuteNode();
                            }
                            GUILayout.EndHorizontal();
                        }
                    }
                }
            }
            GUILayout.FlexibleSpace();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button(new GUIContent("Save Window", "Saves an image of the window to the Screenshots directory")))
            {
                saveScreen = true;
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            if (Event.current.type == EventType.Repaint && GUI.tooltip != tooltip)
            {
                tooltip = GUI.tooltip;
            }

            GUI.DragWindow();
        }
예제 #29
0
        protected override void WindowGUI(int windowID)
        {
            GUILayout.BeginVertical();

            if (core.target.PositionTargetExists)
            {
                var ASL = core.vessel.mainBody.TerrainAltitude(core.target.targetLatitude, core.target.targetLongitude);
                GUILayout.Label(Localizer.Format("#MechJeb_LandingGuidance_label1"));//Target coordinates:

                GUILayout.BeginHorizontal();
                core.target.targetLatitude.DrawEditGUI(EditableAngle.Direction.NS);
                if (GUILayout.Button("▲"))
                {
                    moveByMeter(ref core.target.targetLatitude, 10, ASL);
                }
                GUILayout.Label("10m");
                if (GUILayout.Button("▼"))
                {
                    moveByMeter(ref core.target.targetLatitude, -10, ASL);
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                core.target.targetLongitude.DrawEditGUI(EditableAngle.Direction.EW);
                if (GUILayout.Button("◄"))
                {
                    moveByMeter(ref core.target.targetLongitude, -10, ASL);
                }
                GUILayout.Label("10m");
                if (GUILayout.Button("►"))
                {
                    moveByMeter(ref core.target.targetLongitude, 10, ASL);
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("ASL: " + MuUtils.ToSI(ASL, -1, 4) + "m");
                GUILayout.Label(core.target.targetBody.GetExperimentBiomeSafe(core.target.targetLatitude, core.target.targetLongitude));
                GUILayout.EndHorizontal();
            }
            else
            {
                if (GUILayout.Button(Localizer.Format("#MechJeb_LandingGuidance_button1")))//Enter target coordinates
                {
                    core.target.SetPositionTarget(mainBody, core.target.targetLatitude, core.target.targetLongitude);
                }
            }

            if (GUILayout.Button(Localizer.Format("#MechJeb_LandingGuidance_button2")))
            {
                core.target.PickPositionTargetOnMap();                                                                        //Pick target on map
            }
            List <LandingSite> availableLandingSites = landingSites.Where(p => p.body == mainBody).ToList();

            if (availableLandingSites.Any())
            {
                GUILayout.BeginHorizontal();
                landingSiteIdx = GuiUtils.ComboBox.Box(landingSiteIdx, availableLandingSites.Select(p => p.name).ToArray(), this);
                if (GUILayout.Button("Set", GUILayout.ExpandWidth(false)))
                {
                    core.target.SetPositionTarget(mainBody, availableLandingSites[landingSiteIdx].latitude, availableLandingSites[landingSiteIdx].longitude);
                }
                GUILayout.EndHorizontal();
            }

            DrawGUITogglePredictions();

            if (core.landing != null)
            {
                GUILayout.Label(Localizer.Format("#MechJeb_LandingGuidance_label2"));//Autopilot:

                predictor.maxOrbits        = core.landing.enabled ? 0.5 : 4;
                predictor.noSkipToFreefall = !core.landing.enabled;

                if (core.landing.enabled)
                {
                    if (GUILayout.Button(Localizer.Format("#MechJeb_LandingGuidance_button3")))
                    {
                        core.landing.StopLanding();                                                                        //Abort autoland
                    }
                }
                else
                {
                    GUILayout.BeginHorizontal();
                    if (!core.target.PositionTargetExists || vessel.LandedOrSplashed)
                    {
                        GUI.enabled = false;
                    }
                    if (GUILayout.Button(Localizer.Format("#MechJeb_LandingGuidance_button4")))
                    {
                        core.landing.LandAtPositionTarget(this);                                                                        //Land at target
                    }
                    GUI.enabled = !vessel.LandedOrSplashed;
                    if (GUILayout.Button(Localizer.Format("#MechJeb_LandingGuidance_button5")))
                    {
                        core.landing.LandUntargeted(this);                                                                        //Land somewhere
                    }
                    GUI.enabled = true;
                    GUILayout.EndHorizontal();
                }

                GuiUtils.SimpleTextBox(Localizer.Format("#MechJeb_LandingGuidance_label3"), core.landing.touchdownSpeed, "m/s", 35);//Touchdown speed:

                if (core.landing != null)
                {
                    core.node.autowarp = GUILayout.Toggle(core.node.autowarp, Localizer.Format("#MechJeb_LandingGuidance_checkbox1"));             //Auto-warp
                }
                core.landing.deployGears = GUILayout.Toggle(core.landing.deployGears, Localizer.Format("#MechJeb_LandingGuidance_checkbox2"));     //Deploy Landing Gear
                GuiUtils.SimpleTextBox(Localizer.Format("#MechJeb_LandingGuidance_label4"), core.landing.limitGearsStage, "", 35);                 //"Stage Limit:"
                core.landing.deployChutes = GUILayout.Toggle(core.landing.deployChutes, Localizer.Format("#MechJeb_LandingGuidance_checkbox3"));   //Deploy Parachutes
                predictor.deployChutes    = core.landing.deployChutes;
                GuiUtils.SimpleTextBox(Localizer.Format("#MechJeb_LandingGuidance_label5"), core.landing.limitChutesStage, "", 35);                //Stage Limit:
                predictor.limitChutesStage = core.landing.limitChutesStage;
                core.landing.rcsAdjustment = GUILayout.Toggle(core.landing.rcsAdjustment, Localizer.Format("#MechJeb_LandingGuidance_checkbox4")); //Use RCS for small adjustment

                if (core.landing.enabled)
                {
                    GUILayout.Label(Localizer.Format("#MechJeb_LandingGuidance_label6") + core.landing.status);                                                                                                                                              //Status:
                    GUILayout.Label(Localizer.Format("#MechJeb_LandingGuidance_label7") + (core.landing.CurrentStep != null ? core.landing.CurrentStep.GetType().Name : "N/A"));                                                                             //Step:
                    GUILayout.Label(Localizer.Format("#MechJeb_LandingGuidance_label8") + (core.landing.descentSpeedPolicy != null ? core.landing.descentSpeedPolicy.GetType().Name : "N/A") + " (" + core.landing.UseAtmosphereToBrake().ToString() + ")"); //Mode
                    //GUILayout.Label("DecEndAlt: " + core.landing.DecelerationEndAltitude().ToString("F2"));
                    //var dragLength = mainBody.DragLength(core.landing.LandingAltitude, core.landing.vesselAverageDrag, vesselState.mass);
                    //GUILayout.Label("Drag Length: " + ( dragLength < double.MaxValue ? dragLength.ToString("F2") : "infinite"));
                    //
                    //string parachuteInfo = core.landing.ParachuteControlInfo;
                    //if (null != parachuteInfo)
                    //{
                    //    GUILayout.Label(parachuteInfo);
                    //}
                }
            }

            GUILayout.EndVertical();

            base.WindowGUI(windowID);
        }
예제 #30
0
        public void OnGUI(Rect pos)
        {
            if (clip == null)
            {
                return;
            }

            //left
            Rect rect = new Rect(pos.x + list_width, pos.y + list_height, pos.width / 2 - list_width * 2 - rect_offset, pos.height - list_height * 2);

            GUILayout.BeginArea(rect, EditorConst.WindowBackground);
            {
                if (view != null)
                {
                    view.Draw(new Rect(0, 0, rect.width, rect.height));
                    view.RefreshData(EditorTool.ToObjectList(key_point_list));
                }
            }
            GUILayout.EndArea();

            //right
            rect = new Rect(pos.width / 2 - list_width, pos.y + list_height, +pos.width / 2 - list_width * 2 - rect_offset, pos.height - list_height * 2);

            GUILayout.BeginArea(rect, EditorConst.WindowBackground);
            {
                //view.Draw(new Rect(0, 0, rect.width, rect.height));
                //view.RefreshData(EditorTool.ToObjectList(event_list));

                GUILayout.BeginVertical();

                if (clip != null)
                {
                    GUILayout.Label(" Animation Event ");

                    //basic options
                    EditorGUILayout.Space();

                    //动画文件信息
                    EditorGUILayout.LabelField("Animation Clip Name", clip.name);
                    EditorGUILayout.LabelField("Animation Clip Length", string.Format("{0} s", clip.length.ToString()));
                    EditorGUILayout.LabelField("Animation Clip Frame Rate", clip.frameRate.ToString());
                }

                if (kp != null)
                {
                    //动画事件信息
                    Action_Event_Type curr = GetActionEventTypeEnum(kp.functionName);
                    Action_Event_Type type = (Action_Event_Type)EditorGUILayout.EnumPopup("Function Type", curr);
                    if (type != curr)
                    {
                        curr            = type;
                        kp.functionName = type.ToString();
                    }
                    EditorGUILayout.LabelField("Function 描述", action_event_type_desc[(int)curr], GUILayout.MinHeight(100));


                    kp.floatParameter  = EditorGUILayout.FloatField("Float", kp.floatParameter);
                    kp.intParameter    = EditorGUILayout.IntField("Int", kp.intParameter);
                    kp.stringParameter = EditorGUILayout.TextField("String", kp.stringParameter);
                    kp.time            = EditorGUILayout.Slider("Time", kp.time, 0, clip.length);
                }

                GUILayout.BeginHorizontal();

                if (GUILayout.Button(" Add(no save) "))
                {
                    kp = new KeyPointData(Action_Event_Type.OnStartEffect.ToString(), 0, 0, null, 0.1f);

                    key_point_list.Add(kp);
                    kp_Id = key_point_list.Count - 1;
                }

                if (GUILayout.Button(" Delete "))
                {
                    if (kp == null)
                    {
                        return;
                    }

                    key_point_list.RemoveAt(kp_Id);
                    int count = key_point_list.Count;
                    event_list = new List <AnimationEvent>();
                    for (int i = 0; i < count; i++)
                    {
                        key_point_list[i].Revert();
                        AnimationEvent ae = key_point_list[i].GetAnimationEvent(clip.length);
                        event_list.Add(ae);
                    }

                    kp    = null;
                    kp_Id = 0;
                    SaveAnimationEventInfo();
                }

                if (GUILayout.Button(" Save "))
                {
                    if (kp == null ||
                        event_list.Count <= view.CurSelectIndex - 1)
                    {
                        return;
                    }

                    int count = key_point_list.Count;
                    event_list = new List <AnimationEvent>();
                    for (int i = 0; i < count; i++)
                    {
                        if (kp_Id != i)
                        {
                            key_point_list[i].Revert();
                        }
                        AnimationEvent ae = key_point_list[i].GetAnimationEvent(clip.length);
                        event_list.Add(ae);
                    }

                    SaveAnimationEventInfo();
                }

                GUILayout.EndHorizontal();

                GUILayout.EndVertical();
            }
            GUILayout.EndArea();
        }