예제 #1
0
        void LayoutButton(Action <Transform[]> layoutFucntion)
        {
            if (EditorGUI.EndChangeCheck() && _applyContinuously)
            {
                layoutFucntion(GetOrderedSelection());
            }

            EditorGUILayout.BeginVertical();
            GUILayout.FlexibleSpace();


            EditorGUILayout.BeginHorizontal();

            EditorGUI.BeginDisabledGroup(Selection.transforms.Length <= 1 || _applyContinuously);
            if (GUILayout.Button("Layout"))
            {
                layoutFucntion(GetOrderedSelection());
            }
            EditorGUI.EndDisabledGroup();

            EditorGUI.BeginChangeCheck();
            _applyContinuously = EditorGUILayout.ToggleLeft("AUTO", _applyContinuously, GUILayout.Width(50));
            if (EditorGUI.EndChangeCheck() && _applyContinuously)
            {
                layoutFucntion(GetOrderedSelection());
            }

            EditorGUILayout.EndHorizontal();



            EditorGUILayout.EndVertical();
        }
    void OnGUI()
    {
        EGL.LabelField("Generated texture", EditorStyles.boldLabel);

        EGL.LabelField("Show channels:");
        EGL.BeginHorizontal();
        _c[3] = GUILayout.Toggle(_c[3], "A");
        EG.BeginDisabledGroup(_c[3]);
        _c[0] = GUILayout.Toggle(_c[0], "R");
        _c[1] = GUILayout.Toggle(_c[1], "G");
        _c[2] = GUILayout.Toggle(_c[2], "B");
        EG.EndDisabledGroup();
        EGL.EndHorizontal();

        EGL.LabelField("Zoom");
        zoom = EGL.Slider(zoom, 0.2f, 3f);

        EGL.LabelField("Slice");
        slice = EGL.Slider(slice, 0f, 1f);

        Rect r_tex = EGL.BeginVertical(GUILayout.ExpandHeight(true));

        r_tex.height = r_tex.width = Mathf.Min(r_tex.height, r_tex.width);
        if (texture)
        {
            previewMaterial.SetFloat("_Zoom", zoom);
            previewMaterial.SetFloat("_Slice", slice);
            previewMaterial.SetVector("_Channels", ChannelVector());
            EG.DrawPreviewTexture(r_tex, texture, previewMaterial);
        }
        EGL.EndVertical();
    }
예제 #3
0
        internal static void ErrorMessage(Rect position, GUIContent label, PropertyAttribute customVector, string compatibleTypes)
        {
            string customVectorTypeName = customVector.GetType().Name;
            string attributeText        = "Attribute";
            int    attributeIndex       = customVectorTypeName.IndexOf(attributeText);
            string customVectorName     = customVectorTypeName.Remove(attributeIndex);

            EditorGUIUnity.LabelField(position, label.text, "Use " + customVectorName + " with " + compatibleTypes + ".");
        }
예제 #4
0
        void RadialTab()
        {
            _plane = (Plane)EditorGUILayout.EnumPopup("Plane", _plane);
            _space = (Space)EditorGUILayout.EnumPopup("Space", _space);

            _totalAngle     = EditorGUILayout.FloatField("Total Angle", _totalAngle);
            _inclusiveAngle = EditorGUILayout.Toggle("Inclusive Angle", _inclusiveAngle);

            _radius = EditorGUILayout.FloatField("Radius", _radius);

            _elementRotation = (ElementRotation)EditorGUILayout.EnumPopup("Rotate Elements", _elementRotation);

            EditorGUI.BeginDisabledGroup(_elementRotation == ElementRotation.DontRotate);
            EditorGUIUtility.wideMode = true;
            _rotationOffset           = EditorGUILayout.Vector3Field("Rotation Offset", _rotationOffset);
            EditorGUIUtility.wideMode = false;
            EditorGUI.EndDisabledGroup();

            LayoutButton(RadialLayout);
        }
예제 #5
0
    void showBuildingGUI()
    {
        EG.BeginDisabledGroup(!roadMeshGenerated);
        // General Terrain Settings
        showBuildingUI = EGL.Foldout(showBuildingUI, buildingLabel, true);
        if (showBuildingUI)
        {
            /*if (GL.Button("Generate blocks"))
             * {
             * generator.generateBlocks();
             * }*/

            if (GL.Button("Generate Buildings"))
            {
                generator.generateBuildings();
                buildingLabel = "5. Building Generation - COMPLETED ✔";
            }
            CG.generateWindows = EGL.ToggleLeft("Generate Windows", CG.generateWindows);
        }
        EG.EndDisabledGroup();
    }
예제 #6
0
        void OnGUI()
        {
            EditorGUI.BeginChangeCheck();
            _tab = (Tab)GUILayout.Toolbar((int)_tab, Enum.GetNames(typeof(Tab)));
            if (EditorGUI.EndChangeCheck())
            {
                _applyContinuously = false;
            }

            EditorGUILayout.Space();

            EditorGUI.BeginChangeCheck();

            switch (_tab)
            {
            case Tab.Line: LineTab(); break;

            case Tab.Grid: GridTab(); break;

            case Tab.Radial: RadialTab(); break;
            }
        }
예제 #7
0
 internal static string DoTextField(EditorGUI.RecycledTextEditor editor, int id, Rect position, string text, GUIStyle style, string allowedletters, out bool changed, bool reset, bool multiline, bool passwordField)
 {
   Event current = Event.current;
   string str1 = text;
   if (text == null)
     text = string.Empty;
   if (EditorGUI.showMixedValue)
     text = string.Empty;
   if (EditorGUI.HasKeyboardFocus(id) && Event.current.type != EventType.Layout)
   {
     if (editor.IsEditingControl(id))
     {
       editor.position = position;
       editor.style = style;
       editor.controlID = id;
       editor.multiline = multiline;
       editor.isPasswordField = passwordField;
       editor.DetectFocusChange();
     }
     else if (EditorGUIUtility.editingTextField)
     {
       editor.BeginEditing(id, text, position, style, multiline, passwordField);
       if ((double) GUI.skin.settings.cursorColor.a > 0.0)
         editor.SelectAll();
     }
   }
   if (editor.controlID == id && GUIUtility.keyboardControl != id)
     editor.controlID = 0;
   bool flag1 = false;
   string text1 = editor.text;
   EventType typeForControl = current.GetTypeForControl(id);
   switch (typeForControl)
   {
     case EventType.MouseDown:
       if (position.Contains(current.mousePosition) && current.button == 0)
       {
         if (editor.IsEditingControl(id))
         {
           if (Event.current.clickCount == 2 && GUI.skin.settings.doubleClickSelectsWord)
           {
             editor.MoveCursorToPosition(Event.current.mousePosition);
             editor.SelectCurrentWord();
             editor.MouseDragSelectsWholeWords(true);
             editor.DblClickSnap(TextEditor.DblClickSnapping.WORDS);
             EditorGUI.s_DragToPosition = false;
           }
           else if (Event.current.clickCount == 3 && GUI.skin.settings.tripleClickSelectsLine)
           {
             editor.MoveCursorToPosition(Event.current.mousePosition);
             editor.SelectCurrentParagraph();
             editor.MouseDragSelectsWholeWords(true);
             editor.DblClickSnap(TextEditor.DblClickSnapping.PARAGRAPHS);
             EditorGUI.s_DragToPosition = false;
           }
           else
           {
             editor.MoveCursorToPosition(Event.current.mousePosition);
             EditorGUI.s_SelectAllOnMouseUp = false;
           }
         }
         else
         {
           GUIUtility.keyboardControl = id;
           editor.BeginEditing(id, text, position, style, multiline, passwordField);
           editor.MoveCursorToPosition(Event.current.mousePosition);
           if ((double) GUI.skin.settings.cursorColor.a > 0.0)
             EditorGUI.s_SelectAllOnMouseUp = true;
         }
         GUIUtility.hotControl = id;
         current.Use();
         break;
       }
       break;
     case EventType.MouseUp:
       if (GUIUtility.hotControl == id)
       {
         if (EditorGUI.s_Dragged && EditorGUI.s_DragToPosition)
         {
           editor.MoveSelectionToAltCursor();
           flag1 = true;
         }
         else if (EditorGUI.s_PostPoneMove)
           editor.MoveCursorToPosition(Event.current.mousePosition);
         else if (EditorGUI.s_SelectAllOnMouseUp)
         {
           if ((double) GUI.skin.settings.cursorColor.a > 0.0)
             editor.SelectAll();
           EditorGUI.s_SelectAllOnMouseUp = false;
         }
         editor.MouseDragSelectsWholeWords(false);
         EditorGUI.s_DragToPosition = true;
         EditorGUI.s_Dragged = false;
         EditorGUI.s_PostPoneMove = false;
         if (current.button == 0)
         {
           GUIUtility.hotControl = 0;
           current.Use();
           break;
         }
         break;
       }
       break;
     case EventType.MouseDrag:
       if (GUIUtility.hotControl == id)
       {
         if (!current.shift && editor.hasSelection && EditorGUI.s_DragToPosition)
         {
           editor.MoveAltCursorToPosition(Event.current.mousePosition);
         }
         else
         {
           if (current.shift)
             editor.MoveCursorToPosition(Event.current.mousePosition);
           else
             editor.SelectToPosition(Event.current.mousePosition);
           EditorGUI.s_DragToPosition = false;
           EditorGUI.s_SelectAllOnMouseUp = !editor.hasSelection;
         }
         EditorGUI.s_Dragged = true;
         current.Use();
         break;
       }
       break;
     case EventType.KeyDown:
       if (GUIUtility.keyboardControl == id)
       {
         char character = current.character;
         if (editor.IsEditingControl(id) && editor.HandleKeyEvent(current))
         {
           current.Use();
           flag1 = true;
           break;
         }
         if (current.keyCode == KeyCode.Escape)
         {
           if (editor.IsEditingControl(id))
           {
             if (style == EditorStyles.toolbarSearchField || style == EditorStyles.searchField)
               EditorGUI.s_OriginalText = string.Empty;
             editor.text = EditorGUI.s_OriginalText;
             editor.EndEditing();
             flag1 = true;
             break;
           }
           break;
         }
         if ((int) character == 10 || (int) character == 3)
         {
           if (!editor.IsEditingControl(id))
           {
             editor.BeginEditing(id, text, position, style, multiline, passwordField);
             editor.SelectAll();
           }
           else if (!multiline || current.alt || (current.shift || current.control))
           {
             editor.EndEditing();
           }
           else
           {
             editor.Insert(character);
             flag1 = true;
             break;
           }
           current.Use();
           break;
         }
         if ((int) character == 9 || current.keyCode == KeyCode.Tab)
         {
           if (multiline && editor.IsEditingControl(id))
           {
             bool flag2 = allowedletters == null || allowedletters.IndexOf(character) != -1;
             if (!current.alt && !current.shift && !current.control && (int) character == 9 && flag2)
             {
               editor.Insert(character);
               flag1 = true;
               break;
             }
             break;
           }
           break;
         }
         if ((int) character != 25 && (int) character != 27 && editor.IsEditingControl(id))
         {
           if ((allowedletters == null || allowedletters.IndexOf(character) != -1) && (int) character != 0)
           {
             editor.Insert(character);
             flag1 = true;
             break;
           }
           if (Input.compositionString != string.Empty)
           {
             editor.ReplaceSelection(string.Empty);
             flag1 = true;
           }
           current.Use();
           break;
         }
         break;
       }
       break;
     case EventType.Repaint:
       string str2 = !editor.IsEditingControl(id) ? (!EditorGUI.showMixedValue ? (!passwordField ? text : string.Empty.PadRight(text.Length, '*')) : EditorGUI.s_MixedValueContent.text) : (!passwordField ? editor.text : string.Empty.PadRight(editor.text.Length, '*'));
       if (!string.IsNullOrEmpty(EditorGUI.s_UnitString) && !passwordField)
         str2 = str2 + " " + EditorGUI.s_UnitString;
       if (GUIUtility.hotControl == 0)
         EditorGUIUtility.AddCursorRect(position, MouseCursor.Text);
       if (!editor.IsEditingControl(id))
       {
         EditorGUI.BeginHandleMixedValueContentColor();
         style.Draw(position, EditorGUIUtility.TempContent(str2), id, false);
         EditorGUI.EndHandleMixedValueContentColor();
         break;
       }
       editor.DrawCursor(str2);
       break;
     default:
       switch (typeForControl - 13)
       {
         case EventType.MouseDown:
           if (GUIUtility.keyboardControl == id)
           {
             string commandName = current.commandName;
             if (commandName != null)
             {
               // ISSUE: reference to a compiler-generated field
               if (EditorGUI.\u003C\u003Ef__switch\u0024map0 == null)
               {
                 // ISSUE: reference to a compiler-generated field
                 EditorGUI.\u003C\u003Ef__switch\u0024map0 = new Dictionary<string, int>(6)
                 {
                   {
                     "Cut",
                     0
                   },
                   {
                     "Copy",
                     0
                   },
                   {
                     "Paste",
                     1
                   },
                   {
                     "SelectAll",
                     2
                   },
                   {
                     "UndoRedoPerformed",
                     3
                   },
                   {
                     "Delete",
                     4
                   }
                 };
               }
               int num;
               // ISSUE: reference to a compiler-generated field
               if (EditorGUI.\u003C\u003Ef__switch\u0024map0.TryGetValue(commandName, out num))
               {
                 switch (num)
                 {
                   case 0:
                     if (editor.hasSelection)
                     {
                       current.Use();
                       break;
                     }
                     break;
                   case 1:
                     if (editor.CanPaste())
                     {
                       current.Use();
                       break;
                     }
                     break;
                   case 2:
                     current.Use();
                     break;
                   case 3:
                     editor.text = text;
                     current.Use();
                     break;
                   case 4:
                     current.Use();
                     break;
                 }
               }
               else
                 break;
             }
             else
               break;
           }
           else
             break;
         case EventType.MouseUp:
           if (GUIUtility.keyboardControl == id)
           {
             string commandName = current.commandName;
             if (commandName != null)
             {
               // ISSUE: reference to a compiler-generated field
               if (EditorGUI.\u003C\u003Ef__switch\u0024map1 == null)
               {
                 // ISSUE: reference to a compiler-generated field
                 EditorGUI.\u003C\u003Ef__switch\u0024map1 = new Dictionary<string, int>(6)
                 {
                   {
                     "OnLostFocus",
                     0
                   },
                   {
                     "Cut",
                     1
                   },
                   {
                     "Copy",
                     2
                   },
                   {
                     "Paste",
                     3
                   },
                   {
                     "SelectAll",
                     4
                   },
                   {
                     "Delete",
                     5
                   }
                 };
               }
               int num;
               // ISSUE: reference to a compiler-generated field
               if (EditorGUI.\u003C\u003Ef__switch\u0024map1.TryGetValue(commandName, out num))
               {
                 switch (num)
                 {
                   case 0:
                     if (EditorGUI.activeEditor != null)
                       EditorGUI.activeEditor.EndEditing();
                     current.Use();
                     break;
                   case 1:
                     editor.BeginEditing(id, text, position, style, multiline, passwordField);
                     editor.Cut();
                     flag1 = true;
                     break;
                   case 2:
                     editor.Copy();
                     current.Use();
                     break;
                   case 3:
                     editor.BeginEditing(id, text, position, style, multiline, passwordField);
                     editor.Paste();
                     flag1 = true;
                     break;
                   case 4:
                     editor.SelectAll();
                     current.Use();
                     break;
                   case 5:
                     editor.BeginEditing(id, text, position, style, multiline, passwordField);
                     if (Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.OSXWebPlayer || (Application.platform == RuntimePlatform.OSXDashboardPlayer || Application.platform == RuntimePlatform.OSXEditor) || Application.platform == RuntimePlatform.WebGLPlayer && SystemInfo.operatingSystem.StartsWith("Mac"))
                       editor.Delete();
                     else
                       editor.Cut();
                     flag1 = true;
                     current.Use();
                     break;
                 }
               }
               else
                 break;
             }
             else
               break;
           }
           else
             break;
         case EventType.MouseDrag:
           if (position.Contains(current.mousePosition))
           {
             if (!editor.IsEditingControl(id))
             {
               GUIUtility.keyboardControl = id;
               editor.BeginEditing(id, text, position, style, multiline, passwordField);
               editor.MoveCursorToPosition(Event.current.mousePosition);
             }
             EditorGUI.ShowTextEditorPopupMenu();
             Event.current.Use();
             break;
           }
           break;
       }
   }
   if (GUIUtility.keyboardControl == id)
     GUIUtility.textFieldInput = true;
   editor.UpdateScrollOffsetIfNeeded();
   changed = false;
   if (flag1)
   {
     changed = text1 != editor.text;
     current.Use();
   }
   if (changed)
   {
     GUI.changed = true;
     return editor.text;
   }
   EditorGUI.RecycledTextEditor.s_AllowContextCutOrPaste = true;
   return str1;
 }
예제 #8
0
		internal static void VUMeterHorizontal(float value, ref EditorGUI.VUMeter.SmoothingData data, params GUILayoutOption[] options)
		{
			Rect position = EditorGUILayout.s_LastRect = EditorGUILayout.GetControlRect(false, 16f, EditorStyles.numberField, options);
			EditorGUI.VUMeter.HorizontalMeter(position, value, ref data, EditorGUI.VUMeter.horizontalVUTexture, Color.grey);
		}
예제 #9
0
    void showGrowthMapGUI()
    {
        EG.BeginDisabledGroup(!(terrainGenerated));
        showGrowthUI = EGL.Foldout(showGrowthUI, growthLabel, true);
        if (showGrowthUI)
        {
            GL.BeginVertical();

            GL.BeginHorizontal();
            GL.BeginVertical();
            if (GL.Button("Basic Rule"))
            {
                CG.growthBasic   = 1;
                CG.growthNewYork = 0;
                CG.growthParis   = 0;
            }
            if (GL.Button("New York Rule"))
            {
                CG.growthNewYork = 1;
                CG.growthBasic   = 0;
                CG.growthParis   = 0;
            }
            if (GL.Button("Paris Rule"))
            {
                CG.growthParis   = 1;
                CG.growthBasic   = 0;
                CG.growthNewYork = 0;
            }
            GL.EndVertical();
            GL.BeginVertical();
            GL.Space(1);
            CG.growthBasic = EGL.Slider(1 - CG.growthNewYork - CG.growthParis, 0, 1);
            GL.Space(1);
            CG.growthNewYork = EGL.Slider(1 - CG.growthBasic - CG.growthParis, 0, 1);
            GL.Space(1);
            CG.growthParis = EGL.Slider(1 - CG.growthBasic - CG.growthNewYork, 0, 1);
            GL.EndVertical();
            GL.EndHorizontal();
            GL.Space(1);

            if (GL.Button("Default"))
            {
                CG.growthParis   = 1f / 3f;
                CG.growthBasic   = 1f / 3f;
                CG.growthNewYork = 1f / 3f;
            }

            GL.BeginHorizontal("box");
            GL.BeginVertical();
            GL.Label("Octaves");
            GL.Label("Persistance");
            GL.Label("Zoom");
            GL.Label("Seed");
            GL.EndVertical();

            GL.BeginVertical();
            CG.growthOctaves     = EGL.IntSlider(CG.growthOctaves, 1, 6);
            CG.growthPersistance = EGL.Slider(CG.growthPersistance, 0, 0.7f);
            CG.growthZoom        = EGL.Slider(CG.growthZoom, 0, 0.05f);
            GL.BeginHorizontal();
            EG.BeginDisabledGroup(rGrowthSeed.target == false);
            CG.growthSeed = EGL.IntSlider(CG.growthSeed, 0, int.MaxValue);
            EG.EndDisabledGroup();
            rGrowthSeed.target = EGL.Toggle(rGrowthSeed.target);
            GL.EndHorizontal();

            GL.Space(20);

            GL.BeginHorizontal();
            GL.Label("Or import your growth-rule map: ");
            CG.growthMapInput = (Texture2D)EGL.ObjectField(CG.growthMapInput, typeof(Texture2D), false);
            GL.EndHorizontal();
            GL.EndVertical();

            GL.EndHorizontal();
            GL.EndVertical();

            GL.BeginHorizontal();
            if (GL.Button("Generate Growth Map"))
            {
                if (rGrowthSeed.target == false && CG.growthMapInput == null)
                {
                    CG.growthSeed = Random.Range(0, int.MaxValue);
                }
                generator.generateGrowthRule();
                isGrowthMap   = true;
                CG.showGrowth = true;
            }

            EG.BeginDisabledGroup(!isGrowthMap);
            GL.BeginHorizontal();
            GL.FlexibleSpace();
            CG.showGrowth = EGL.ToggleLeft("Preview Growth Map", CG.showGrowth);
            GL.FlexibleSpace();
            GL.EndHorizontal();
            GL.EndHorizontal();

            if (GL.Button("Save and Proceed"))
            {
                growthMapGenerated = true;
                growthLabel        = "3. Growth Map Generation - COMPLETED ✔";
                showGrowthUI       = false;
                CG.showGrowth      = false;
                showRoadMapUI      = true;
            }
            EG.EndDisabledGroup();
        }
        EG.EndDisabledGroup();
    }
예제 #10
0
        internal static void CreateCustomVectorField(Rect position, SerializedProperty property, GUIContent label, PropertyAttribute attribute)
        {
            CustomVector4Attribute customVector = (CustomVector4Attribute)attribute;

            label = CustomVectorUtils.GetLabel(label, customVector.label);

            if (property.propertyType == SerializedPropertyType.Vector4)
            {
                string  foldoutLabel = label.text;
                Vector4 v4Value      = property.vector4Value;

                float fieldHeight         = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                int   rows                = EditorGUIUtility.wideMode ? 1 : 2;
                float foldoutFieldsHeight = EditorGUIUnity.GetPropertyHeight(property) - (fieldHeight * rows);

                Rect foldoutPos = position;
                foldoutPos.y -= foldoutFieldsHeight / 2;

                property.isExpanded = EditorGUIUnity.Foldout(foldoutPos, property.isExpanded, foldoutLabel);

                if (property.isExpanded)
                {
                    GUIContent[] subLabels = new GUIContent[]
                    {
                        EditorGUIUtility.TrTextContent(customVector.xLabel),
                        EditorGUIUtility.TrTextContent(customVector.yLabel),
                        EditorGUIUtility.TrTextContent(customVector.zLabel),
                        EditorGUIUtility.TrTextContent(customVector.wLabel)
                    };

                    float[] values = new float[]
                    {
                        v4Value.x,
                        v4Value.y,
                        v4Value.z,
                        v4Value.w
                    };

                    float spacing = EditorGUIUtility.wideMode ? 0 : EditorGUIUtility.singleLineHeight + 1;
                    position.y     += EditorGUIUtility.standardVerticalSpacing + spacing;
                    position.height = EditorGUIUtility.singleLineHeight;

                    using (var check = new EditorGUIUnity.ChangeCheckScope())
                    {
                        float oldLabelWidth  = EditorGUIUtility.labelWidth;
                        int   oldIndentLevel = EditorGUIUnity.indentLevel;
                        EditorGUIUnity.indentLevel = 1;

                        for (int i = 0; i < values.Length; i++)
                        {
                            position.y += fieldHeight;
                            values[i]   = EditorGUIUnity.FloatField(position, subLabels[i], values[i]);
                        }

                        EditorGUIUtility.labelWidth = oldLabelWidth;
                        EditorGUIUnity.indentLevel  = oldIndentLevel;

                        if (check.changed)
                        {
                            v4Value.x = values[0];
                            v4Value.y = values[1];
                            v4Value.z = values[2];
                            v4Value.w = values[3];
                        }
                    }
                }

                property.vector4Value = v4Value;
            }
            else
            {
                CustomVectorUtils.ErrorMessage(position, label, customVector, "Vector4");
            }
        }
예제 #11
0
 internal static UnityEngine.Object DoDropField(Rect position, int id, System.Type objType, EditorGUI.ObjectFieldValidator validator, bool allowSceneObjects, GUIStyle style)
 {
   if (validator == null)
     validator = new EditorGUI.ObjectFieldValidator(EditorGUI.ValidateObjectFieldAssignment);
   EventType eventType1 = Event.current.type;
   if (!GUI.enabled && GUIClip.enabled && Event.current.rawType == EventType.MouseDown)
     eventType1 = Event.current.rawType;
   EventType eventType2 = eventType1;
   switch (eventType2)
   {
     case EventType.Repaint:
       style.Draw(position, GUIContent.none, id, DragAndDrop.activeControlID == id);
       break;
     case EventType.DragUpdated:
     case EventType.DragPerform:
       if (position.Contains(Event.current.mousePosition) && GUI.enabled)
       {
         UnityEngine.Object[] objectReferences = DragAndDrop.objectReferences;
         UnityEngine.Object target = validator(objectReferences, objType, (SerializedProperty) null);
         if (target != (UnityEngine.Object) null && !allowSceneObjects && !EditorUtility.IsPersistent(target))
           target = (UnityEngine.Object) null;
         if (target != (UnityEngine.Object) null)
         {
           DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
           if (eventType1 == EventType.DragPerform)
           {
             GUI.changed = true;
             DragAndDrop.AcceptDrag();
             DragAndDrop.activeControlID = 0;
             Event.current.Use();
             return target;
           }
           DragAndDrop.activeControlID = id;
           Event.current.Use();
           break;
         }
         break;
       }
       break;
     default:
       if (eventType2 == EventType.DragExited && GUI.enabled)
       {
         HandleUtility.Repaint();
         break;
       }
       break;
   }
   return (UnityEngine.Object) null;
 }
예제 #12
0
 internal static void DoNumberField(EditorGUI.RecycledTextEditor editor, Rect position, Rect dragHotZone, int id, bool isDouble, ref double doubleVal, ref long longVal, string formatString, GUIStyle style, bool draggable, double dragSensitivity)
 {
   string allowedletters = !isDouble ? EditorGUI.s_AllowedCharactersForInt : EditorGUI.s_AllowedCharactersForFloat;
   if (draggable)
     EditorGUI.DragNumberValue(editor, position, dragHotZone, id, isDouble, ref doubleVal, ref longVal, formatString, style, dragSensitivity);
   Event current = Event.current;
   string text;
   if (EditorGUI.HasKeyboardFocus(id) || current.type == EventType.MouseDown && current.button == 0 && position.Contains(current.mousePosition))
   {
     if (!editor.IsEditingControl(id))
     {
       text = EditorGUI.s_RecycledCurrentEditingString = !isDouble ? longVal.ToString(formatString) : doubleVal.ToString(formatString);
     }
     else
     {
       text = EditorGUI.s_RecycledCurrentEditingString;
       if (current.type == EventType.ValidateCommand && current.commandName == "UndoRedoPerformed")
         text = !isDouble ? longVal.ToString(formatString) : doubleVal.ToString(formatString);
     }
   }
   else
     text = !isDouble ? longVal.ToString(formatString) : doubleVal.ToString(formatString);
   if (GUIUtility.keyboardControl == id)
   {
     bool changed;
     string str1 = EditorGUI.DoTextField(editor, id, position, text, style, allowedletters, out changed, false, false, false);
     if (!changed)
       return;
     GUI.changed = true;
     EditorGUI.s_RecycledCurrentEditingString = str1;
     if (isDouble)
     {
       string lower = str1.ToLower();
       if (lower == "inf" || lower == "infinity")
         doubleVal = double.PositiveInfinity;
       else if (lower == "-inf" || lower == "-infinity")
       {
         doubleVal = double.NegativeInfinity;
       }
       else
       {
         string str2 = str1.Replace(',', '.');
         if (!double.TryParse(str2, NumberStyles.Float, (IFormatProvider) CultureInfo.InvariantCulture.NumberFormat, out doubleVal))
         {
           doubleVal = EditorGUI.s_RecycledCurrentEditingFloat = ExpressionEvaluator.Evaluate<double>(str2);
         }
         else
         {
           if (double.IsNaN(doubleVal))
             doubleVal = 0.0;
           EditorGUI.s_RecycledCurrentEditingFloat = doubleVal;
         }
       }
     }
     else if (!long.TryParse(str1, out longVal))
       longVal = EditorGUI.s_RecycledCurrentEditingInt = ExpressionEvaluator.Evaluate<long>(str1);
     else
       EditorGUI.s_RecycledCurrentEditingInt = longVal;
   }
   else
   {
     bool changed;
     EditorGUI.DoTextField(editor, id, position, text, style, allowedletters, out changed, false, false, false);
   }
 }
예제 #13
0
 public virtual void OnGUI(Rect position, SerializedProperty property, GUIContent label)
 {
     EditorGUI.DefaultPropertyField(position, property, label);
     EditorGUI.LabelField(position, label, EditorGUIUtility.TempContent("No GUI Implemented"));
 }
예제 #14
0
        protected void OnRenderTextureGUI(GUIElements guiElements)
        {
            GUI.changed = false;

            bool isTexture3D = (m_Dimension.intValue == (int)UnityEngine.Rendering.TextureDimension.Tex3D);

            EditorGUILayout.IntPopup(m_Dimension, styles.dimensionStrings, styles.dimensionValues, styles.dimension);

            GUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel(styles.size, EditorStyles.popup);
            EditorGUILayout.DelayedIntField(m_Width, GUIContent.none, GUILayout.MinWidth(40));
            GUILayout.Label(styles.cross);
            EditorGUILayout.DelayedIntField(m_Height, GUIContent.none, GUILayout.MinWidth(40));
            if (isTexture3D)
            {
                GUILayout.Label(styles.cross);
                EditorGUILayout.DelayedIntField(m_Depth, GUIContent.none, GUILayout.MinWidth(40));
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            if ((guiElements & GUIElements.RenderTargetAAGUI) != 0)
            {
                EditorGUILayout.IntPopup(m_AntiAliasing, styles.renderTextureAntiAliasing, styles.renderTextureAntiAliasingValues, styles.antiAliasing);
            }

            GraphicsFormat format           = (GraphicsFormat)m_ColorFormat.intValue;
            GraphicsFormat compatibleFormat = SystemInfo.GetCompatibleFormat(format, FormatUsage.Render);

            using (new EditorGUI.DisabledScope(compatibleFormat == GraphicsFormat.None))
                EditorGUILayout.PropertyField(m_EnableCompatibleFormat, styles.enableCompatibleFormat);

            EditorGUILayout.PropertyField(m_ColorFormat, styles.colorFormat);

            if (compatibleFormat != format)
            {
                string text = string.Format("Format {0} is not supported on this platform. ", format.ToString());
                if (compatibleFormat != GraphicsFormat.None)
                {
                    if (m_EnableCompatibleFormat.boolValue)
                    {
                        text += string.Format("Using {0} as a compatible format.", compatibleFormat.ToString());
                    }
                    else
                    {
                        text += string.Format("You may enable Compatible Color Format to fallback automatically to a platform specific compatible format, {0} on this device.", compatibleFormat.ToString());
                    }
                }
                EditorGUILayout.HelpBox(text, m_EnableCompatibleFormat.boolValue && compatibleFormat != GraphicsFormat.None ? MessageType.Warning : MessageType.Error);
            }

            if ((guiElements & GUIElements.RenderTargetDepthGUI) != 0)
            {
                EditorGUILayout.PropertyField(m_DepthFormat, styles.depthBuffer);
            }

            m_sRGB.boolValue = GraphicsFormatUtility.IsSRGBFormat(format);

            using (new EditorGUI.DisabledScope(isTexture3D))
            {
                EditorGUILayout.PropertyField(m_EnableMipmaps, styles.enableMipmaps);
                using (new EditorGUI.DisabledScope(!m_EnableMipmaps.boolValue))
                    EditorGUILayout.PropertyField(m_AutoGeneratesMipmaps, styles.autoGeneratesMipmaps);
            }

            if (isTexture3D)
            {
                // Mip map generation is not supported yet for 3D textures.
                EditorGUILayout.HelpBox("3D RenderTextures do not support Mip Maps.", MessageType.Info);
            }

            EditorGUILayout.PropertyField(m_UseDynamicScale, styles.useDynamicScale);

            var rt = target as RenderTexture;

            if (GUI.changed && rt != null)
            {
                rt.Release();
            }

            EditorGUILayout.Space();

            EditorGUI.BeginChangeCheck();
            DoWrapModePopup();
            DoFilterModePopup();

            using (new EditorGUI.DisabledScope(RenderTextureHasDepth())) // Render Textures with depth are forced to 0 Aniso Level
            {
                DoAnisoLevelSlider();
            }
            if (RenderTextureHasDepth())
            {
                // RenderTextures don't enforce this nicely. RenderTexture only forces Aniso to 0 if the gfx card
                // supports depth, rather than forcing Aniso to zero depending on what the user asks of the RT. If the
                // user requests any kind of depth then we will force aniso to zero here.
                m_Aniso.intValue = 0;
                EditorGUILayout.HelpBox("RenderTextures with depth must have an Aniso Level of 0.", MessageType.Info);
            }

            if (EditorGUI.EndChangeCheck())
            {
                ApplySettingsToTextures();
            }
        }
예제 #15
0
        void DrawCall(Rect rect, int index, bool isactive, bool isfocused)
        {
            var propCall = _callsProp.GetArrayElementAtIndex(index);

            rect.height = lineHeight;
            rect.y     += verticalSpacing;

            Rect functionRect = rect;
            Rect argRect      = rect;

            argRect.xMin += 5;
            argRect.y    += lineHeight + verticalSpacing;

            var propTarget     = propCall.FindPropertyRelative(targetPath);
            var propMethodName = propCall.FindPropertyRelative(methodNamePath);
            var propModes      = propCall.FindPropertyRelative(modesPath);
            var propArgument   = propCall.FindPropertyRelative(argumentPath);
            var targetObject   = propTarget.objectReferenceValue;


            Color c = GUI.backgroundColor;

            GUI.backgroundColor = Color.white;

            if (targetObject != null && !string.IsNullOrEmpty(propMethodName.stringValue))
            {
                EditorGUI.PropertyField(argRect, propArgument, GUIContent.none);
            }

            using (new EditorGUI.DisabledScope(targetObject == null))
            {
                EditorGUI.BeginProperty(functionRect, GUIContent.none, propMethodName);
                {
                    var buttonLabel = new StringBuilder();
                    if (targetObject == null)
                    {
                        buttonLabel.Append(strNoBinding);
                    }
                    else
                    {
                        if (_targetGameObject != (targetObject is Component ? (targetObject as Component).gameObject : targetObject))
                        {
                            buttonLabel.Append("<Missing>");
                        }
                        buttonLabel.Append(targetObject.GetType().Name);

                        if (!string.IsNullOrEmpty(propMethodName.stringValue))
                        {
                            var modeCount = propModes.arraySize;
                            var args      = new StringBuilder();
                            var types     = new Type[modeCount];
                            for (var i = 0; i < modeCount; ++i)
                            {
                                types[i] = Mode2Type((PersistentListenerMode)propModes.GetArrayElementAtIndex(i).enumValueIndex);
                                args.Append(GetTypeName(types[i]));
                                if (i < modeCount - 1)
                                {
                                    args.Append(", ");
                                }
                            }
                            buttonLabel.Append(".");
                            MethodInfo methodInfo = null;
                            if (_targetGameObject == targetObject is Component ? (targetObject as Component).gameObject : targetObject)
                            {
                                methodInfo = UnityEventBase.GetValidMethodInfo(targetObject, propMethodName.stringValue, types);
                            }
                            if (methodInfo == null)
                            {
                                buttonLabel.Append("<Missing>");
                            }
                            else if (string.IsNullOrEmpty(propArgument.stringValue))
                            {
                                GUI.Label(argRect, GetMethodParameters(methodInfo), EditorStyles.centeredGreyMiniLabel);
                            }
                            if (propMethodName.stringValue.StartsWith("set_"))
                            {
                                buttonLabel.Append(string.Format("{0} : {1}", propMethodName.stringValue.Substring(4), args.ToString()));
                            }
                            else
                            {
                                buttonLabel.Append(string.Format("{0} ({1})", propMethodName.stringValue, args.ToString()));
                            }
                        }
                    }

                    if (GUI.Button(functionRect, buttonLabel.ToString(), EditorStyles.popup))
                    {
                        BuildPopupList(_targetGameObject, propCall).DropDown(functionRect);
                    }
                }
                EditorGUI.EndProperty();
            }
            GUI.backgroundColor = c;
        }
            public static int DragReorder(Rect position, int elementHeight, List <MonoScript> elements, DrawElementDelegate drawElementDelegate)
            {
                int id = GUIUtility.GetControlID(s_DragReorderGUIHash, FocusType.Passive);

                Rect elementRect = position;

                elementRect.height = elementHeight;

                int  defPos = 0;
                Rect defRect;

                // If we're dragging, draw elements based on their animated reordering positions,
                // but only for repainting. Control event handling does't like to suddenly change order,
                // so things will screw up if we HANDLE the controls in a different order when dragging.
                if (GUIUtility.hotControl == id && Event.current.type == EventType.Repaint)
                {
                    for (int i = 0; i < elements.Count; i++)
                    {
                        // Don't draw the dragged element as part of loop
                        if (i == s_ReorderingDraggedElement)
                        {
                            continue;
                        }
                        if (IsDefaultTimeElement(elements[i]))
                        {
                            defPos = i;
                            i++;
                            continue;
                        }
                        elementRect.y = position.y + s_ReorderingPositions[i] * elementHeight;
                        drawElementDelegate(elementRect, elements[i], false);
                    }
                    defRect = new Rect(elementRect.x, position.y + s_ReorderingPositions[defPos] * elementHeight, elementRect.width, (s_ReorderingPositions[defPos + 1] - s_ReorderingPositions[defPos] + 1) * elementHeight);
                }
                // For everything else than repainting while dragging,
                // draw controls based on their positions in the array.
                else
                {
                    for (int i = 0; i < elements.Count; i++)
                    {
                        elementRect.y = position.y + i * elementHeight;
                        if (IsDefaultTimeElement(elements[i]))
                        {
                            defPos = i;
                            i++;
                            continue;
                        }
                        drawElementDelegate(elementRect, elements[i], false);
                    }
                    defRect = new Rect(elementRect.x, position.y + defPos * elementHeight, elementRect.width, elementHeight * 2);
                }

                GUI.Label(defRect, Content.defaultTimeContent, Styles.defaultTime);

                bool isAddingToDefault = defRect.height > elementHeight * 2.5f;

                if (GUIUtility.hotControl == id)
                {
                    if (isAddingToDefault)
                    {
                        GUI.color = new Color(1, 1, 1, 0.5f);
                    }
                    // Draw the dragged element after all the other ones
                    elementRect.y = position.y + s_ReorderingPositions[s_ReorderingDraggedElement] * elementHeight;
                    drawElementDelegate(elementRect, elements[s_ReorderingDraggedElement], true);

                    GUI.color = Color.white;
                }

                int       changed = -1;
                EventType type    = Event.current.GetTypeForControl(id);

                switch (type)
                {
                case EventType.MouseDown:
                    if (position.Contains(Event.current.mousePosition))
                    {
                        GUIUtility.keyboardControl = 0;
                        EditorGUI.EndEditingActiveTextField();

                        s_ReorderingDraggedElement = Mathf.FloorToInt((Event.current.mousePosition.y - position.y) / elementHeight);
                        if (!IsDefaultTimeElement(elements[s_ReorderingDraggedElement]))
                        {
                            s_ReorderingPositions = new float[elements.Count];
                            s_ReorderingGoals     = new int[elements.Count];
                            for (int i = 0; i < elements.Count; i++)
                            {
                                s_ReorderingGoals[i]     = i;
                                s_ReorderingPositions[i] = i;
                            }
                            GUIUtility.hotControl = id;
                            Event.current.Use();
                        }
                    }
                    break;

                case EventType.MouseDrag:
                    if (GUIUtility.hotControl != id)
                    {
                        break;
                    }

                    // Set reordering position of dragged element based on mouse cursor
                    s_ReorderingPositions[s_ReorderingDraggedElement] = (Event.current.mousePosition.y - position.y) / elementHeight - 0.5f;
                    // Clamp to range of list
                    s_ReorderingPositions[s_ReorderingDraggedElement] = Mathf.Clamp(s_ReorderingPositions[s_ReorderingDraggedElement], 0, elements.Count - 1);
                    // Set draggedToPosition based on dragged position
                    int draggedToPosition = Mathf.RoundToInt(s_ReorderingPositions[s_ReorderingDraggedElement]);

                    // if dragged to a new position, re-assign goals
                    if (draggedToPosition != s_ReorderingGoals[s_ReorderingDraggedElement])
                    {
                        // Reset
                        for (int i = 0; i < elements.Count; i++)
                        {
                            s_ReorderingGoals[i] = i;
                        }
                        // Find direction that other elements must be moved in
                        int direction = (draggedToPosition > s_ReorderingDraggedElement ? -1 : 1);

                        // Move goals of elements to make room for the dragged one
                        for (int i = s_ReorderingDraggedElement; i != draggedToPosition; i -= direction)
                        {
                            s_ReorderingGoals[i - direction] = i;
                        }

                        // At last, move the goal of the dragged element
                        s_ReorderingGoals[s_ReorderingDraggedElement] = draggedToPosition;
                    }
                    Event.current.Use();
                    break;

                case EventType.MouseUp:
                    if (GUIUtility.hotControl != id)
                    {
                        break;
                    }

                    if (s_ReorderingGoals[s_ReorderingDraggedElement] != s_ReorderingDraggedElement)
                    {
                        // Reorder array according to the reordering goals
                        List <MonoScript> reorderedArray = new List <MonoScript>(elements);
                        for (int i = 0; i < elements.Count; i++)
                        {
                            elements[s_ReorderingGoals[i]] = reorderedArray[i];
                        }

                        // Return which elements was just moved
                        changed = s_ReorderingGoals[s_ReorderingDraggedElement];
                    }

                    // Reset
                    s_ReorderingGoals          = null;
                    s_ReorderingPositions      = null;
                    s_ReorderingDraggedElement = -1;
                    GUIUtility.hotControl      = 0;
                    Event.current.Use();
                    break;

                case EventType.Repaint:
                    // Animate elements to move towards their goals
                    if (GUIUtility.hotControl == id)
                    {
                        for (int i = 0; i < elements.Count; i++)
                        {
                            if (i != s_ReorderingDraggedElement)
                            {
                                s_ReorderingPositions[i] = Mathf.MoveTowards(s_ReorderingPositions[i], s_ReorderingGoals[i], 0.075f);
                            }
                        }
                        GUIView.current.Repaint();
                    }
                    break;
                }

                return(changed);
            }
        public override void OnInspectorGUI()
        {
            bool GUIEnabledValue = GUI.enabled;

            if (Provider.enabled && !Provider.isActive && !EditorUserSettings.WorkOffline)
            {
                GUI.enabled = false;
            }

            if (m_Edited)
            {
                UpdateOrder(m_Edited);
                m_Edited = null;
            }

            EditorGUILayout.BeginVertical(EditorStyles.inspectorFullWidthMargins);
            {
                GUILayout.Label(Content.helpText, EditorStyles.helpBox);

                EditorGUILayout.Space();

                // Vertical that contains box and the toolbar below it
                Rect listRect = EditorGUILayout.BeginVertical();
                {
                    int        dropFieldId = EditorGUIUtility.GetControlID(s_DropFieldHash, FocusType.Passive, listRect);
                    MonoScript dropped     = EditorGUI.DoDropField(listRect, dropFieldId, typeof(MonoScript), MonoScriptValidatorCallback, false, Styles.dropField) as MonoScript;
                    if (dropped)
                    {
                        AddScriptToCustomOrder(dropped);
                    }

                    // Vertical that is used as a border around the scrollview
                    EditorGUILayout.BeginVertical(Styles.boxBackground);
                    {
                        // The scrollview itself
                        m_Scroll = EditorGUILayout.BeginVerticalScrollView(m_Scroll);
                        {
                            // List
                            Rect r       = GUILayoutUtility.GetRect(10, kListElementHeight * m_CustomTimeScripts.Count, GUILayout.ExpandWidth(true));
                            int  changed = DragReorderGUI.DragReorder(r, kListElementHeight, m_CustomTimeScripts, DrawElement);
                            if (changed >= 0)
                            {
                                // Give dragged item value in between neighbors
                                SetExecutionOrderAtIndexAccordingToNeighbors(changed, 0);
                                // Update neighbors if needed
                                UpdateOrder(m_CustomTimeScripts[changed]);
                                // Neighbors may have been moved so there's more space around dragged item,
                                // so set order again to get possible rounding benefits
                                SetExecutionOrderAtIndexAccordingToNeighbors(changed, 0);
                            }
                        } EditorGUILayout.EndScrollView();
                    } EditorGUILayout.EndVertical();

                    // The toolbar below the box
                    GUILayout.BeginHorizontal(Styles.toolbar);
                    {
                        GUILayout.FlexibleSpace();
                        Rect       r2;
                        GUIContent content = Content.iconToolbarPlus;
                        r2 = GUILayoutUtility.GetRect(content, Styles.toolbarDropDown);
                        if (EditorGUI.DropdownButton(r2, content, FocusType.Passive, Styles.toolbarDropDown))
                        {
                            ShowScriptPopup(r2);
                        }
                    } GUILayout.EndHorizontal();
                } GUILayout.EndVertical();

                ApplyRevertGUI();
            } GUILayout.EndVertical();

            GUI.enabled = GUIEnabledValue;
            if (Provider.enabled && !Provider.isActive && !EditorUserSettings.WorkOffline)
            {
                EditorGUILayout.HelpBox("Version control is disconnected", MessageType.Warning);
            }

            GUILayout.FlexibleSpace();
        }
예제 #18
0
 internal static int DoIntField(EditorGUI.RecycledTextEditor editor, Rect position, Rect dragHotZone, int id, int value, string formatString, GUIStyle style, bool draggable, float dragSensitivity)
 {
   double doubleVal = 0.0;
   long longVal = (long) value;
   EditorGUI.DoNumberField(editor, position, dragHotZone, id, false, ref doubleVal, ref longVal, formatString, style, draggable, (double) dragSensitivity);
   return MathUtils.ClampToInt(longVal);
 }
예제 #19
0
 internal static double DoDoubleField(EditorGUI.RecycledTextEditor editor, Rect position, Rect dragHotZone, int id, double value, string formatString, GUIStyle style, bool draggable, double dragSensitivity)
 {
   long longVal = 0;
   EditorGUI.DoNumberField(editor, position, dragHotZone, id, true, ref value, ref longVal, formatString, style, draggable, dragSensitivity);
   return value;
 }
 private void DrawLogoListHeaderCallback(Rect rect)
 {
     m_TotalLogosDuration = 0; // Calculated during logo list draw
     EditorGUI.LabelField(rect, "Logos");
 }
예제 #21
0
 internal static UnityEngine.Object DoObjectField(Rect position, Rect dropRect, int id, UnityEngine.Object obj, System.Type objType, SerializedProperty property, EditorGUI.ObjectFieldValidator validator, bool allowSceneObjects)
 {
   return EditorGUI.DoObjectField(position, dropRect, id, obj, objType, property, validator, allowSceneObjects, EditorStyles.objectField);
 }
        private void BuiltinCustomSplashScreenGUI()
        {
            EditorGUILayout.LabelField(k_Texts.splashTitle, EditorStyles.boldLabel);

            using (new EditorGUI.DisabledScope(!licenseAllowsDisabling))
            {
                EditorGUILayout.PropertyField(m_ShowUnitySplashScreen, k_Texts.showSplash);
                if (!m_ShowUnitySplashScreen.boolValue)
                {
                    return;
                }
            }

            GUIContent buttonLabel       = SplashScreen.isFinished ? k_Texts.previewSplash : k_Texts.cancelPreviewSplash;
            Rect       previewButtonRect = GUILayoutUtility.GetRect(buttonLabel, "button");

            previewButtonRect = EditorGUI.PrefixLabel(previewButtonRect, new GUIContent(" "));
            if (GUI.Button(previewButtonRect, buttonLabel))
            {
                if (SplashScreen.isFinished)
                {
                    SplashScreen.Begin();
                    var gv = GameView.GetMainGameView();
                    if (gv)
                    {
                        gv.Focus();
                    }
                    EditorApplication.update += PollSplashState;
                }
                else
                {
                    SplashScreen.Stop(SplashScreen.StopBehavior.StopImmediate);
                    EditorApplication.update -= PollSplashState;
                }

                GameView.RepaintAll();
            }

            EditorGUILayout.PropertyField(m_SplashScreenLogoStyle, k_Texts.splashStyle);

            // Animation
            EditorGUILayout.PropertyField(m_SplashScreenAnimation, k_Texts.animate);
            m_ShowAnimationControlsAnimator.target = m_SplashScreenAnimation.intValue == (int)PlayerSettings.SplashScreen.AnimationMode.Custom;

            if (EditorGUILayout.BeginFadeGroup(m_ShowAnimationControlsAnimator.faded))
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.Slider(m_SplashScreenLogoAnimationZoom, 0.0f, 1.0f, k_Texts.logoZoom);
                EditorGUILayout.Slider(m_SplashScreenBackgroundAnimationZoom, 0.0f, 1.0f, k_Texts.backgroundZoom);
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFadeGroup();

            EditorGUILayout.Space();

            // Logos
            EditorGUILayout.LabelField(k_Texts.logosTitle, EditorStyles.boldLabel);
            using (new EditorGUI.DisabledScope(!Application.HasProLicense()))
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(m_ShowUnitySplashLogo, k_Texts.showLogo);
                if (EditorGUI.EndChangeCheck())
                {
                    if (!m_ShowUnitySplashLogo.boolValue)
                    {
                        RemoveUnityLogoFromLogosList();
                    }
                    else if (m_SplashScreenDrawMode.intValue == (int)PlayerSettings.SplashScreen.DrawMode.AllSequential)
                    {
                        AddUnityLogoToLogosList();
                    }
                }

                m_ShowLogoControlsAnimator.target = m_ShowUnitySplashLogo.boolValue;
            }

            if (EditorGUILayout.BeginFadeGroup(m_ShowLogoControlsAnimator.faded))
            {
                EditorGUI.indentLevel++;
                EditorGUI.BeginChangeCheck();
                var oldDrawmode = m_SplashScreenDrawMode.intValue;
                EditorGUILayout.PropertyField(m_SplashScreenDrawMode, k_Texts.drawMode);
                if (oldDrawmode != m_SplashScreenDrawMode.intValue)
                {
                    if (m_SplashScreenDrawMode.intValue == (int)PlayerSettings.SplashScreen.DrawMode.UnityLogoBelow)
                    {
                        RemoveUnityLogoFromLogosList();
                    }
                    else
                    {
                        AddUnityLogoToLogosList();
                    }
                }
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFadeGroup();

            m_LogoList.DoLayoutList();
            EditorGUILayout.Space();

            // Background
            EditorGUILayout.LabelField(k_Texts.backgroundTitle, EditorStyles.boldLabel);
            EditorGUILayout.Slider(m_SplashScreenOverlayOpacity, Application.HasProLicense() ? k_MinProEditionOverlayOpacity : k_MinPersonalEditionOverlayOpacity, 1.0f, k_Texts.overlayOpacity);
            m_ShowBackgroundColorAnimator.target = m_SplashScreenBackgroundLandscape.objectReferenceValue == null;
            if (EditorGUILayout.BeginFadeGroup(m_ShowBackgroundColorAnimator.faded))
            {
                EditorGUILayout.PropertyField(m_SplashScreenBackgroundColor, k_Texts.backgroundColor);
            }
            EditorGUILayout.EndFadeGroup();

            EditorGUILayout.PropertyField(m_SplashScreenBlurBackground, k_Texts.blurBackground);
            EditorGUI.BeginChangeCheck();
            ObjectReferencePropertyField <Sprite>(m_SplashScreenBackgroundLandscape, k_Texts.backgroundImage);
            if (EditorGUI.EndChangeCheck() && m_SplashScreenBackgroundLandscape.objectReferenceValue == null)
            {
                m_SplashScreenBackgroundPortrait.objectReferenceValue = null;
            }

            using (new EditorGUI.DisabledScope(m_SplashScreenBackgroundLandscape.objectReferenceValue == null))
            {
                ObjectReferencePropertyField <Sprite>(m_SplashScreenBackgroundPortrait, k_Texts.backgroundPortraitImage);
            }
        }
        public override void OnInspectorGUI()
        {
            if (m_EditorUserSettings != null && !m_EditorUserSettings.targetObject)
            {
                LoadEditorUserSettings();
            }

            serializedObject.Update();

            // GUI.enabled hack because we don't want some controls to be disabled if the EditorSettings.asset is locked
            // since some of the controls are not dependent on the Editor Settings asset. Unfortunately, this assumes
            // that the editor will only be disabled because of version control locking which may change in the future.
            var editorEnabled = GUI.enabled;

            ShowUnityRemoteGUI(editorEnabled);

            GUILayout.Space(10);
            bool collabEnabled = Collab.instance.IsCollabEnabledForCurrentProject();
            using (new EditorGUI.DisabledScope(!collabEnabled))
            {
                GUI.enabled = !collabEnabled;
                GUILayout.Label(Content.versionControl, EditorStyles.boldLabel);

                ExternalVersionControl selvc = EditorSettings.externalVersionControl;
                CreatePopupMenuVersionControl(Content.mode.text, vcPopupList, selvc, SetVersionControlSystem);
                GUI.enabled = editorEnabled && !collabEnabled;
            }
            if (collabEnabled)
            {
                EditorGUILayout.HelpBox("Version Control not available when using Collaboration feature.", MessageType.Warning);
            }

            if (VersionControlSystemHasGUI())
            {
                GUI.enabled = true;
                bool hasRequiredFields = false;

                if (EditorSettings.externalVersionControl == ExternalVersionControl.Generic ||
                    EditorSettings.externalVersionControl == ExternalVersionControl.Disabled)
                {
                    // no specific UI for these VCS types
                }
                else
                {
                    ConfigField[] configFields = Provider.GetActiveConfigFields();

                    hasRequiredFields = true;

                    foreach (ConfigField field in configFields)
                    {
                        string newVal;
                        string oldVal = EditorUserSettings.GetConfigValue(field.name);
                        if (field.isPassword)
                        {
                            newVal = EditorGUILayout.PasswordField(field.label, oldVal);
                            if (newVal != oldVal)
                                EditorUserSettings.SetPrivateConfigValue(field.name, newVal);
                        }
                        else
                        {
                            newVal = EditorGUILayout.TextField(field.label, oldVal);
                            if (newVal != oldVal)
                                EditorUserSettings.SetConfigValue(field.name, newVal);
                        }

                        if (field.isRequired && string.IsNullOrEmpty(newVal))
                            hasRequiredFields = false;
                    }
                }

                // Log level popup
                string logLevel = EditorUserSettings.GetConfigValue("vcSharedLogLevel");
                int idx = System.Array.FindIndex(logLevelPopupList, (item) => item.ToLower() == logLevel);
                if (idx == -1)
                {
                    logLevel = "notice";
                    idx = System.Array.FindIndex(logLevelPopupList, (item) => item.ToLower() == logLevel);
                    if (idx == -1)
                    {
                        idx = 0;
                    }
                    logLevel = logLevelPopupList[idx];
                    EditorUserSettings.SetConfigValue("vcSharedLogLevel", logLevel);
                }
                int newIdx = EditorGUILayout.Popup(Content.logLevel, idx, logLevelPopupList);
                if (newIdx != idx)
                {
                    EditorUserSettings.SetConfigValue("vcSharedLogLevel", logLevelPopupList[newIdx].ToLower());
                }

                GUI.enabled = editorEnabled;

                string osState = "Connected";
                if (Provider.onlineState == OnlineState.Updating)
                    osState = "Connecting...";
                else if (Provider.onlineState == OnlineState.Offline)
                    osState = "Disconnected";
                else if (EditorUserSettings.WorkOffline)
                    osState = "Work Offline";

                EditorGUILayout.LabelField(Content.status.text, osState);

                if (Provider.onlineState != OnlineState.Online && !string.IsNullOrEmpty(Provider.offlineReason))
                {
                    GUI.enabled = false;
                    GUILayout.TextArea(Provider.offlineReason);
                    GUI.enabled = editorEnabled;
                }

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUI.enabled = hasRequiredFields && Provider.onlineState != OnlineState.Updating;
                if (GUILayout.Button("Connect", EditorStyles.miniButton))
                    Provider.UpdateSettings();
                GUILayout.EndHorizontal();

                EditorUserSettings.AutomaticAdd = EditorGUILayout.Toggle(Content.automaticAdd, EditorUserSettings.AutomaticAdd);

                if (Provider.requiresNetwork)
                {
                    bool workOfflineNew = EditorGUILayout.Toggle(Content.workOffline, EditorUserSettings.WorkOffline); // Enabled has a slightly different behaviour
                    if (workOfflineNew != EditorUserSettings.WorkOffline)
                    {
                        // On toggling on show a warning
                        if (workOfflineNew && !EditorUtility.DisplayDialog("Confirm working offline", "Working offline and making changes to your assets means that you will have to manually integrate changes back into version control using your standard version control client before you stop working offline in Unity. Make sure you know what you are doing.", "Work offline", "Cancel"))
                        {
                            workOfflineNew = false; // User cancelled working offline
                        }
                        EditorUserSettings.WorkOffline = workOfflineNew;
                        EditorApplication.RequestRepaintAllViews();
                    }

                    EditorUserSettings.allowAsyncStatusUpdate = EditorGUILayout.Toggle(Content.allowAsyncUpdate, EditorUserSettings.allowAsyncStatusUpdate);
                }

                if (Provider.hasCheckoutSupport)
                {
                    EditorUserSettings.showFailedCheckout = EditorGUILayout.Toggle(Content.showFailedCheckouts, EditorUserSettings.showFailedCheckout);
                    EditorUserSettings.overwriteFailedCheckoutAssets = EditorGUILayout.Toggle(Content.overwriteFailedCheckoutAssets, EditorUserSettings.overwriteFailedCheckoutAssets);
                }

                var newOverlayIcons = EditorGUILayout.Toggle(Content.overlayIcons, EditorUserSettings.overlayIcons);
                if (newOverlayIcons != EditorUserSettings.overlayIcons)
                {
                    EditorUserSettings.overlayIcons = newOverlayIcons;
                    EditorApplication.RequestRepaintAllViews();
                }

                GUI.enabled = editorEnabled;

                // Semantic merge popup
                EditorUserSettings.semanticMergeMode = (SemanticMergeMode)EditorGUILayout.Popup(Content.smartMerge, (int)EditorUserSettings.semanticMergeMode, semanticMergePopupList);

                DrawOverlayDescriptions();
            }

            GUILayout.Space(10);

            int index = (int)EditorSettings.serializationMode;
            using (new EditorGUI.DisabledScope(!collabEnabled))
            {
                GUI.enabled = !collabEnabled;
                GUILayout.Label(Content.assetSerialization, EditorStyles.boldLabel);
                GUI.enabled = editorEnabled && !collabEnabled;


                CreatePopupMenu("Mode", serializationPopupList, index, SetAssetSerializationMode);
            }
            if (collabEnabled)
            {
                EditorGUILayout.HelpBox("Asset Serialization is forced to Text when using Collaboration feature.", MessageType.Warning);
            }

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.defaultBehaviorMode, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            index = Mathf.Clamp((int)EditorSettings.defaultBehaviorMode, 0, behaviorPopupList.Length - 1);
            CreatePopupMenu(Content.mode.text, behaviorPopupList, index, SetDefaultBehaviorMode);

            {
                var wasEnabled = GUI.enabled;
                GUI.enabled = true;

                DoAssetPipelineSettings();

                if (m_AssetPipelineMode.intValue == (int)AssetPipelineMode.Version2)
                    DoCacheServerSettings();

                GUI.enabled = wasEnabled;
            }
            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label("Prefab Editing Environments", EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            {
                EditorGUI.BeginChangeCheck();
                SceneAsset scene = EditorSettings.prefabRegularEnvironment;
                scene = (SceneAsset)EditorGUILayout.ObjectField("Regular Environment", scene, typeof(SceneAsset), false);
                if (EditorGUI.EndChangeCheck())
                    EditorSettings.prefabRegularEnvironment = scene;
            }
            {
                EditorGUI.BeginChangeCheck();
                SceneAsset scene = EditorSettings.prefabUIEnvironment;
                scene = (SceneAsset)EditorGUILayout.ObjectField("UI Environment", scene, typeof(SceneAsset), false);
                if (EditorGUI.EndChangeCheck())
                    EditorSettings.prefabUIEnvironment = scene;
            }

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.graphics, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            EditorGUI.BeginChangeCheck();
            bool showRes = LightmapVisualization.showResolution;
            showRes = EditorGUILayout.Toggle(Content.showLightmapResolutionOverlay, showRes);
            if (EditorGUI.EndChangeCheck())
                LightmapVisualization.showResolution = showRes;

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.spritePacker, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            index = Mathf.Clamp((int)EditorSettings.spritePackerMode, 0, spritePackerPopupList.Length - 1);
            CreatePopupMenu(Content.mode.text, spritePackerPopupList, index, SetSpritePackerMode);

            if (EditorSettings.spritePackerMode == SpritePackerMode.AlwaysOn
                || EditorSettings.spritePackerMode == SpritePackerMode.BuildTimeOnly)
            {
                index = Mathf.Clamp((int)(EditorSettings.spritePackerPaddingPower - 1), 0, 2);
                CreatePopupMenu("Padding Power (Legacy Sprite Packer)", spritePackerPaddingPowerPopupList, index, SetSpritePackerPaddingPower);
            }

            DoProjectGenerationSettings();
            DoEtcTextureCompressionSettings();
            DoLineEndingsSettings();
            DoStreamingSettings();
            DoShaderCompilationSettings();
            DoEnterPlayModeSettings();

            serializedObject.ApplyModifiedProperties();
            m_EditorUserSettings.ApplyModifiedProperties();
        }
예제 #24
0
		internal static string DoTextField(EditorGUI.RecycledTextEditor editor, int id, Rect position, string text, GUIStyle style, string allowedletters, out bool changed, bool reset, bool multiline, bool passwordField)
		{
			Event current = Event.current;
			string result = text;
			if (text == null)
			{
				text = string.Empty;
			}
			if (EditorGUI.showMixedValue)
			{
				text = string.Empty;
			}
			if (EditorGUI.HasKeyboardFocus(id) && Event.current.type != EventType.Layout)
			{
				if (editor.IsEditingControl(id))
				{
					editor.position = position;
					editor.style = style;
					editor.controlID = id;
					editor.multiline = multiline;
					editor.isPasswordField = passwordField;
					editor.ClampPos();
					editor.UpdateScrollOffsetIfNeeded();
				}
				else
				{
					if (EditorGUIUtility.editingTextField)
					{
						editor.BeginEditing(id, text, position, style, multiline, passwordField);
						if (GUI.skin.settings.cursorColor.a > 0f)
						{
							editor.SelectAll();
						}
					}
				}
			}
			if (editor.controlID == id && GUIUtility.keyboardControl != id)
			{
				editor.controlID = 0;
			}
			bool flag = false;
			string text2 = editor.content.text;
			EventType typeForControl = current.GetTypeForControl(id);
			switch (typeForControl)
			{
			case EventType.MouseDown:
				if (position.Contains(current.mousePosition) && current.button == 0)
				{
					if (editor.IsEditingControl(id))
					{
						if (Event.current.clickCount == 2 && GUI.skin.settings.doubleClickSelectsWord)
						{
							editor.MoveCursorToPosition(Event.current.mousePosition);
							editor.SelectCurrentWord();
							editor.MouseDragSelectsWholeWords(true);
							editor.DblClickSnap(TextEditor.DblClickSnapping.WORDS);
							EditorGUI.s_DragToPosition = false;
						}
						else
						{
							if (Event.current.clickCount == 3 && GUI.skin.settings.tripleClickSelectsLine)
							{
								editor.MoveCursorToPosition(Event.current.mousePosition);
								editor.SelectCurrentParagraph();
								editor.MouseDragSelectsWholeWords(true);
								editor.DblClickSnap(TextEditor.DblClickSnapping.PARAGRAPHS);
								EditorGUI.s_DragToPosition = false;
							}
							else
							{
								editor.MoveCursorToPosition(Event.current.mousePosition);
								EditorGUI.s_SelectAllOnMouseUp = false;
							}
						}
					}
					else
					{
						GUIUtility.keyboardControl = id;
						editor.BeginEditing(id, text, position, style, multiline, passwordField);
						editor.MoveCursorToPosition(Event.current.mousePosition);
						if (GUI.skin.settings.cursorColor.a > 0f)
						{
							EditorGUI.s_SelectAllOnMouseUp = true;
						}
					}
					GUIUtility.hotControl = id;
					current.Use();
				}
				goto IL_967;
			case EventType.MouseUp:
				if (GUIUtility.hotControl == id)
				{
					if (EditorGUI.s_Dragged && EditorGUI.s_DragToPosition)
					{
						editor.MoveSelectionToAltCursor();
						flag = true;
					}
					else
					{
						if (EditorGUI.s_PostPoneMove)
						{
							editor.MoveCursorToPosition(Event.current.mousePosition);
						}
						else
						{
							if (EditorGUI.s_SelectAllOnMouseUp)
							{
								if (GUI.skin.settings.cursorColor.a > 0f)
								{
									editor.SelectAll();
								}
								EditorGUI.s_SelectAllOnMouseUp = false;
							}
						}
					}
					editor.MouseDragSelectsWholeWords(false);
					EditorGUI.s_DragToPosition = true;
					EditorGUI.s_Dragged = false;
					EditorGUI.s_PostPoneMove = false;
					if (current.button == 0)
					{
						GUIUtility.hotControl = 0;
						current.Use();
					}
				}
				goto IL_967;
			case EventType.MouseMove:
			case EventType.KeyUp:
			case EventType.ScrollWheel:
				IL_121:
				switch (typeForControl)
				{
				case EventType.ValidateCommand:
					if (GUIUtility.keyboardControl == id)
					{
						string commandName = current.commandName;
						switch (commandName)
						{
						case "Cut":
						case "Copy":
							if (editor.hasSelection)
							{
								current.Use();
							}
							break;
						case "Paste":
							if (editor.CanPaste())
							{
								current.Use();
							}
							break;
						case "SelectAll":
							current.Use();
							break;
						case "UndoRedoPerformed":
							editor.content.text = text;
							current.Use();
							break;
						}
					}
					goto IL_967;
				case EventType.ExecuteCommand:
					if (GUIUtility.keyboardControl == id)
					{
						string commandName = current.commandName;
						switch (commandName)
						{
						case "OnLostFocus":
							if (EditorGUI.activeEditor != null)
							{
								EditorGUI.activeEditor.EndEditing();
							}
							current.Use();
							break;
						case "Cut":
							editor.BeginEditing(id, text, position, style, multiline, passwordField);
							editor.Cut();
							flag = true;
							break;
						case "Copy":
							editor.Copy();
							current.Use();
							break;
						case "Paste":
							editor.BeginEditing(id, text, position, style, multiline, passwordField);
							editor.Paste();
							flag = true;
							break;
						case "SelectAll":
							editor.SelectAll();
							current.Use();
							break;
						}
					}
					goto IL_967;
				case EventType.DragExited:
					goto IL_967;
				case EventType.ContextClick:
					if (position.Contains(current.mousePosition))
					{
						if (!editor.IsEditingControl(id))
						{
							GUIUtility.keyboardControl = id;
							editor.BeginEditing(id, text, position, style, multiline, passwordField);
							editor.MoveCursorToPosition(Event.current.mousePosition);
						}
						EditorGUI.ShowTextEditorPopupMenu();
						Event.current.Use();
					}
					goto IL_967;
				default:
					goto IL_967;
				}
				break;
			case EventType.MouseDrag:
				if (GUIUtility.hotControl == id)
				{
					if (!current.shift && editor.hasSelection && EditorGUI.s_DragToPosition)
					{
						editor.MoveAltCursorToPosition(Event.current.mousePosition);
					}
					else
					{
						if (current.shift)
						{
							editor.MoveCursorToPosition(Event.current.mousePosition);
						}
						else
						{
							editor.SelectToPosition(Event.current.mousePosition);
						}
						EditorGUI.s_DragToPosition = false;
						EditorGUI.s_SelectAllOnMouseUp = !editor.hasSelection;
					}
					EditorGUI.s_Dragged = true;
					current.Use();
				}
				goto IL_967;
			case EventType.KeyDown:
				if (GUIUtility.keyboardControl == id)
				{
					char character = current.character;
					if (editor.IsEditingControl(id) && editor.HandleKeyEvent(current))
					{
						current.Use();
						flag = true;
					}
					else
					{
						if (current.keyCode == KeyCode.Escape)
						{
							if (editor.IsEditingControl(id))
							{
								if (style == EditorStyles.toolbarSearchField || style == EditorStyles.searchField)
								{
									EditorGUI.s_OriginalText = string.Empty;
								}
								editor.content.text = EditorGUI.s_OriginalText;
								editor.EndEditing();
								flag = true;
							}
						}
						else
						{
							if (character == '\n' || character == '\u0003')
							{
								if (!editor.IsEditingControl(id))
								{
									editor.BeginEditing(id, text, position, style, multiline, passwordField);
									editor.SelectAll();
								}
								else
								{
									if (multiline && !current.alt && !current.shift && !current.control)
									{
										editor.Insert(character);
										flag = true;
										goto IL_967;
									}
									editor.EndEditing();
								}
								current.Use();
							}
							else
							{
								if (character == '\t' || current.keyCode == KeyCode.Tab)
								{
									if (multiline && editor.IsEditingControl(id))
									{
										bool flag2 = allowedletters == null || allowedletters.IndexOf(character) != -1;
										bool flag3 = !current.alt && !current.shift && !current.control && character == '\t';
										if (flag3 && flag2)
										{
											editor.Insert(character);
											flag = true;
										}
									}
								}
								else
								{
									if (character != '\u0019' && character != '\u001b')
									{
										if (editor.IsEditingControl(id))
										{
											bool flag4 = (allowedletters == null || allowedletters.IndexOf(character) != -1) && character != '\0';
											if (flag4)
											{
												editor.Insert(character);
												flag = true;
											}
											else
											{
												if (Input.compositionString != string.Empty)
												{
													editor.ReplaceSelection(string.Empty);
													flag = true;
												}
												current.Use();
											}
										}
									}
								}
							}
						}
					}
				}
				goto IL_967;
			case EventType.Repaint:
			{
				string text3;
				if (editor.IsEditingControl(id))
				{
					text3 = ((!passwordField) ? editor.content.text : string.Empty.PadRight(editor.content.text.Length, '*'));
				}
				else
				{
					if (EditorGUI.showMixedValue)
					{
						text3 = EditorGUI.s_MixedValueContent.text;
					}
					else
					{
						text3 = ((!passwordField) ? text : string.Empty.PadRight(text.Length, '*'));
					}
				}
				if (!string.IsNullOrEmpty(EditorGUI.s_UnitString) && !passwordField)
				{
					text3 = text3 + " " + EditorGUI.s_UnitString;
				}
				if (GUIUtility.hotControl == 0)
				{
					EditorGUIUtility.AddCursorRect(position, MouseCursor.Text);
				}
				if (!editor.IsEditingControl(id))
				{
					EditorGUI.BeginHandleMixedValueContentColor();
					style.Draw(position, EditorGUIUtility.TempContent(text3), id, false);
					EditorGUI.EndHandleMixedValueContentColor();
				}
				else
				{
					editor.DrawCursor(text3);
				}
				goto IL_967;
			}
			}
			goto IL_121;
			IL_967:
			if (GUIUtility.keyboardControl == id)
			{
				GUIUtility.textFieldInput = true;
			}
			changed = false;
			if (flag)
			{
				changed = (text2 != editor.content.text);
				current.Use();
			}
			if (changed)
			{
				GUI.changed = true;
				return editor.content.text;
			}
			EditorGUI.RecycledTextEditor.s_AllowContextCutOrPaste = true;
			return result;
		}
예제 #25
0
        private void RuleOverrideInspectorOnGUI(Rect rect, RuleTile.TilingRule originalRule)
        {
            RuleTile.TilingRule overrideRule = overrideTile[originalRule];

            float y = rect.yMin;

            EditorGUI.BeginChangeCheck();

            GUI.Label(new Rect(rect.xMin, y, k_LabelWidth, k_SingleLineHeight), "Enabled");
            bool enabled = EditorGUI.Toggle(new Rect(rect.xMin + k_LabelWidth, y, rect.width - k_LabelWidth, k_SingleLineHeight), overrideRule != null);

            y += k_SingleLineHeight;

            if (EditorGUI.EndChangeCheck())
            {
                if (enabled)
                {
                    overrideTile[originalRule] = originalRule;
                }
                else
                {
                    overrideTile[originalRule] = null;
                }
                overrideRule = overrideTile[originalRule];
            }

            if (overrideRule == null)
            {
                return;
            }

            GUI.Label(new Rect(rect.xMin, y, k_LabelWidth, k_SingleLineHeight), "Game Object");
            overrideRule.m_GameObject = (GameObject)EditorGUI.ObjectField(new Rect(rect.xMin + k_LabelWidth, y, rect.width - k_LabelWidth, k_SingleLineHeight), "", overrideRule.m_GameObject, typeof(GameObject), false);
            y += k_SingleLineHeight;
            GUI.Label(new Rect(rect.xMin, y, k_LabelWidth, k_SingleLineHeight), "Collider");
            overrideRule.m_ColliderType = (Tile.ColliderType)EditorGUI.EnumPopup(new Rect(rect.xMin + k_LabelWidth, y, rect.width - k_LabelWidth, k_SingleLineHeight), overrideRule.m_ColliderType);
            y += k_SingleLineHeight;
            GUI.Label(new Rect(rect.xMin, y, k_LabelWidth, k_SingleLineHeight), "Output");
            overrideRule.m_Output = (RuleTile.TilingRule.OutputSprite)EditorGUI.EnumPopup(new Rect(rect.xMin + k_LabelWidth, y, rect.width - k_LabelWidth, k_SingleLineHeight), overrideRule.m_Output);
            y += k_SingleLineHeight;

            if (overrideRule.m_Output == RuleTile.TilingRule.OutputSprite.Animation)
            {
                GUI.Label(new Rect(rect.xMin, y, k_LabelWidth, k_SingleLineHeight), "Speed");
                overrideRule.m_AnimationSpeed = EditorGUI.FloatField(new Rect(rect.xMin + k_LabelWidth, y, rect.width - k_LabelWidth, k_SingleLineHeight), overrideRule.m_AnimationSpeed);
                y += k_SingleLineHeight;
            }
            if (overrideRule.m_Output == RuleTile.TilingRule.OutputSprite.Random)
            {
                GUI.Label(new Rect(rect.xMin, y, k_LabelWidth, k_SingleLineHeight), "Noise");
                overrideRule.m_PerlinScale = EditorGUI.Slider(new Rect(rect.xMin + k_LabelWidth, y, rect.width - k_LabelWidth, k_SingleLineHeight), overrideRule.m_PerlinScale, 0.001f, 0.999f);
                y += k_SingleLineHeight;

                GUI.Label(new Rect(rect.xMin, y, k_LabelWidth, k_SingleLineHeight), "Shuffle");
                overrideRule.m_RandomTransform = (RuleTile.TilingRule.Transform)EditorGUI.EnumPopup(new Rect(rect.xMin + k_LabelWidth, y, rect.width - k_LabelWidth, k_SingleLineHeight), overrideRule.m_RandomTransform);
                y += k_SingleLineHeight;
            }

            if (overrideRule.m_Output != RuleTile.TilingRule.OutputSprite.Single)
            {
                GUI.Label(new Rect(rect.xMin, y, k_LabelWidth, k_SingleLineHeight), "Size");
                EditorGUI.BeginChangeCheck();
                int newLength = EditorGUI.DelayedIntField(new Rect(rect.xMin + k_LabelWidth, y, rect.width - k_LabelWidth, k_SingleLineHeight), overrideRule.m_Sprites.Length);
                if (EditorGUI.EndChangeCheck())
                {
                    Array.Resize(ref overrideRule.m_Sprites, Math.Max(newLength, 1));
                }
                y += k_SingleLineHeight;

                for (int i = 0; i < overrideRule.m_Sprites.Length; i++)
                {
                    overrideRule.m_Sprites[i] = EditorGUI.ObjectField(new Rect(rect.xMin + k_LabelWidth, y, rect.width - k_LabelWidth, k_SingleLineHeight), overrideRule.m_Sprites[i], typeof(Sprite), false) as Sprite;
                    y += k_SingleLineHeight;
                }
            }
        }
예제 #26
0
		internal static float DoFloatField(EditorGUI.RecycledTextEditor editor, Rect position, Rect dragHotZone, int id, float value, string formatString, GUIStyle style, bool draggable, float dragSensitivity)
		{
			long num = 0L;
			double value2 = (double)value;
			EditorGUI.DoNumberField(editor, position, dragHotZone, id, true, ref value2, ref num, formatString, style, draggable, (double)dragSensitivity);
			return MathUtils.ClampToFloat(value2);
		}
예제 #27
0
    void showRoadMapGUI()
    {
        EG.BeginDisabledGroup(!(terrainGenerated && growthMapGenerated && populationGenerated));
        showRoadMapUI = EGL.Foldout(showRoadMapUI, roadmapLabel, true);
        if (showRoadMapUI)
        {
            GL.Label("Streets", EditorStyles.centeredGreyMiniLabel);
            GL.BeginHorizontal();
            GL.BeginVertical();
            GL.Label("Width");
            GL.Label("Min Length");
            GL.Label("LookAhead");
            GL.Label("Pop Threshold");
            GL.Label("Max Slope");
            GL.EndVertical();
            GL.BeginVertical();
            CG.streetWidth        = EGL.IntSlider(CG.streetWidth, 5, 20);
            CG.streetMinLength    = EGL.Slider(CG.streetMinLength, 5f, 100f);
            CG.streetLookAhead    = EGL.IntSlider(CG.streetLookAhead, 1, (int)(CG.terrainSize / CG.streetMinLength));
            CG.streetPopThreshold = EGL.Slider(CG.streetPopThreshold, 0f, 1f);
            CG.streetMaxSlope     = EGL.Slider(CG.streetMaxSlope, 0f, 1f);
            GL.EndVertical();
            GL.EndHorizontal();

            GL.Space(5);

            GL.Label("Highways", EditorStyles.centeredGreyMiniLabel);
            GL.BeginHorizontal();
            GL.BeginVertical();
            GL.Label("Width");
            GL.Label("Min Length");
            GL.Label("LookAhead");
            GL.Label("Pop Threshold");
            GL.Label("Max Slope");
            GL.EndVertical();
            GL.BeginVertical();
            CG.highwayWidth        = EGL.IntSlider(CG.highwayWidth, 10, 25);
            CG.highwayMinLength    = EGL.Slider(CG.highwayMinLength, 5f, 200f);
            CG.highwayLookAhead    = EGL.IntSlider(CG.highwayLookAhead, 1, (int)(CG.terrainSize / CG.highwayMinLength));
            CG.highwayPopThreshold = EGL.Slider(CG.highwayPopThreshold, 0f, 1f);
            CG.highwayMaxSlope     = EGL.Slider(CG.highwayMaxSlope, 0f, 1f);
            GL.EndVertical();
            GL.EndHorizontal();

            GL.Space(10);

            showRoadMapAdvanced = EGL.Foldout(showRoadMapAdvanced, "Advanced Settings", true);
            if (showRoadMapAdvanced)
            {
                EGL.HelpBox("Adjusting these settings might break the Editor or severely influence performance.", MessageType.Warning);
                GL.Label("General Advanced Settings", EditorStyles.centeredGreyMiniLabel);
                GL.BeginHorizontal();
                GL.BeginVertical();
                GL.Label("Legalization Attempts");
                GL.Label("Min Road Correction Angle");
                GL.Label("Node Check Radius");
                GL.Label("Road Connect Max Distance");
                GL.Label("Ray Count");
                GL.EndVertical();
                GL.BeginVertical();
                CG.legalizationAttempts = EGL.IntSlider(CG.legalizationAttempts, 1, 100);
                CG.minRoadAngle         = EGL.IntSlider(CG.minRoadAngle, 0, 90);
                CG.nodeCheckRadius      = EGL.Slider(CG.nodeCheckRadius, 0f, 100f);
                CG.roadConnectDistance  = EGL.Slider(CG.roadConnectDistance, 0f, 100f);
                CG.rayCount             = EGL.IntSlider(CG.rayCount, 1, 32);
                GL.EndVertical();
                GL.EndHorizontal();

                GL.Label("Advanced Settings for L-system Component", EditorStyles.centeredGreyMiniLabel);
                EGL.HelpBox("Low values correspond to higher priority.", MessageType.Info);
                GL.BeginHorizontal();
                GL.BeginVertical();
                GL.Label("Street - Priority");
                GL.Label("Highway - Priority");
                GL.EndVertical();
                GL.BeginVertical();
                CG.streetPriority  = EGL.IntSlider(CG.streetPriority, 1, 5);
                CG.highwayPriority = EGL.IntSlider(CG.highwayPriority, 1, 5);
                GL.EndVertical();
                GL.EndHorizontal();

                GL.Label("Advanced Settings for Growth Rules", EditorStyles.centeredGreyMiniLabel);
                GL.BeginHorizontal();
                GL.BeginVertical();
                GL.Label("Street - Straight Angle");
                GL.Label("Street - Branch  Angle");
                GL.Space(10);
                GL.Label("Highway - Branch Prob");
                GL.Label("Highway - Straight Angle");
                GL.Label("Highway - Branch Angle");
                GL.EndVertical();
                GL.BeginVertical();
                CG.streetStraightAngle = EGL.Slider(CG.streetStraightAngle, 0f, 90f);
                CG.streetBranchAngle   = EGL.Slider(CG.streetBranchAngle, 0f, 90f);
                GL.Space(10);
                CG.highwayBranchProb    = EGL.Slider(CG.highwayBranchProb, 0f, 1f);
                CG.highwayStraightAngle = EGL.Slider(CG.highwayStraightAngle, 0f, 90f);
                CG.highwayBranchAngle   = EGL.Slider(CG.highwayBranchAngle, 0f, 90f);
                GL.EndVertical();
                GL.EndHorizontal();
            }
            if (roadMapGenerated)
            {
                GL.BeginHorizontal("Box");
                GL.FlexibleSpace();
                CG.showPop = EGL.ToggleLeft("Preview Pop Map", CG.showPop);
                GL.FlexibleSpace();
                CG.showGrowth = EGL.ToggleLeft("Preview Growth Map", CG.showGrowth);
                GL.FlexibleSpace();
                GL.EndHorizontal();

                if (DebugMode)
                {
                    showPreviewGUI();
                }
            }
            EGL.HelpBox("The 'Generate Road Map' button may take several tries to generate road map due to the random nature of the algorithm.", MessageType.Info);
            GL.BeginHorizontal();
            if (GL.Button("Generate Road Map"))
            {
                GameObject roadMap = GameObject.Find("RoadMap");
                GameObject nodes   = GameObject.Find("Nodes");


                if (roadMap != null)
                {
                    roadMap.SetActive(true);
                }
                if (nodes != null)
                {
                    nodes.SetActive(true);
                }
                generator.generateRoadMap();
                roadMapGenerated  = true;
                roadMeshGenerated = false;
            }

            EG.BeginDisabledGroup(!roadMapGenerated);
            if (GL.Button("Generate Road Meshes & Blocks"))
            {
                generator.generateRoadMeshes();
                generator.generateBlocks();
                roadMeshGenerated = true;
            }
            EG.EndDisabledGroup();
            GL.EndHorizontal();

            EG.BeginDisabledGroup(!roadMeshGenerated);
            if (GL.Button("Save and Proceed"))
            {
                showRoadMapUI       = false;
                showRoadMapAdvanced = false;
                showBuildingUI      = true;
                GameObject roadMap = GameObject.Find("RoadMap");
                if (roadMap != null)
                {
                    roadMap.SetActive(false);
                }
                GameObject nodes = GameObject.Find("Nodes");
                if (nodes != null)
                {
                    nodes.SetActive(false);
                }
                roadmapLabel = "4. Road Map Generation - COMPLETED ✔";
            }
            EG.EndDisabledGroup();
        }
        EG.EndDisabledGroup();
    }
예제 #28
0
		internal static void DoNumberField(EditorGUI.RecycledTextEditor editor, Rect position, Rect dragHotZone, int id, bool isDouble, ref double doubleVal, ref long longVal, string formatString, GUIStyle style, bool draggable, double dragSensitivity)
		{
			string allowedletters = (!isDouble) ? EditorGUI.s_AllowedCharactersForInt : EditorGUI.s_AllowedCharactersForFloat;
			if (draggable)
			{
				EditorGUI.DragNumberValue(editor, position, dragHotZone, id, isDouble, ref doubleVal, ref longVal, formatString, style, dragSensitivity);
			}
			Event current = Event.current;
			string text;
			if (EditorGUI.HasKeyboardFocus(id) || (current.type == EventType.MouseDown && current.button == 0 && position.Contains(current.mousePosition)))
			{
				if (!editor.IsEditingControl(id))
				{
					text = (EditorGUI.s_RecycledCurrentEditingString = ((!isDouble) ? longVal.ToString(formatString) : doubleVal.ToString(formatString)));
				}
				else
				{
					text = EditorGUI.s_RecycledCurrentEditingString;
					if (current.type == EventType.ValidateCommand && current.commandName == "UndoRedoPerformed")
					{
						text = ((!isDouble) ? longVal.ToString(formatString) : doubleVal.ToString(formatString));
					}
				}
			}
			else
			{
				text = ((!isDouble) ? longVal.ToString(formatString) : doubleVal.ToString(formatString));
			}
			if (GUIUtility.keyboardControl == id)
			{
				bool flag;
				text = EditorGUI.DoTextField(editor, id, position, text, style, allowedletters, out flag, false, false, false);
				if (flag)
				{
					GUI.changed = true;
					EditorGUI.s_RecycledCurrentEditingString = text;
					if (isDouble)
					{
						string a = text.ToLower();
						if (a == "inf" || a == "infinity")
						{
							doubleVal = double.PositiveInfinity;
						}
						else
						{
							if (a == "-inf" || a == "-infinity")
							{
								doubleVal = double.NegativeInfinity;
							}
							else
							{
								text = text.Replace(',', '.');
								if (!double.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture.NumberFormat, out doubleVal))
								{
									doubleVal = (EditorGUI.s_RecycledCurrentEditingFloat = 0.0);
									return;
								}
								if (double.IsNaN(doubleVal))
								{
									doubleVal = 0.0;
								}
								EditorGUI.s_RecycledCurrentEditingFloat = doubleVal;
							}
						}
					}
					else
					{
						if (!long.TryParse(text, out longVal))
						{
							longVal = (EditorGUI.s_RecycledCurrentEditingInt = 0L);
							return;
						}
						EditorGUI.s_RecycledCurrentEditingInt = longVal;
					}
				}
			}
			else
			{
				bool flag;
				text = EditorGUI.DoTextField(editor, id, position, text, style, allowedletters, out flag, false, false, false);
			}
		}
예제 #29
0
 public int GUIListOfFloatObjectToggleFields(GUIContent label, SerializedProperty[] objectProps, EditorGUI.ObjectFieldValidator validator, GUIContent buttonTooltip, bool allowCreation)
 {
     int num = -1;
     int length = objectProps.Length;
     Rect totalPosition = GUILayoutUtility.GetRect(0f, (float) (15 * length));
     totalPosition.height = 13f;
     float num3 = 10f;
     float num4 = 35f;
     float num5 = 10f;
     float width = (((totalPosition.width - num3) - num4) - (num5 * 2f)) - 9f;
     PrefixLabel(totalPosition, label);
     for (int i = 0; i < length; i++)
     {
         SerializedProperty property = objectProps[i];
         Rect position = new Rect(((totalPosition.x + num3) + num4) + num5, totalPosition.y, width, totalPosition.height);
         int id = GUIUtility.GetControlID(0x12da2a, EditorGUIUtility.native, position);
         EditorGUI.DoObjectField(position, position, id, null, null, property, validator, true, ParticleSystemStyles.Get().objectField);
         if (property.objectReferenceValue == null)
         {
             position = new Rect(totalPosition.xMax - 9f, totalPosition.y + 3f, 9f, 9f);
             if (allowCreation)
             {
                 if (buttonTooltip == null)
                 {
                 }
                 if (!GUI.Button(position, GUIContent.none, ParticleSystemStyles.Get().plus))
                 {
                     goto Label_0129;
                 }
             }
             num = i;
         }
     Label_0129:
         totalPosition.y += 15f;
     }
     return num;
 }
예제 #30
0
		internal static UnityEngine.Object MiniThumbnailObjectField(Rect position, GUIContent label, UnityEngine.Object obj, Type objType, EditorGUI.ObjectFieldValidator validator)
		{
			int controlID = GUIUtility.GetControlID(EditorGUI.s_ObjectFieldHash, EditorGUIUtility.native, position);
			Rect rect;
			Rect labelPosition;
			EditorGUI.GetRectsForMiniThumbnailField(position, out rect, out labelPosition);
			EditorGUI.HandlePrefixLabel(position, labelPosition, label, controlID, EditorStyles.label);
			return EditorGUI.DoObjectField(rect, rect, controlID, obj, objType, null, validator, false);
		}
예제 #31
0
		internal static UnityEngine.Object MiniThumbnailObjectField(GUIContent label, UnityEngine.Object obj, Type objType, EditorGUI.ObjectFieldValidator validator, params GUILayoutOption[] options)
		{
			Rect position = EditorGUILayout.s_LastRect = EditorGUILayout.GetControlRect(true, 16f, options);
			return EditorGUI.MiniThumbnailObjectField(position, label, obj, objType, validator);
		}
예제 #32
0
		internal static UnityEngine.Object DoObjectField(Rect position, Rect dropRect, int id, UnityEngine.Object obj, Type objType, SerializedProperty property, EditorGUI.ObjectFieldValidator validator, bool allowSceneObjects, GUIStyle style)
		{
			if (validator == null)
			{
				validator = new EditorGUI.ObjectFieldValidator(EditorGUI.ValidateObjectFieldAssignment);
			}
			Event current = Event.current;
			EventType eventType = current.type;
			if (!GUI.enabled && GUIClip.enabled && Event.current.rawType == EventType.MouseDown)
			{
				eventType = Event.current.rawType;
			}
			bool flag = EditorGUIUtility.HasObjectThumbnail(objType);
			EditorGUI.ObjectFieldVisualType objectFieldVisualType = EditorGUI.ObjectFieldVisualType.IconAndText;
			if (flag && position.height <= 18f && position.width <= 32f)
			{
				objectFieldVisualType = EditorGUI.ObjectFieldVisualType.MiniPreivew;
			}
			else
			{
				if (flag && position.height > 16f)
				{
					objectFieldVisualType = EditorGUI.ObjectFieldVisualType.LargePreview;
				}
			}
			Vector2 iconSize = EditorGUIUtility.GetIconSize();
			if (objectFieldVisualType == EditorGUI.ObjectFieldVisualType.IconAndText)
			{
				EditorGUIUtility.SetIconSize(new Vector2(12f, 12f));
			}
			EventType eventType2 = eventType;
			switch (eventType2)
			{
			case EventType.KeyDown:
				if (GUIUtility.keyboardControl == id)
				{
					if (current.keyCode == KeyCode.Backspace || current.keyCode == KeyCode.Delete)
					{
						if (property != null)
						{
							property.objectReferenceValue = null;
						}
						else
						{
							obj = null;
						}
						GUI.changed = true;
						current.Use();
					}
					if (current.MainActionKeyForControl(id))
					{
						ObjectSelector.get.Show(obj, objType, property, allowSceneObjects);
						ObjectSelector.get.objectSelectorID = id;
						current.Use();
						GUIUtility.ExitGUI();
					}
				}
				goto IL_5EB;
			case EventType.KeyUp:
			case EventType.ScrollWheel:
			case EventType.Layout:
			case EventType.Ignore:
			case EventType.Used:
			case EventType.ValidateCommand:
				IL_FF:
				if (eventType2 != EventType.MouseDown)
				{
					goto IL_5EB;
				}
				if (Event.current.button != 0)
				{
					goto IL_5EB;
				}
				if (position.Contains(Event.current.mousePosition))
				{
					Rect rect;
					switch (objectFieldVisualType)
					{
					case EditorGUI.ObjectFieldVisualType.IconAndText:
						rect = new Rect(position.xMax - 15f, position.y, 15f, position.height);
						break;
					case EditorGUI.ObjectFieldVisualType.LargePreview:
						rect = new Rect(position.xMax - 32f, position.yMax - 14f, 32f, 14f);
						break;
					case EditorGUI.ObjectFieldVisualType.MiniPreivew:
						rect = new Rect(position.xMax - 15f, position.y, 15f, position.height);
						break;
					default:
						throw new ArgumentOutOfRangeException();
					}
					EditorGUIUtility.editingTextField = false;
					if (rect.Contains(Event.current.mousePosition))
					{
						if (GUI.enabled)
						{
							GUIUtility.keyboardControl = id;
							ObjectSelector.get.Show(obj, objType, property, allowSceneObjects);
							ObjectSelector.get.objectSelectorID = id;
							current.Use();
							GUIUtility.ExitGUI();
						}
					}
					else
					{
						UnityEngine.Object @object = (property == null) ? obj : property.objectReferenceValue;
						Component component = @object as Component;
						if (component)
						{
							@object = component.gameObject;
						}
						if (EditorGUI.showMixedValue)
						{
							@object = null;
						}
						if (Event.current.clickCount == 1)
						{
							GUIUtility.keyboardControl = id;
							if (@object)
							{
								bool flag2 = current.shift || current.control;
								if (!flag2)
								{
									EditorGUIUtility.PingObject(@object);
								}
								if (flag2 && @object is Texture)
								{
									PopupWindowWithoutFocus.Show(new RectOffset(6, 3, 0, 3).Add(position), new ObjectPreviewPopup(@object), new PopupLocationHelper.PopupLocation[]
									{
										PopupLocationHelper.PopupLocation.Left,
										PopupLocationHelper.PopupLocation.Below,
										PopupLocationHelper.PopupLocation.Right
									});
								}
							}
							current.Use();
						}
						else
						{
							if (Event.current.clickCount == 2)
							{
								if (@object)
								{
									AssetDatabase.OpenAsset(@object);
									GUIUtility.ExitGUI();
								}
								current.Use();
							}
						}
					}
				}
				goto IL_5EB;
			case EventType.Repaint:
			{
				GUIContent content;
				if (EditorGUI.showMixedValue)
				{
					content = EditorGUI.s_MixedValueContent;
				}
				else
				{
					if (property != null)
					{
						content = EditorGUIUtility.TempContent(property.objectReferenceStringValue, AssetPreview.GetMiniThumbnail(property.objectReferenceValue));
						obj = property.objectReferenceValue;
						if (obj != null)
						{
							UnityEngine.Object[] references = new UnityEngine.Object[]
							{
								obj
							};
							if (validator(references, objType, property) == null)
							{
								content = EditorGUIUtility.TempContent("Type mismatch");
							}
						}
					}
					else
					{
						content = EditorGUIUtility.ObjectContent(obj, objType);
					}
				}
				switch (objectFieldVisualType)
				{
				case EditorGUI.ObjectFieldVisualType.IconAndText:
					EditorGUI.BeginHandleMixedValueContentColor();
					style.Draw(position, content, id, DragAndDrop.activeControlID == id);
					EditorGUI.EndHandleMixedValueContentColor();
					break;
				case EditorGUI.ObjectFieldVisualType.LargePreview:
					EditorGUI.DrawObjectFieldLargeThumb(position, id, obj, content);
					break;
				case EditorGUI.ObjectFieldVisualType.MiniPreivew:
					EditorGUI.DrawObjectFieldMiniThumb(position, id, obj, content);
					break;
				default:
					throw new ArgumentOutOfRangeException();
				}
				goto IL_5EB;
			}
			case EventType.DragUpdated:
			case EventType.DragPerform:
				if (dropRect.Contains(Event.current.mousePosition) && GUI.enabled)
				{
					UnityEngine.Object[] objectReferences = DragAndDrop.objectReferences;
					UnityEngine.Object object2 = validator(objectReferences, objType, property);
					if (object2 != null && !allowSceneObjects && !EditorUtility.IsPersistent(object2))
					{
						object2 = null;
					}
					if (object2 != null)
					{
						DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
						if (eventType == EventType.DragPerform)
						{
							if (property != null)
							{
								property.objectReferenceValue = object2;
							}
							else
							{
								obj = object2;
							}
							GUI.changed = true;
							DragAndDrop.AcceptDrag();
							DragAndDrop.activeControlID = 0;
						}
						else
						{
							DragAndDrop.activeControlID = id;
						}
						Event.current.Use();
					}
				}
				goto IL_5EB;
			case EventType.ExecuteCommand:
			{
				string commandName = current.commandName;
				if (commandName == "ObjectSelectorUpdated" && ObjectSelector.get.objectSelectorID == id && GUIUtility.keyboardControl == id)
				{
					UnityEngine.Object[] references2 = new UnityEngine.Object[]
					{
						ObjectSelector.GetCurrentObject()
					};
					UnityEngine.Object object3 = validator(references2, objType, property);
					if (property != null)
					{
						property.objectReferenceValue = object3;
					}
					GUI.changed = true;
					current.Use();
					return object3;
				}
				goto IL_5EB;
			}
			case EventType.DragExited:
				if (GUI.enabled)
				{
					HandleUtility.Repaint();
				}
				goto IL_5EB;
			}
			goto IL_FF;
			IL_5EB:
			EditorGUIUtility.SetIconSize(iconSize);
			return obj;
		}
예제 #33
0
 private static void DragNumberValue(EditorGUI.RecycledTextEditor editor, Rect position, Rect dragHotZone, int id, bool isDouble, ref double doubleVal, ref long longVal, string formatString, GUIStyle style, double dragSensitivity)
 {
   Event current = Event.current;
   switch (current.GetTypeForControl(id))
   {
     case EventType.MouseDown:
       if (!dragHotZone.Contains(current.mousePosition) || current.button != 0)
         break;
       EditorGUIUtility.editingTextField = false;
       GUIUtility.hotControl = id;
       if (EditorGUI.activeEditor != null)
         EditorGUI.activeEditor.EndEditing();
       current.Use();
       GUIUtility.keyboardControl = id;
       EditorGUI.s_DragCandidateState = 1;
       EditorGUI.s_DragStartValue = doubleVal;
       EditorGUI.s_DragStartIntValue = longVal;
       EditorGUI.s_DragStartPos = current.mousePosition;
       EditorGUI.s_DragSensitivity = dragSensitivity;
       current.Use();
       EditorGUIUtility.SetWantsMouseJumping(1);
       break;
     case EventType.MouseUp:
       if (GUIUtility.hotControl != id || EditorGUI.s_DragCandidateState == 0)
         break;
       GUIUtility.hotControl = 0;
       EditorGUI.s_DragCandidateState = 0;
       current.Use();
       EditorGUIUtility.SetWantsMouseJumping(0);
       break;
     case EventType.MouseDrag:
       if (GUIUtility.hotControl != id)
         break;
       switch (EditorGUI.s_DragCandidateState)
       {
         case 1:
           if ((double) (Event.current.mousePosition - EditorGUI.s_DragStartPos).sqrMagnitude > (double) EditorGUI.kDragDeadzone)
           {
             EditorGUI.s_DragCandidateState = 2;
             GUIUtility.keyboardControl = id;
           }
           current.Use();
           return;
         case 2:
           if (isDouble)
           {
             doubleVal = doubleVal + (double) HandleUtility.niceMouseDelta * EditorGUI.s_DragSensitivity;
             doubleVal = MathUtils.RoundBasedOnMinimumDifference(doubleVal, EditorGUI.s_DragSensitivity);
           }
           else
             longVal = longVal + (long) Math.Round((double) HandleUtility.niceMouseDelta * EditorGUI.s_DragSensitivity);
           GUI.changed = true;
           current.Use();
           return;
         default:
           return;
       }
     case EventType.KeyDown:
       if (GUIUtility.hotControl != id || current.keyCode != KeyCode.Escape || EditorGUI.s_DragCandidateState == 0)
         break;
       doubleVal = EditorGUI.s_DragStartValue;
       longVal = EditorGUI.s_DragStartIntValue;
       GUI.changed = true;
       GUIUtility.hotControl = 0;
       current.Use();
       break;
     case EventType.Repaint:
       EditorGUIUtility.AddCursorRect(dragHotZone, MouseCursor.SlideArrow);
       break;
   }
 }
예제 #34
0
		internal static UnityEngine.Object DoDropField(Rect position, int id, Type objType, EditorGUI.ObjectFieldValidator validator, bool allowSceneObjects, GUIStyle style)
		{
			if (validator == null)
			{
				validator = new EditorGUI.ObjectFieldValidator(EditorGUI.ValidateObjectFieldAssignment);
			}
			Event current = Event.current;
			EventType eventType = current.type;
			if (!GUI.enabled && GUIClip.enabled && Event.current.rawType == EventType.MouseDown)
			{
				eventType = Event.current.rawType;
			}
			EventType eventType2 = eventType;
			switch (eventType2)
			{
			case EventType.Repaint:
				style.Draw(position, GUIContent.none, id, DragAndDrop.activeControlID == id);
				goto IL_144;
			case EventType.Layout:
				IL_6B:
				if (eventType2 != EventType.DragExited)
				{
					goto IL_144;
				}
				if (GUI.enabled)
				{
					HandleUtility.Repaint();
				}
				goto IL_144;
			case EventType.DragUpdated:
			case EventType.DragPerform:
				if (position.Contains(Event.current.mousePosition) && GUI.enabled)
				{
					UnityEngine.Object[] objectReferences = DragAndDrop.objectReferences;
					UnityEngine.Object @object = validator(objectReferences, objType, null);
					if (@object != null && !allowSceneObjects && !EditorUtility.IsPersistent(@object))
					{
						@object = null;
					}
					if (@object != null)
					{
						DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
						if (eventType == EventType.DragPerform)
						{
							GUI.changed = true;
							DragAndDrop.AcceptDrag();
							DragAndDrop.activeControlID = 0;
							Event.current.Use();
							return @object;
						}
						DragAndDrop.activeControlID = id;
						Event.current.Use();
					}
				}
				goto IL_144;
			}
			goto IL_6B;
			IL_144:
			return null;
		}
예제 #35
0
 internal static double DoDoubleField(EditorGUI.RecycledTextEditor editor, Rect position, Rect dragHotZone, int id, double value, string formatString, GUIStyle style, bool draggable)
 {
   return EditorGUI.DoDoubleField(editor, position, dragHotZone, id, value, formatString, style, draggable, Event.current.GetTypeForControl(id) != EventType.MouseDown ? 0.0 : EditorGUI.CalculateFloatDragSensitivity(EditorGUI.s_DragStartValue));
 }
예제 #36
0
			public static void HorizontalMeter(Rect position, float value, ref EditorGUI.VUMeter.SmoothingData data, Texture2D foregroundTexture, Color peakColor)
			{
				if (Event.current.type != EventType.Repaint)
				{
					return;
				}
				float value2;
				float peak;
				EditorGUI.VUMeter.SmoothVUMeterData(ref value, ref data, out value2, out peak);
				EditorGUI.VUMeter.HorizontalMeter(position, value2, peak, foregroundTexture, peakColor);
			}
예제 #37
0
 internal static long DoLongField(EditorGUI.RecycledTextEditor editor, Rect position, Rect dragHotZone, int id, long value, string formatString, GUIStyle style, bool draggable, double dragSensitivity)
 {
   double doubleVal = 0.0;
   EditorGUI.DoNumberField(editor, position, dragHotZone, id, false, ref doubleVal, ref value, formatString, style, draggable, dragSensitivity);
   return value;
 }
예제 #38
0
        void DrawCall(Rect rect, int index, bool isactive, bool isfocused)
        {
            var propCall = _callsProp.GetArrayElementAtIndex(index);

            rect.height = lineHeight;
            rect.y     += verticalSpacing;

            Rect functionRect = rect;

            functionRect.width *= 0.4f;

            Rect argRect = rect;

            argRect.xMin = functionRect.xMax + 5;

            var propTarget     = propCall.FindPropertyRelative(targetPath);
            var propMethodName = propCall.FindPropertyRelative(methodNamePath);
            var propMode       = propCall.FindPropertyRelative(modePath);
            var propArgument   = propCall.FindPropertyRelative(argumentPath);
            var targetObject   = propTarget.objectReferenceValue;

            Color c = GUI.backgroundColor;

            GUI.backgroundColor = Color.white;

            var modeEnum = GetMode(propMode);

            if (targetObject != null && !string.IsNullOrEmpty(propMethodName.stringValue))
            {
                EditorGUI.PropertyField(argRect, propArgument, GUIContent.none);
            }

            using (new EditorGUI.DisabledScope(targetObject == null))
            {
                EditorGUI.BeginProperty(functionRect, GUIContent.none, propMethodName);
                {
                    var buttonLabel = new StringBuilder();
                    if (targetObject == null || string.IsNullOrEmpty(propMethodName.stringValue))
                    {
                        buttonLabel.Append(strNoBinding);
                    }
                    else
                    {
                        if (FindMethod(targetObject, propMethodName.stringValue, modeEnum) == null)
                        {
                            buttonLabel.Append("<Missing>");
                        }
                        buttonLabel.Append(targetObject.GetType().Name);
                        if (!string.IsNullOrEmpty(propMethodName.stringValue))
                        {
                            buttonLabel.Append(".");
                            if (propMethodName.stringValue.StartsWith("set_"))
                            {
                                buttonLabel.Append(propMethodName.stringValue.Substring(4));
                            }
                            else
                            {
                                buttonLabel.Append(propMethodName.stringValue);
                            }
                        }
                    }

                    if (GUI.Button(functionRect, buttonLabel.ToString(), EditorStyles.popup))
                    {
                        BuildPopupList(targetObject, propCall).DropDown(functionRect);
                    }
                }
                EditorGUI.EndProperty();
            }
            GUI.backgroundColor = c;
        }
예제 #39
0
 internal static UnityEngine.Object MiniThumbnailObjectField(Rect position, GUIContent label, UnityEngine.Object obj, System.Type objType, EditorGUI.ObjectFieldValidator validator)
 {
   int controlId = GUIUtility.GetControlID(EditorGUI.s_ObjectFieldHash, EditorGUIUtility.native, position);
   Rect thumbRect;
   Rect labelRect;
   EditorGUI.GetRectsForMiniThumbnailField(position, out thumbRect, out labelRect);
   EditorGUI.HandlePrefixLabel(position, labelRect, label, controlId, EditorStyles.label);
   return EditorGUI.DoObjectField(thumbRect, thumbRect, controlId, obj, objType, (SerializedProperty) null, validator, false);
 }
예제 #40
0
 private static void SmoothVUMeterData(ref float value, ref EditorGUI.VUMeter.SmoothingData data, out float renderValue, out float renderPeak)
 {
   if ((double) value <= (double) data.lastValue)
   {
     value = Mathf.Lerp(data.lastValue, value, Time.smoothDeltaTime * 7f);
   }
   else
   {
     value = Mathf.Lerp(value, data.lastValue, Time.smoothDeltaTime * 2f);
     data.peakValue = value;
     data.peakValueTime = Time.realtimeSinceStartup;
   }
   if ((double) value > 1.11111116409302)
     value = 1.111111f;
   if ((double) data.peakValue > 1.11111116409302)
     data.peakValue = 1.111111f;
   renderValue = value * 0.9f;
   renderPeak = data.peakValue * 0.9f;
   data.lastValue = value;
 }
예제 #41
0
 internal static UnityEngine.Object DoObjectField(Rect position, Rect dropRect, int id, UnityEngine.Object obj, System.Type objType, SerializedProperty property, EditorGUI.ObjectFieldValidator validator, bool allowSceneObjects, GUIStyle style)
 {
   if (validator == null)
     validator = new EditorGUI.ObjectFieldValidator(EditorGUI.ValidateObjectFieldAssignment);
   Event current = Event.current;
   EventType eventType1 = current.type;
   if (!GUI.enabled && GUIClip.enabled && Event.current.rawType == EventType.MouseDown)
     eventType1 = Event.current.rawType;
   bool flag1 = EditorGUIUtility.HasObjectThumbnail(objType);
   EditorGUI.ObjectFieldVisualType objectFieldVisualType = EditorGUI.ObjectFieldVisualType.IconAndText;
   if (flag1 && (double) position.height <= 18.0 && (double) position.width <= 32.0)
     objectFieldVisualType = EditorGUI.ObjectFieldVisualType.MiniPreivew;
   else if (flag1 && (double) position.height > 16.0)
     objectFieldVisualType = EditorGUI.ObjectFieldVisualType.LargePreview;
   Vector2 iconSize = EditorGUIUtility.GetIconSize();
   if (objectFieldVisualType == EditorGUI.ObjectFieldVisualType.IconAndText)
     EditorGUIUtility.SetIconSize(new Vector2(12f, 12f));
   else if (objectFieldVisualType == EditorGUI.ObjectFieldVisualType.LargePreview)
     EditorGUIUtility.SetIconSize(new Vector2(64f, 64f));
   EventType eventType2 = eventType1;
   switch (eventType2)
   {
     case EventType.KeyDown:
       if (GUIUtility.keyboardControl == id)
       {
         if (current.keyCode == KeyCode.Backspace || current.keyCode == KeyCode.Delete)
         {
           if (property != null)
             property.objectReferenceValue = (UnityEngine.Object) null;
           else
             obj = (UnityEngine.Object) null;
           GUI.changed = true;
           current.Use();
         }
         if (current.MainActionKeyForControl(id))
         {
           ObjectSelector.get.Show(obj, objType, property, allowSceneObjects);
           ObjectSelector.get.objectSelectorID = id;
           current.Use();
           GUIUtility.ExitGUI();
           break;
         }
         break;
       }
       break;
     case EventType.Repaint:
       GUIContent content;
       if (EditorGUI.showMixedValue)
         content = EditorGUI.s_MixedValueContent;
       else if (property != null)
       {
         content = EditorGUIUtility.TempContent(property.objectReferenceStringValue, (Texture) AssetPreview.GetMiniThumbnail(property.objectReferenceValue));
         obj = property.objectReferenceValue;
         if (obj != (UnityEngine.Object) null)
         {
           UnityEngine.Object[] references = new UnityEngine.Object[1]{ obj };
           if (validator(references, objType, property) == (UnityEngine.Object) null)
             content = EditorGUIUtility.TempContent("Type mismatch");
         }
       }
       else
         content = EditorGUIUtility.ObjectContent(obj, objType);
       switch (objectFieldVisualType)
       {
         case EditorGUI.ObjectFieldVisualType.IconAndText:
           EditorGUI.BeginHandleMixedValueContentColor();
           style.Draw(position, content, id, DragAndDrop.activeControlID == id);
           EditorGUI.EndHandleMixedValueContentColor();
           break;
         case EditorGUI.ObjectFieldVisualType.LargePreview:
           EditorGUI.DrawObjectFieldLargeThumb(position, id, obj, content);
           break;
         case EditorGUI.ObjectFieldVisualType.MiniPreivew:
           EditorGUI.DrawObjectFieldMiniThumb(position, id, obj, content);
           break;
         default:
           throw new ArgumentOutOfRangeException();
       }
     case EventType.DragUpdated:
     case EventType.DragPerform:
       if (dropRect.Contains(Event.current.mousePosition) && GUI.enabled)
       {
         UnityEngine.Object[] objectReferences = DragAndDrop.objectReferences;
         UnityEngine.Object target = validator(objectReferences, objType, property);
         if (target != (UnityEngine.Object) null && !allowSceneObjects && !EditorUtility.IsPersistent(target))
           target = (UnityEngine.Object) null;
         if (target != (UnityEngine.Object) null)
         {
           DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
           if (eventType1 == EventType.DragPerform)
           {
             if (property != null)
               property.objectReferenceValue = target;
             else
               obj = target;
             GUI.changed = true;
             DragAndDrop.AcceptDrag();
             DragAndDrop.activeControlID = 0;
           }
           else
             DragAndDrop.activeControlID = id;
           Event.current.Use();
           break;
         }
         break;
       }
       break;
     case EventType.ExecuteCommand:
       if (current.commandName == "ObjectSelectorUpdated" && ObjectSelector.get.objectSelectorID == id && GUIUtility.keyboardControl == id)
       {
         UnityEngine.Object[] references = new UnityEngine.Object[1]
         {
           ObjectSelector.GetCurrentObject()
         };
         UnityEngine.Object @object = validator(references, objType, property);
         if (property != null)
           property.objectReferenceValue = @object;
         GUI.changed = true;
         current.Use();
         return @object;
       }
       break;
     case EventType.DragExited:
       if (GUI.enabled)
       {
         HandleUtility.Repaint();
         break;
       }
       break;
     default:
       if (eventType2 == EventType.MouseDown && Event.current.button == 0 && position.Contains(Event.current.mousePosition))
       {
         Rect rect;
         switch (objectFieldVisualType)
         {
           case EditorGUI.ObjectFieldVisualType.IconAndText:
             rect = new Rect(position.xMax - 15f, position.y, 15f, position.height);
             break;
           case EditorGUI.ObjectFieldVisualType.LargePreview:
             rect = new Rect(position.xMax - 36f, position.yMax - 14f, 36f, 14f);
             break;
           case EditorGUI.ObjectFieldVisualType.MiniPreivew:
             rect = new Rect(position.xMax - 15f, position.y, 15f, position.height);
             break;
           default:
             throw new ArgumentOutOfRangeException();
         }
         EditorGUIUtility.editingTextField = false;
         if (rect.Contains(Event.current.mousePosition))
         {
           if (GUI.enabled)
           {
             GUIUtility.keyboardControl = id;
             ObjectSelector.get.Show(obj, objType, property, allowSceneObjects);
             ObjectSelector.get.objectSelectorID = id;
             current.Use();
             GUIUtility.ExitGUI();
             break;
           }
           break;
         }
         UnityEngine.Object @object = property == null ? obj : property.objectReferenceValue;
         Component component = @object as Component;
         if ((bool) ((UnityEngine.Object) component))
           @object = (UnityEngine.Object) component.gameObject;
         if (EditorGUI.showMixedValue)
           @object = (UnityEngine.Object) null;
         if (Event.current.clickCount == 1)
         {
           GUIUtility.keyboardControl = id;
           if ((bool) @object)
           {
             bool flag2 = current.shift || current.control;
             if (!flag2)
               EditorGUIUtility.PingObject(@object);
             if (flag2 && @object is Texture)
               PopupWindowWithoutFocus.Show(new RectOffset(6, 3, 0, 3).Add(position), (PopupWindowContent) new ObjectPreviewPopup(@object), new PopupLocationHelper.PopupLocation[3]
               {
                 PopupLocationHelper.PopupLocation.Left,
                 PopupLocationHelper.PopupLocation.Below,
                 PopupLocationHelper.PopupLocation.Right
               });
           }
           current.Use();
           break;
         }
         if (Event.current.clickCount == 2)
         {
           if ((bool) @object)
           {
             AssetDatabase.OpenAsset(@object);
             GUIUtility.ExitGUI();
           }
           current.Use();
           break;
         }
         break;
       }
       break;
   }
   EditorGUIUtility.SetIconSize(iconSize);
   return obj;
 }
예제 #42
0
        private void SearchField(Event e)
        {
            string searchBarName = "SearchFilter";

            if (e.commandName == "Find")
            {
                if (e.type == EventType.ExecuteCommand)
                {
                    EditorGUI.FocusTextInControl(searchBarName);
                }

                if (e.type != EventType.Layout)
                {
                    e.Use();
                }
            }

            string searchText = LogEntries.wrapped.searchString;

            if (e.type == EventType.KeyDown)
            {
                if (e.keyCode == KeyCode.Escape)
                {
                    searchText = string.Empty;
                    GUIUtility.keyboardControl = m_ListView.ID;
                    Repaint();
                }
                else if ((e.keyCode == KeyCode.UpArrow || e.keyCode == KeyCode.DownArrow) &&
                         GUI.GetNameOfFocusedControl() == searchBarName)
                {
                    GUIUtility.keyboardControl = m_ListView.ID;
                }
            }

            GUI.SetNextControlName(searchBarName);
            Rect rect = GUILayoutUtility.GetRect(0, EditorGUILayout.kLabelFloatMaxW * 1.5f, EditorGUI.kSingleLineHeight,
                                                 EditorGUI.kSingleLineHeight, EditorStyles.toolbarSearchField, GUILayout.MinWidth(100),
                                                 GUILayout.MaxWidth(300));

            bool showHistory   = LogEntries.wrapped.searchHistory[0].Length != 0;
            Rect popupPosition = rect;

            popupPosition.width = 20;
            if (showHistory && Event.current.type == EventType.MouseDown && popupPosition.Contains(Event.current.mousePosition))
            {
                GUIUtility.keyboardControl = 0;
                EditorUtility.DisplayCustomMenu(rect, EditorGUIUtility.TempContent(LogEntries.wrapped.searchHistory), -1, OnSetFilteringHistoryCallback, null);
                Event.current.Use();
            }

            LogEntries.wrapped.searchString = EditorGUI.ToolbarSearchField(
#if !UNITY_2018_1_OR_NEWER
                GUIUtility.GetControlID("EditorSearchField".GetHashCode(), FocusType.Keyboard, position),
#endif
                rect, searchText, showHistory);

            if (GUILayout.Button(new GUIContent(iconCustomFiltersMono, Constants.CustomFiltersLabel), EditorStyles.toolbarDropDown))
            {
                Rect buttonRect = rect;
                buttonRect.x += buttonRect.width;
                var menuData     = new CustomFiltersItemProvider(LogEntries.wrapped.customFilters);
                var flexibleMenu = new FlexibleMenu(menuData, -1, new CustomFiltersModifyItemUI(), null);
                PopupWindow.Show(buttonRect, flexibleMenu);
            }

            int iconIndex = 0;
            foreach (var filter in LogEntries.wrapped.customFilters.filters)
            {
                if (iconIndex >= 7)
                {
                    iconIndex = 0;
                }
                filter.toggle = GUILayout.Toggle(filter.toggle, new GUIContent(filter.filter, iconCustomFiltersSmalls[iconIndex++]), Constants.MiniButton);
            }
        }
예제 #43
0
 public static void VerticalMeter(Rect position, float value, ref EditorGUI.VUMeter.SmoothingData data, Texture2D foregroundTexture, Color peakColor)
 {
   if (Event.current.type != EventType.Repaint)
     return;
   float renderValue;
   float renderPeak;
   EditorGUI.VUMeter.SmoothVUMeterData(ref value, ref data, out renderValue, out renderPeak);
   EditorGUI.VUMeter.VerticalMeter(position, renderValue, renderPeak, foregroundTexture, peakColor);
 }
예제 #44
0
        private void Buttons()
        {
            bool enabled = GUI.enabled;

            GUI.enabled &= !EditorApplication.isPlayingOrWillChangePlaymode;
            if (Lightmapping.lightingDataAsset && !Lightmapping.lightingDataAsset.isValid)
            {
                EditorGUILayout.HelpBox(Lightmapping.lightingDataAsset.validityErrorMessage, MessageType.Warning);
            }
            EditorGUILayout.Space();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            Rect rect = GUILayoutUtility.GetRect(LightingWindow.Styles.ContinuousBakeLabel, GUIStyle.none);

            EditorGUI.BeginProperty(rect, LightingWindow.Styles.ContinuousBakeLabel, this.m_WorkflowMode);
            bool flag = this.m_WorkflowMode.intValue == 0;

            EditorGUI.BeginChangeCheck();
            flag = GUILayout.Toggle(flag, LightingWindow.Styles.ContinuousBakeLabel, new GUILayoutOption[0]);
            if (EditorGUI.EndChangeCheck())
            {
                this.m_WorkflowMode.intValue = ((!flag) ? 1 : 0);
            }
            EditorGUI.EndProperty();
            using (new EditorGUI.DisabledScope(flag))
            {
                bool flag2 = flag || !Lightmapping.isRunning;
                if (flag2)
                {
                    if (EditorGUI.ButtonWithDropdownList(LightingWindow.Styles.BuildLabel, LightingWindow.s_BakeModeOptions, new GenericMenu.MenuFunction2(this.BakeDropDownCallback), new GUILayoutOption[]
                    {
                        GUILayout.Width(170f)
                    }))
                    {
                        this.DoBake();
                        GUIUtility.ExitGUI();
                    }
                }
                else
                {
                    if (LightmapEditorSettings.lightmapper == LightmapEditorSettings.Lightmapper.PathTracer && this.m_EnabledBakedGI.boolValue && GUILayout.Button("Force Stop", new GUILayoutOption[]
                    {
                        GUILayout.Width(150f)
                    }))
                    {
                        Lightmapping.ForceStop();
                    }
                    if (GUILayout.Button("Cancel", new GUILayoutOption[]
                    {
                        GUILayout.Width(150f)
                    }))
                    {
                        Lightmapping.Cancel();
                        UsabilityAnalytics.Track("/LightMapper/Cancel");
                    }
                }
            }
            GUILayout.EndHorizontal();
            EditorGUILayout.Space();
            GUI.enabled = enabled;
        }
예제 #45
0
        void OnGUI()
        {
            Event e = Event.current;

            LoadIcons();
            LogEntries.wrapped.UpdateEntries();

            if (!m_HasUpdatedGuiStyles)
            {
                m_LineHeight   = Mathf.RoundToInt(Constants.ErrorStyle.lineHeight);
                m_BorderHeight = Constants.ErrorStyle.border.top + Constants.ErrorStyle.border.bottom;
                UpdateListView();
            }

            GUILayout.BeginHorizontal(Constants.Toolbar);

            if (GUILayout.Button(Constants.ClearLabel, Constants.MiniButton))
            {
                LogEntries.Clear();
                GUIUtility.keyboardControl = 0;
            }

            int currCount = LogEntries.wrapped.GetCount();

            if (m_ListView.totalRows != currCount && m_ListView.totalRows > 0)
            {
                // scroll bar was at the bottom?
                if (m_ListView.scrollPos.y >= m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight)
                {
                    m_ListView.scrollPos.y = currCount * RowHeight - ms_LVHeight;
                }
            }

            if (LogEntries.wrapped.searchFrame)
            {
                LogEntries.wrapped.searchFrame = false;
                int selectedIndex = LogEntries.wrapped.GetSelectedEntryIndex();
                if (selectedIndex != -1)
                {
                    int showIndex = selectedIndex + 1;
                    if (currCount > showIndex)
                    {
                        int showCount = ms_LVHeight / RowHeight;
                        showIndex = showIndex + showCount / 2;
                    }
                    m_ListView.scrollPos.y = showIndex * RowHeight - ms_LVHeight;
                }
            }

            EditorGUILayout.Space();

            bool wasCollapsed = LogEntries.wrapped.collapse;

            LogEntries.wrapped.collapse = GUILayout.Toggle(wasCollapsed, Constants.CollapseLabel, Constants.MiniButton);

            bool collapsedChanged = (wasCollapsed != LogEntries.wrapped.collapse);

            if (collapsedChanged)
            {
                // unselect if collapsed flag changed
                m_ListView.row = -1;

                // scroll to bottom
                m_ListView.scrollPos.y = LogEntries.wrapped.GetCount() * RowHeight;
            }

            SetFlag(ConsoleFlags.ClearOnPlay, GUILayout.Toggle(HasFlag(ConsoleFlags.ClearOnPlay), Constants.ClearOnPlayLabel, Constants.MiniButton));
#if UNITY_2019_1_OR_NEWER
            SetFlag(ConsoleFlags.ClearOnBuild, GUILayout.Toggle(HasFlag(ConsoleFlags.ClearOnBuild), Constants.ClearOnBuildLabel, Constants.MiniButton));
#endif
            SetFlag(ConsoleFlags.ErrorPause, GUILayout.Toggle(HasFlag(ConsoleFlags.ErrorPause), Constants.ErrorPauseLabel, Constants.MiniButton));

#if UNITY_2018_3_OR_NEWER
            ConnectionGUILayout.AttachToPlayerDropdown(m_ConsoleAttachToPlayerState, EditorStyles.toolbarDropDown);
#endif

            EditorGUILayout.Space();

            if (m_DevBuild)
            {
                GUILayout.FlexibleSpace();
                SetFlag(ConsoleFlags.StopForAssert, GUILayout.Toggle(HasFlag(ConsoleFlags.StopForAssert), Constants.StopForAssertLabel, Constants.MiniButton));
                SetFlag(ConsoleFlags.StopForError, GUILayout.Toggle(HasFlag(ConsoleFlags.StopForError), Constants.StopForErrorLabel, Constants.MiniButton));
            }

            GUILayout.FlexibleSpace();

            // Search bar
            GUILayout.Space(4f);
            SearchField(e);

            int errorCount = 0, warningCount = 0, logCount = 0;
            LogEntries.wrapped.GetCountsByType(ref errorCount, ref warningCount, ref logCount);
            EditorGUI.BeginChangeCheck();
            bool setLogFlag     = GUILayout.Toggle(LogEntries.wrapped.HasFlag((int)ConsoleFlags.LogLevelLog), new GUIContent((logCount <= 999 ? logCount.ToString() : "999+"), logCount > 0 ? iconInfoSmall : iconInfoMono), Constants.MiniButton);
            bool setWarningFlag = GUILayout.Toggle(LogEntries.wrapped.HasFlag((int)ConsoleFlags.LogLevelWarning), new GUIContent((warningCount <= 999 ? warningCount.ToString() : "999+"), warningCount > 0 ? iconWarnSmall : iconWarnMono), Constants.MiniButton);
            bool setErrorFlag   = GUILayout.Toggle(LogEntries.wrapped.HasFlag((int)ConsoleFlags.LogLevelError), new GUIContent((errorCount <= 999 ? errorCount.ToString() : "999+"), errorCount > 0 ? iconErrorSmall : iconErrorMono), Constants.MiniButton);
            // Active entry index may no longer be valid
            if (EditorGUI.EndChangeCheck())
            {
            }

            LogEntries.wrapped.SetFlag((int)ConsoleFlags.LogLevelLog, setLogFlag);
            LogEntries.wrapped.SetFlag((int)ConsoleFlags.LogLevelWarning, setWarningFlag);
            LogEntries.wrapped.SetFlag((int)ConsoleFlags.LogLevelError, setErrorFlag);

            if (GUILayout.Button(new GUIContent(errorCount > 0 ? iconFirstErrorSmall : iconFirstErrorMono, Constants.FirstErrorLabel), Constants.MiniButton))
            {
                int firstErrorIndex = LogEntries.wrapped.GetFirstErrorEntryIndex();
                if (firstErrorIndex != -1)
                {
                    SetActiveEntry(firstErrorIndex);
                    LogEntries.wrapped.searchFrame = true;
                }
            }

            GUILayout.EndHorizontal();

            SplitterGUILayout.BeginVerticalSplit(spl);
            int rowHeight = RowHeight;
            EditorGUIUtility.SetIconSize(new Vector2(rowHeight, rowHeight));
            GUIContent tempContent      = new GUIContent();
            int        id               = GUIUtility.GetControlID(0);
            int        rowDoubleClicked = -1;

            /////@TODO: Make Frame selected work with ListViewState
            using (new GettingLogEntriesScope(m_ListView))
            {
                int  selectedRow      = -1;
                bool openSelectedItem = false;
                bool collapsed        = LogEntries.wrapped.collapse;
                foreach (ListViewElement el in ListViewGUI.ListView(m_ListView, Constants.Box))
                {
                    if (e.type == EventType.MouseDown && e.button == 0 && el.position.Contains(e.mousePosition))
                    {
                        m_ListView.row = el.row;
                        selectedRow    = el.row;
                        if (e.clickCount == 2)
                        {
                            openSelectedItem = true;
                        }
                    }
                    else if (e.type == EventType.Repaint)
                    {
                        int    mode           = 0;
                        int    entryCount     = 0;
                        int    searchIndex    = 0;
                        int    searchEndIndex = 0;
                        string text           = LogEntries.wrapped.GetEntryLinesAndFlagAndCount(el.row, ref mode, ref entryCount,
                                                                                                ref searchIndex, ref searchEndIndex);
                        ConsoleFlags flag       = (ConsoleFlags)mode;
                        bool         isSelected = LogEntries.wrapped.IsEntrySelected(el.row);

                        // Draw the background
                        GUIStyle s = el.row % 2 == 0 ? Constants.OddBackground : Constants.EvenBackground;
                        s.Draw(el.position, false, false, isSelected, false);

                        // Draw the icon
#if !UNITY_2017_3_OR_NEWER
                        if (Constants.LogStyleLineCount == 1)
                        {
                            Rect rt = el.position;
                            rt.x     += 6f;
                            rt.y     += 2f;
                            rt.width  = 16f;
                            rt.height = 16f;
                            GUI.DrawTexture(rt, GetIconForErrorMode(flag, false));
                        }
                        else
#endif
                        {
                            GUIStyle iconStyle = GetStyleForErrorMode(flag, true, Constants.LogStyleLineCount == 1);
                            iconStyle.Draw(el.position, false, false, isSelected, false);
                        }

                        // Draw the text
                        tempContent.text = text;
                        GUIStyle errorModeStyle = GetStyleForErrorMode(flag, false, Constants.LogStyleLineCount == 1);

                        if (string.IsNullOrEmpty(LogEntries.wrapped.searchString) || searchIndex == -1 || searchIndex >= text.Length)
                        {
                            errorModeStyle.Draw(el.position, tempContent, id, isSelected);
                        }
                        else
                        {
                            errorModeStyle.DrawWithTextSelection(el.position, tempContent, GUIUtility.keyboardControl, searchIndex, searchEndIndex);
                        }

                        if (collapsed)
                        {
                            Rect badgeRect = el.position;
                            tempContent.text = entryCount.ToString(CultureInfo.InvariantCulture);
                            Vector2 badgeSize = Constants.CountBadge.CalcSize(tempContent);
                            badgeRect.xMin  = badgeRect.xMax - badgeSize.x;
                            badgeRect.yMin += ((badgeRect.yMax - badgeRect.yMin) - badgeSize.y) * 0.5f;
                            badgeRect.x    -= 5f;
                            GUI.Label(badgeRect, tempContent, Constants.CountBadge);
                        }
                    }
                }

                if (selectedRow != -1)
                {
                    if (m_ListView.scrollPos.y >= m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight)
                    {
                        m_ListView.scrollPos.y = m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight - 1;
                    }
                }

                // Make sure the selected entry is up to date
                if (m_ListView.totalRows == 0 || m_ListView.row >= m_ListView.totalRows || m_ListView.row < 0)
                {
                }
                else
                {
                    if (m_ListView.selectionChanged)
                    {
                        SetActiveEntry(m_ListView.row);
                    }
                }

                // Open entry using return key
                if ((GUIUtility.keyboardControl == m_ListView.ID) && (e.type == EventType.KeyDown) && (e.keyCode == KeyCode.Return) && (m_ListView.row != 0))
                {
                    selectedRow      = m_ListView.row;
                    openSelectedItem = true;
                }

                if (e.type != EventType.Layout && ListViewGUI.ilvState.rectHeight != 1)
                {
                    ms_LVHeight = ListViewGUI.ilvState.rectHeight;
                }

                if (openSelectedItem)
                {
                    rowDoubleClicked = selectedRow;
                    e.Use();
                }

                if (selectedRow != -1)
                {
                    SetActiveEntry(selectedRow);
                }
            }

            // Prevent dead locking in EditorMonoConsole by delaying callbacks (which can log to the console) until after LogEntries.EndGettingEntries() has been
            // called (this releases the mutex in EditorMonoConsole so logging again is allowed). Fix for case 1081060.
            if (rowDoubleClicked != -1)
            {
                LogEntries.wrapped.StacktraceListView_RowGotDoubleClicked();
            }

            EditorGUIUtility.SetIconSize(Vector2.zero);

            StacktraceListView(e, tempContent);

            SplitterGUILayout.EndVerticalSplit();

            // Copy & Paste selected item
            if ((e.type == EventType.ValidateCommand || e.type == EventType.ExecuteCommand) && e.commandName == "Copy")
            {
                if (e.type == EventType.ExecuteCommand)
                {
                    LogEntries.wrapped.StacktraceListView_CopyAll();
                }
                e.Use();
            }
        }
예제 #46
0
		public int GUIListOfFloatObjectToggleFields(GUIContent label, SerializedProperty[] objectProps, EditorGUI.ObjectFieldValidator validator, GUIContent buttonTooltip, bool allowCreation)
		{
			int result = -1;
			int num = objectProps.Length;
			Rect rect = GUILayoutUtility.GetRect(0f, (float)(15 * num));
			rect.height = 13f;
			float num2 = 10f;
			float num3 = 35f;
			float num4 = 10f;
			float width = rect.width - num2 - num3 - num4 * 2f - 9f;
			ModuleUI.PrefixLabel(rect, label);
			for (int i = 0; i < num; i++)
			{
				SerializedProperty serializedProperty = objectProps[i];
				Rect rect2 = new Rect(rect.x + num2 + num3 + num4, rect.y, width, rect.height);
				int controlID = GUIUtility.GetControlID(1235498, EditorGUIUtility.native, rect2);
				EditorGUI.DoObjectField(rect2, rect2, controlID, null, null, serializedProperty, validator, true, ParticleSystemStyles.Get().objectField);
				if (serializedProperty.objectReferenceValue == null)
				{
					rect2 = new Rect(rect.xMax - 9f, rect.y + 3f, 9f, 9f);
					if (!allowCreation || GUI.Button(rect2, buttonTooltip ?? GUIContent.none, ParticleSystemStyles.Get().plus))
					{
						result = i;
					}
				}
				rect.y += 15f;
			}
			return result;
		}
예제 #47
0
 public int GUIListOfFloatObjectToggleFields(GUIContent label, SerializedProperty[] objectProps, EditorGUI.ObjectFieldValidator validator, GUIContent buttonTooltip, bool allowCreation)
 {
   int num1 = -1;
   int length = objectProps.Length;
   Rect rect1 = GUILayoutUtility.GetRect(0.0f, (float) (15 * length));
   rect1.height = 13f;
   float num2 = 10f;
   float num3 = 35f;
   float num4 = 10f;
   float width = (float) ((double) rect1.width - (double) num2 - (double) num3 - (double) num4 * 2.0 - 9.0);
   ModuleUI.PrefixLabel(rect1, label);
   for (int index = 0; index < length; ++index)
   {
     SerializedProperty objectProp = objectProps[index];
     Rect rect2 = new Rect(rect1.x + num2 + num3 + num4, rect1.y, width, rect1.height);
     int controlId = GUIUtility.GetControlID(1235498, EditorGUIUtility.native, rect2);
     EditorGUI.DoObjectField(rect2, rect2, controlId, (UnityEngine.Object) null, (System.Type) null, objectProp, validator, true, ParticleSystemStyles.Get().objectField);
     if (objectProp.objectReferenceValue == (UnityEngine.Object) null)
     {
       rect2 = new Rect(rect1.xMax - 9f, rect1.y + 3f, 9f, 9f);
       if (!allowCreation || GUI.Button(rect2, buttonTooltip ?? GUIContent.none, ParticleSystemStyles.Get().plus))
         num1 = index;
     }
     rect1.y += 15f;
   }
   return num1;
 }
예제 #48
0
    void showTerrainGUI()
    {
        // General Terrain Settings
        showTerrainUI = EGL.Foldout(showTerrainUI, terrainLabel, true);

        if (showTerrainUI)
        {
            GL.BeginHorizontal();
            GL.BeginVertical();
            GL.Label(new GUIContent("Terrain Size", "The width in units of the generated Terrain Object."));
            GL.Label(new GUIContent("Terrain Height Range", "The min and max height in units of the generated Terrain Object."));
            GL.Label("Water?");
            GL.EndVertical();

            GL.BeginVertical();
            CG.terrainSize = EGL.IntSlider(CG.terrainSize, 512, 2048);
            GL.BeginHorizontal();
            GL.TextField(CG.minHeight.ToString("F1"));
            EGL.MinMaxSlider(ref CG.minHeight, ref CG.maxHeight, CG.terrainSize * -CG.highwayMaxSlope, CG.terrainSize * CG.highwayMaxSlope);
            GL.TextField(CG.maxHeight.ToString("F1"));
            GL.EndHorizontal();
            EG.BeginDisabledGroup(CG.minHeight > 0);
            rWaterToggle.target = EGL.Toggle(rWaterToggle.target);
            EG.EndDisabledGroup();
            GL.EndVertical();
            GL.EndHorizontal();

            GL.BeginVertical();
            GL.Label("Height Map Generation", EditorStyles.centeredGreyMiniLabel);
            GL.BeginHorizontal("box");
            GL.BeginVertical();
            GL.Label("Octaves");
            GL.Label("Persistance");
            GL.Label("Zoom");
            GL.Label("Seed");
            GL.EndVertical();

            GL.BeginVertical();
            CG.terrainOctaves     = EGL.IntSlider(CG.terrainOctaves, 1, 6);
            CG.terrainPersistance = EGL.Slider(CG.terrainPersistance, 0, 0.7f);
            CG.terrainZoom        = EGL.Slider(CG.terrainZoom, 0.01f, 0.04f);
            GL.BeginHorizontal();
            EG.BeginDisabledGroup(rTerrainSeed.target == false);
            CG.terrainSeed = EGL.IntSlider(CG.terrainSeed, 0, int.MaxValue);
            EG.EndDisabledGroup();
            rTerrainSeed.target = EGL.Toggle(rTerrainSeed.target);
            GL.EndHorizontal();
            GL.Space(20);
            GL.BeginHorizontal();
            GL.Label("Or import your custom height map: ");
            CG.terrainMap = (Texture2D)EGL.ObjectField(CG.terrainMap, typeof(Texture2D), false);
            GL.EndHorizontal();
            GL.EndVertical();


            GL.EndHorizontal();
            GL.EndVertical();

            GL.BeginHorizontal();
            if (GL.Button("Generate New Terrain"))
            {
                if (rTerrainSeed.target == false && CG.terrainMap == null)
                {
                    CG.terrainSeed = Random.Range(0, int.MaxValue);
                }
                CG.rWater = rWaterToggle.target;
                generator.generateTerrain();
                isTerrain = true;
            }
            EG.BeginDisabledGroup(!isTerrain);
            if (GL.Button("Save and Proceed"))
            {
                terrainGenerated = true;
                terrainLabel     = "1. Terrain Generation - COMPLETED ✔";
                if (CityGeneratorUI.DebugMode)
                {
                    Debug.Log("Terrain Generated");
                }
                showTerrainUI = false;
                showPopUI     = true;
            }
            EG.EndDisabledGroup();

            GL.EndHorizontal();
        }
    }
예제 #49
0
    void showPopulationMapGUI()
    {
        EG.BeginDisabledGroup(!(terrainGenerated));
        showPopUI = EGL.Foldout(showPopUI, populationLabel, true);
        if (showPopUI)
        {
            GL.BeginVertical();
            GL.BeginHorizontal("box");
            GL.BeginVertical();
            GL.Label("Octaves");
            GL.Label("Persistance");
            GL.Label("Zoom");
            GL.Label("Seed");
            GL.EndVertical();

            GL.BeginVertical();
            CG.popOctaves     = EGL.IntSlider(CG.popOctaves, 1, 6);
            CG.popPersistance = EGL.Slider(CG.popPersistance, 0, 0.5f);
            CG.popZoom        = EGL.Slider(CG.popZoom, 0, 0.05f);
            GL.BeginHorizontal();
            EG.BeginDisabledGroup(rPopSeed.target == false);
            CG.popSeed = EGL.IntSlider(CG.popSeed, 0, int.MaxValue);
            EG.EndDisabledGroup();
            rPopSeed.target = EGL.Toggle(rPopSeed.target);
            GL.EndHorizontal();

            GL.Space(20);

            GL.BeginHorizontal();
            GL.Label("Or import your custom pop map: ");
            CG.popMapInput = (Texture2D)EGL.ObjectField(CG.popMapInput, typeof(Texture2D), false);
            GL.EndHorizontal();
            GL.EndVertical();

            GL.EndHorizontal();
            GL.EndVertical();

            GL.BeginHorizontal();
            if (GL.Button("Generate Population Map"))
            {
                if (rPopSeed.target == false && CG.popMapInput == null)
                {
                    CG.popSeed = Random.Range(0, int.MaxValue);
                }
                generator.generatePopulationMap();
                isPopMap   = true;
                CG.showPop = true;
            }

            EG.BeginDisabledGroup(!isPopMap);
            GL.BeginHorizontal();
            GL.FlexibleSpace();
            CG.showPop = EGL.ToggleLeft("Preview Pop Map", CG.showPop);
            GL.EndHorizontal();

            GL.EndHorizontal();
            if (GL.Button("Save and Proceed"))
            {
                populationGenerated = true;
                populationLabel     = "2. Population Map Generation - COMPLETED ✔";
                showPopUI           = false;
                CG.showPop          = false;
                showGrowthUI        = true;
            }
            EG.EndDisabledGroup();
        }
        EG.EndDisabledGroup();
    }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.PropertyField(m_Sprite, Contents.spriteLabel);

            EditorGUILayout.PropertyField(m_Color, Contents.colorLabel, true);

            FlipToggles();

            Rect r = GUILayoutUtility.GetRect(
                EditorGUILayout.kLabelFloatMinW, EditorGUILayout.kLabelFloatMaxW,
                EditorGUI.kSingleLineHeight, EditorGUI.kSingleLineHeight);

            EditorGUI.showMixedValue = m_Material.hasMultipleDifferentValues;
            Object currentMaterialRef  = m_Material.GetArrayElementAtIndex(0).objectReferenceValue;
            Object returnedMaterialRef = EditorGUI.ObjectField(r, Contents.materialLabel, currentMaterialRef, typeof(Material), false);

            if (returnedMaterialRef != currentMaterialRef)
            {
                m_Material.GetArrayElementAtIndex(0).objectReferenceValue = returnedMaterialRef;
            }
            EditorGUI.showMixedValue = false;

            EditorGUILayout.PropertyField(m_DrawMode, Contents.drawModeLabel);

            m_ShowDrawMode.target = ShouldShowDrawMode();
            if (EditorGUILayout.BeginFadeGroup(m_ShowDrawMode.faded))
            {
                string notFullRectWarning = GetSpriteNotFullRectWarning();
                if (notFullRectWarning != null)
                {
                    EditorGUILayout.HelpBox(notFullRectWarning, MessageType.Warning);
                }

                EditorGUI.indentLevel++;
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel(Contents.sizeLabel);
                EditorGUI.showMixedValue = m_Size.hasMultipleDifferentValues;
                FloatFieldLabelAbove(Contents.widthLabel, m_Size.FindPropertyRelative("x"));
                FloatFieldLabelAbove(Contents.heightLabel, m_Size.FindPropertyRelative("y"));
                EditorGUI.showMixedValue = false;
                EditorGUILayout.EndHorizontal();

                m_ShowTileMode.target = ShouldShowTileMode();
                if (EditorGUILayout.BeginFadeGroup(m_ShowTileMode.faded))
                {
                    EditorGUILayout.PropertyField(m_SpriteTileMode, Contents.fullTileLabel);

                    m_ShowAdaptiveThreshold.target = ShouldShowAdaptiveThreshold();
                    if (EditorGUILayout.BeginFadeGroup(m_ShowAdaptiveThreshold.faded))
                    {
                        EditorGUI.indentLevel++;
                        EditorGUILayout.Slider(m_AdaptiveModeThreshold, 0.0f, 1.0f, Contents.fullTileThresholdLabel);
                        EditorGUI.indentLevel--;
                    }
                    EditorGUILayout.EndFadeGroup();
                }
                EditorGUILayout.EndFadeGroup();
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFadeGroup();

            RenderSortingLayerFields();

            EditorGUILayout.PropertyField(m_MaskInteraction, Contents.maskInteractionLabel);

            EditorGUILayout.PropertyField(m_SpriteSortPoint, Contents.spriteSortPointLabel);

            RenderRenderingLayer();

            CheckForErrors();

            serializedObject.ApplyModifiedProperties();
        }