예제 #1
0
 private Action <ContactMaterial, int> PreContactMaterialEditor(ContactMaterialEntry[] entries)
 {
     return((cm, index) =>
     {
         using (InspectorGUI.IndentScope.Single) {
             entries[index].IsOriented = InspectorGUI.Toggle(GUI.MakeLabel("Is Oriented",
                                                                           false,
                                                                           "Enable/disable oriented friction models."),
                                                             entries[index].IsOriented);
             if (entries[index].IsOriented)
             {
                 using (InspectorGUI.IndentScope.Single) {
                     entries[index].ReferenceObject = (GameObject)EditorGUILayout.ObjectField(GUI.MakeLabel("Reference Object"),
                                                                                              entries[index].ReferenceObject,
                                                                                              typeof(GameObject),
                                                                                              true);
                     entries[index].PrimaryDirection = (FrictionModel.PrimaryDirection)EditorGUILayout.EnumPopup(GUI.MakeLabel("Primary Direction",
                                                                                                                               false,
                                                                                                                               "Primary direction in object local frame."),
                                                                                                                 entries[index].PrimaryDirection,
                                                                                                                 InspectorEditor.Skin.Popup);
                 }
             }
         }
     });
 }
예제 #2
0
        public override void OnPreTargetMembersGUI()
        {
            Track.RemoveInvalidWheels();

            bool toggleSelectWheel       = false;
            bool toggleDisableCollisions = false;

            if (!EditorApplication.isPlaying && NumTargets == 1)
            {
                InspectorGUI.ToolButtons(InspectorGUI.ToolButtonData.Create(ToolIcon.FindTrackWheel,
                                                                            SelectWheelToolEnable,
                                                                            "Select track wheel to add in scene view.",
                                                                            () => toggleSelectWheel = true),
                                         InspectorGUI.ToolButtonData.Create(ToolIcon.DisableCollisions,
                                                                            DisableCollisionsTool,
                                                                            "Disable collisions between this track and other objects.",
                                                                            () => toggleDisableCollisions = true));

                if (DisableCollisionsTool)
                {
                    GetChild <DisableCollisionsTool>().OnInspectorGUI();
                }
            }

            if (toggleSelectWheel)
            {
                SelectWheelToolEnable = !SelectWheelToolEnable;
            }
            if (toggleDisableCollisions)
            {
                DisableCollisionsTool = !DisableCollisionsTool;
            }
        }
예제 #3
0
        public void OnInspectorGUI(bool onlyNameAndMaterial = false)
        {
            if (!onlyNameAndMaterial)
            {
                InspectorGUI.OnDropdownToolBegin("Create visual representation of this shape.");
            }

            Name = EditorGUILayout.TextField(GUI.MakeLabel("Name"),
                                             Name,
                                             InspectorEditor.Skin.TextField);

            InspectorGUI.UnityMaterial(GUI.MakeLabel("Material"),
                                       Material,
                                       newMaterial => Material = newMaterial);

            if (!onlyNameAndMaterial)
            {
                var createCancelState = InspectorGUI.PositiveNegativeButtons(Preview != null,
                                                                             "Create",
                                                                             "Create new shape visual.",
                                                                             "Cancel");

                InspectorGUI.OnDropdownToolEnd();

                if (createCancelState == InspectorGUI.PositiveNegativeResult.Positive)
                {
                    CreateShapeVisual();
                }
                if (createCancelState != InspectorGUI.PositiveNegativeResult.Neutral)
                {
                    PerformRemoveFromParent();
                }
            }
        }
예제 #4
0
        public override void OnPreTargetMembersGUI()
        {
            bool toggleSelectTireAndRim = false;
            bool toggleSelectTire       = false;
            bool toggleSelectRim        = false;

            if (!EditorApplication.isPlaying && NumTargets == 1)
            {
                InspectorGUI.ToolButtons(InspectorGUI.ToolButtonData.Create(ToolIcon.FindTireRim,
                                                                            SelectTireAndRimToolEnable,
                                                                            "Find Tire, Rim and Tire <-> Rim constraint by selecting Tire in scene view.",
                                                                            () => toggleSelectTireAndRim = true),
                                         InspectorGUI.ToolButtonData.Create(ToolIcon.FindTire,
                                                                            SelectTireToolEnable,
                                                                            "Find Tire by selecting Tire in scene view.",
                                                                            () => toggleSelectTire = true),
                                         InspectorGUI.ToolButtonData.Create(ToolIcon.FindRim,
                                                                            SelectRimToolEnable,
                                                                            "Find Rim by selecting Rim in scene view.",
                                                                            () => toggleSelectRim = true));
            }

            if (toggleSelectTireAndRim)
            {
                SelectTireAndRimToolEnable = !SelectTireAndRimToolEnable;
            }
            if (toggleSelectTire)
            {
                SelectTireToolEnable = !SelectTireToolEnable;
            }
            if (toggleSelectRim)
            {
                SelectRimToolEnable = !SelectRimToolEnable;
            }
        }
예제 #5
0
        public override void OnPostTargetMembersGUI()
        {
            if (NumTargets != 1)
            {
                return;
            }

            using (new GUI.EnabledBlock(!EditorApplication.isPlayingOrWillChangePlaymode)) {
                Undo.RecordObject(Sink, "Sink template");

                var sinkAll = InspectorGUI.Toggle(GUI.MakeLabel("Sink All"), Sink.SinkAll);
                if (sinkAll != Sink.SinkAll)
                {
                    Sink.SinkAll = sinkAll;
                }

                if (!Sink.SinkAll)
                {
                    InspectorGUI.ToolListGUI(this,
                                             Sink.Templates,
                                             "Sink Templates",
                                             m_availableTemplates,
                                             OnTemplateAdd,
                                             OnTemplateRemove);
                }
            }
        }
예제 #6
0
        private Tuple <PropertyWrapper, CableProperties.Direction, object> OnPropertyGUI(CableProperties.Direction dir,
                                                                                         CableProperties properties,
                                                                                         GUISkin skin)
        {
            Tuple <PropertyWrapper, CableProperties.Direction, object> changed = null;
            var data = EditorData.Instance.GetData(properties, "CableProperty" + dir.ToString());

            if (GUI.Foldout(data, GUI.MakeLabel(dir.ToString()), skin))
            {
                using (new GUI.Indent(12)) {
                    GUI.Separator();

                    var wrappers = PropertyWrapper.FindProperties <CableProperty>(System.Reflection.BindingFlags.Instance |
                                                                                  System.Reflection.BindingFlags.Public);
                    foreach (var wrapper in wrappers)
                    {
                        if (wrapper.GetContainingType() == typeof(float) && InspectorEditor.ShouldBeShownInInspector(wrapper.Member))
                        {
                            var value = EditorGUILayout.FloatField(InspectorGUI.MakeLabel(wrapper.Member),
                                                                   wrapper.Get <float>(properties[dir]));
                            if (UnityEngine.GUI.changed)
                            {
                                changed = new Tuple <PropertyWrapper, CableProperties.Direction, object>(wrapper, dir, value);
                                UnityEngine.GUI.changed = false;
                            }
                        }
                    }
                }
            }
            return(changed);
        }
예제 #7
0
        public override void OnPostTargetMembersGUI()
        {
            var skin = InspectorEditor.Skin;

            var beginWinches = GetTargets <Wire, WireWinch>(wire => wire.BeginWinch).Where(winch => winch != null);
            var endWinches   = GetTargets <Wire, WireWinch>(wire => wire.EndWinch).Where(winch => winch != null);

            if (beginWinches.Count() > 0)
            {
                GUILayout.Label(GUI.MakeLabel("Begin winch", true), skin.Label);
                using (InspectorGUI.IndentScope.Single) {
                    if (beginWinches.Count() != NumTargets)
                    {
                        InspectorGUI.WarningLabel("Not all selected wires has a begin winch.");
                    }
                    InspectorEditor.DrawMembersGUI(beginWinches.ToArray());
                }
            }
            if (endWinches.Count() > 0)
            {
                GUILayout.Label(GUI.MakeLabel("End winch", true), skin.Label);
                using (InspectorGUI.IndentScope.Single) {
                    if (endWinches.Count() != NumTargets)
                    {
                        InspectorGUI.WarningLabel("Not all selected wires has an end winch.");
                    }
                    InspectorEditor.DrawMembersGUI(endWinches.ToArray());
                }
            }
        }
예제 #8
0
        public override void OnPostTargetMembersGUI()
        {
            if (IsMultiSelect)
            {
                return;
            }

            InspectorGUI.HandleFrame(TrackWheel.Frame, 1);
        }
예제 #9
0
        private void HandleDownloadInstall()
        {
            var skin = InspectorEditor.Skin;
            var downloadOrInstallPressed = false;

            var rect     = EditorGUILayout.GetControlRect();
            var orgWidth = rect.width;

            rect.width = 74;

            var buttonText = m_status == Status.AwaitInstall ? "Install" : "Download";

            using (new GUI.EnabledBlock(m_status == Status.AwaitDownload ||
                                        (m_currentVersion.IsValid && m_status == Status.AwaitInstall)))
                downloadOrInstallPressed = UnityEngine.GUI.Button(rect,
                                                                  GUI.MakeLabel(buttonText),
                                                                  skin.Button);
            rect.x    += rect.width + EditorGUIUtility.standardVerticalSpacing;
            rect.width = orgWidth - rect.x;
            using (new GUI.EnabledBlock(m_status == Status.Downloading))
                EditorGUI.ProgressBar(rect,
                                      m_downloadProgress,
                                      m_serverVersion.VersionStringShort +
                                      (m_status == Status.Downloading ? $": { (int)(100.0f * m_downloadProgress + 0.5f) }%" : ""));

            if (m_status == Status.AwaitInstall)
            {
                InspectorGUI.Separator(1, 4);

                EditorGUILayout.LabelField(GUI.MakeLabel($"AGXDynamicsForUnity-{m_serverVersion.VersionStringShort} is ready to be installed!\n\n" +
                                                         GUI.AddColorTag("During the installation Unity will be restarted.",
                                                                         Color.Lerp(Color.red, Color.white, 0.25f))),
                                           skin.TextAreaMiddleCenter);
            }

            if (downloadOrInstallPressed)
            {
                if (m_status == Status.AwaitDownload)
                {
                    if (File.Exists(Target))
                    {
                        File.Delete(Target);
                    }

                    Web.RequestHandler.Get($"https://us.download.algoryx.se/AGXUnity/packages/{m_sourceFilename}",
                                           new FileInfo(Target).Directory,
                                           OnDownloadComplete,
                                           OnDownloadProgress);
                    m_status = Status.Downloading;
                }
                else if (m_status == Status.AwaitInstall)
                {
                    InstallTarget();
                }
            }
        }
예제 #10
0
 public override void OnPreTargetMembersGUI()
 {
     for (int i = 0; i < Targets.Length; ++i)
     {
         var root = Targets[i] as RestoredAssetsRoot;
         InspectorGUI.ToolArrayGUI(this,
                                   m_assets[i],
                                   $"[{m_assets[ i ].Length}] {root.Type.ToString().SplitCamelCase()} assets");
     }
 }
예제 #11
0
        public override void OnPreTargetMembersGUI()
        {
            Manager.RemoveNullEntries();

            InspectorGUI.ToolListGUI(this,
                                     Manager.ContactMaterials,
                                     Identifier,
                                     cm => Manager.Add(cm),
                                     cm => Manager.Remove(cm),
                                     PreContactMaterialEditor(Manager.ContactMaterialEntries));
        }
예제 #12
0
        public override void OnPostTargetMembersGUI()
        {
            if (IsMultiSelect)
            {
                return;
            }

            InspectorGUI.ToolArrayGUI(this, RigidBody.GetComponentsInChildren <Shape>(), "Shapes");

            InspectorGUI.ToolArrayGUI(this, m_constraints.ToArray(), "Constraints");
        }
예제 #13
0
        public override void OnPostTargetMembersGUI()
        {
            if (IsMultiSelect)
            {
                return;
            }

            var shapeVisual = ShapeVisual.Find(Shape);

            if (shapeVisual == null)
            {
                return;
            }

            var materials = shapeVisual.GetMaterials();

            if (materials.Length > 1)
            {
                var names = (from renderer in shapeVisual.GetComponentsInChildren <MeshRenderer>()
                             from material in renderer.sharedMaterials
                             select renderer.name).ToArray();

                var distinctMaterials = materials.Distinct().ToArray();
                var isExtended        = false;
                if (distinctMaterials.Length == 1)
                {
                    isExtended = ShapeVisualMaterialGUI("Common Render Material",
                                                        distinctMaterials[0],
                                                        newMaterial => shapeVisual.SetMaterial(newMaterial));
                }
                else
                {
                    isExtended = InspectorGUI.Foldout(EditorData.Instance.GetData(Shape, "Render Materials"),
                                                      GUI.MakeLabel("Render Materials"));
                }

                if (isExtended)
                {
                    using (InspectorGUI.IndentScope.Single)
                        for (int i = 0; i < materials.Length; ++i)
                        {
                            ShapeVisualMaterialGUI(names[i],
                                                   materials[i],
                                                   newMaterial => shapeVisual.ReplaceMaterial(i, newMaterial));
                        }
                }
            }
            else if (materials.Length == 1)
            {
                ShapeVisualMaterialGUI("Render Material",
                                       materials[0],
                                       newMaterial => shapeVisual.ReplaceMaterial(0, newMaterial));
            }
        }
예제 #14
0
 private void OnShapeConfigGUI(bool hasRadius)
 {
     using (InspectorGUI.IndentScope.Create(2)) {
         State.ShapeAsParent = InspectorGUI.Toggle(GUI.MakeLabel("Shape as parent"),
                                                   State.ShapeAsParent);
         if (hasRadius)
         {
             State.ExpandRadius = InspectorGUI.Toggle(GUI.MakeLabel("Expand radius"),
                                                      State.ExpandRadius);
         }
     }
 }
예제 #15
0
        public void ToolsGUI(bool isMultiSelect)
        {
            var  skin          = InspectorEditor.Skin;
            bool guiWasEnabled = UnityEngine.GUI.enabled;

            bool toggleSelectParent   = false;
            bool toggleFindGivenPoint = false;
            bool toggleSelectEdge     = false;
            bool togglePositionHandle = false;

            UnityEngine.GUI.enabled = !isMultiSelect;
            InspectorGUI.ToolButtons(InspectorGUI.ToolButtonData.Create(ToolIcon.SelectParent,
                                                                        SelectParent,
                                                                        "Select parent object by selecting object in scene view",
                                                                        () => toggleSelectParent = true,
                                                                        !isMultiSelect,
                                                                        () => UnityEngine.GUI.enabled = !isMultiSelect && guiWasEnabled),
                                     InspectorGUI.ToolButtonData.Create(ToolIcon.FindTransformGivenPoint,
                                                                        FindTransformGivenPointOnSurface,
                                                                        "Find position and rotation given point and direction on an objects surface",
                                                                        () => toggleFindGivenPoint = true,
                                                                        !isMultiSelect && guiWasEnabled),
                                     InspectorGUI.ToolButtonData.Create(ToolIcon.FindTransformGivenEdge,
                                                                        FindTransformGivenEdge,
                                                                        "Find position and rotation given a triangle or principal edge",
                                                                        () => toggleSelectEdge = true,
                                                                        !isMultiSelect && guiWasEnabled),
                                     InspectorGUI.ToolButtonData.Create(ToolIcon.TransformHandle,
                                                                        TransformHandleActive,
                                                                        "Position/rotation handle",
                                                                        () => togglePositionHandle = true,
                                                                        !isMultiSelect && guiWasEnabled));

            if (toggleSelectParent)
            {
                SelectParent = !SelectParent;
            }
            if (toggleFindGivenPoint)
            {
                FindTransformGivenPointOnSurface = !FindTransformGivenPointOnSurface;
            }
            if (toggleSelectEdge)
            {
                FindTransformGivenEdge = !FindTransformGivenEdge;
            }
            if (togglePositionHandle)
            {
                TransformHandleActive = !TransformHandleActive;
            }

            UnityEngine.GUI.enabled = guiWasEnabled;
        }
예제 #16
0
        private void MeshStatisticsGUI()
        {
            if (IsMultiSelect || Mesh.PrecomputedCollisionMeshes.Length == 0)
            {
                return;
            }

            EditorGUILayout.Space();

            InspectorGUI.BrandSeparator();

            var numCollisionMeshes = Mesh.PrecomputedCollisionMeshes.Length;
            var totNumVertices     = Mesh.PrecomputedCollisionMeshes.Select(collisionMesh => collisionMesh.Vertices.Length).Sum();
            var totNumTriangles    = Mesh.PrecomputedCollisionMeshes.Select(collisionMesh => collisionMesh.Indices.Length).Sum() / 3;
            var meshPlural         = numCollisionMeshes > 1 ? "es" : string.Empty;
            var summaryString      = $"Summary ({numCollisionMeshes} mesh{meshPlural}, {totNumTriangles} triangles, {totNumVertices} vertices)";

            if (InspectorGUI.Foldout(GetMeshStatisticsEditorData(Mesh),
                                     GUI.MakeLabel(summaryString)))
            {
                InspectorGUI.Separator();

                EditorGUILayout.LabelField(GUI.MakeLabel("Number of meshes"),
                                           GUI.MakeLabel(Mesh.PrecomputedCollisionMeshes.Length.ToString(), Color.green),
                                           InspectorEditor.Skin.TextField);
                using (InspectorGUI.IndentScope.Single) {
                    InspectorGUI.Separator();
                    for (int i = 0; i < Mesh.PrecomputedCollisionMeshes.Length; ++i)
                    {
                        var numVertices  = Mesh.PrecomputedCollisionMeshes[i].Vertices.Length;
                        var numTriangles = Mesh.PrecomputedCollisionMeshes[i].Indices.Length / 3;
                        EditorGUILayout.LabelField(GUI.MakeLabel($"[{i}] Number of triangles (vertices)"),
                                                   GUI.MakeLabel($"{numTriangles.ToString().Color( InspectorGUISkin.BrandColorBlue )} ({numVertices.ToString()})"),
                                                   InspectorEditor.Skin.TextField);
                    }
                    InspectorGUI.Separator();
                }
                var totNumTrianglesString  = totNumTriangles.ToString().Color(InspectorGUISkin.BrandColorBlue);
                var hasReducedNumTriangles = Mesh.Options != null &&
                                             (Mesh.Options.Mode != AGXUnity.Collide.CollisionMeshOptions.MeshMode.Trimesh ||
                                              Mesh.Options.ReductionEnabled);
                if (hasReducedNumTriangles)
                {
                    totNumTrianglesString += $" (originally: {Mesh.SourceObjects.Select( source => source.triangles.Length / 3 ).Sum().ToString().Color( Color.red )})";
                }
                EditorGUILayout.LabelField(GUI.MakeLabel("Total number of triangles"),
                                           GUI.MakeLabel(totNumTrianglesString),
                                           InspectorEditor.Skin.TextField);
            }
        }
예제 #17
0
        public static void AGXDynamicsForUnityLogoGUI()
        {
            GUILayout.BeginHorizontal(GUILayout.Width(570));
            GUILayout.Box(IconManager.GetAGXUnityLogo(),
                          GUI.Skin.customStyles[3],
                          GUILayout.Width(400),
                          GUILayout.Height(100));
            GUILayout.EndHorizontal();

            EditorGUILayout.LabelField("© " + System.DateTime.Now.Year + " Algoryx Simulation AB",
                                       InspectorEditor.Skin.LabelMiddleCenter);

            InspectorGUI.BrandSeparator(1, 6);
        }
예제 #18
0
        private NodeFoldoutState NodeFoldout(Route <NodeT> .ValidatedNode validatedNode)
        {
            if (s_invalidNodeStyle == null)
            {
                s_invalidNodeStyle = new GUIStyle(InspectorEditor.Skin.Label);
                s_invalidNodeStyle.normal.background = GUI.CreateColoredTexture(1,
                                                                                1,
                                                                                Color.Lerp(UnityEngine.GUI.color,
                                                                                           Color.red,
                                                                                           0.75f));
            }

            var state = new NodeFoldoutState();
            var node  = validatedNode.Node;

            var verticalScope = !validatedNode.Valid ?
                                new EditorGUILayout.VerticalScope(s_invalidNodeStyle) :
                                null;
            var horizontalScope = node == Selected ?
                                  new EditorGUILayout.HorizontalScope(InspectorEditor.Skin.Label) :
                                  new EditorGUILayout.HorizontalScope(InspectorEditor.Skin.TextArea);

            state.Foldout = InspectorGUI.Foldout(GetFoldoutData(node),
                                                 GUI.MakeLabel(GetNodeTypeString(node) + ' ' +
                                                               SelectGameObjectDropdownMenuTool.GetGUIContent(node.Parent).text,
                                                               !validatedNode.Valid,
                                                               validatedNode.ErrorString),
                                                 newState =>
            {
                Selected = newState ? node : null;
                EditorUtility.SetDirty(Parent);
            });

            state.InsertBefore = InspectorGUI.Button(MiscIcon.EntryInsertBefore,
                                                     true,
                                                     "Insert a new node before this node.",
                                                     GUILayout.Width(18));
            state.InsertAfter = InspectorGUI.Button(MiscIcon.EntryInsertAfter,
                                                    true,
                                                    "Insert a new node after this node.",
                                                    GUILayout.Width(18));
            state.Erase = InspectorGUI.Button(MiscIcon.EntryRemove,
                                              true,
                                              "Remove this node from the route.",
                                              GUILayout.Width(18));
            horizontalScope?.Dispose();
            verticalScope?.Dispose();

            return(state);
        }
        public void OnInspectorGUI()
        {
            if (RigidBody == null || GetChildren().Length == 0)
            {
                PerformRemoveFromParent();
                return;
            }

            var skin = InspectorEditor.Skin;

            InspectorGUI.OnDropdownToolBegin("Create visual representation of this rigid body given all supported shapes.");

            foreach (var tool in GetChildren <ShapeVisualCreateTool>())
            {
                if (ShapeVisual.HasShapeVisual(tool.Shape))
                {
                    continue;
                }

                EditorGUILayout.PrefixLabel(GUI.MakeLabel(tool.Shape.name,
                                                          true),
                                            skin.Label);
                using (InspectorGUI.IndentScope.Single)
                    tool.OnInspectorGUI(true);
            }

            var createCancelState = InspectorGUI.PositiveNegativeButtons(true,
                                                                         "Create",
                                                                         "Create shape visual for shapes that hasn't already got one.",
                                                                         "Cancel");

            if (createCancelState == InspectorGUI.PositiveNegativeResult.Positive)
            {
                foreach (var tool in GetChildren <ShapeVisualCreateTool>())
                {
                    if (!ShapeVisual.HasShapeVisual(tool.Shape))
                    {
                        tool.CreateShapeVisual();
                    }
                }
            }

            InspectorGUI.OnDropdownToolEnd();

            if (createCancelState != InspectorGUI.PositiveNegativeResult.Neutral)
            {
                PerformRemoveFromParent();
            }
        }
예제 #20
0
        public override void OnPostTargetMembersGUI()
        {
            if (NumTargets > 1)
            {
                return;
            }

            Undo.RecordObject(Track, "Track wheel add/remove.");

            InspectorGUI.ToolListGUI(this,
                                     Track.Wheels,
                                     "Wheels",
                                     wheel => Track.Add(wheel),
                                     wheel => Track.Remove(wheel));
        }
예제 #21
0
        private bool ShapeVisualMaterialGUI(string name, Material material, Action <Material> onNewMaterial)
        {
            var editorData = EditorData.Instance.GetData(Shape, "Visual_" + name);
            var result     = InspectorGUI.FoldoutObjectField(GUI.MakeLabel(name),
                                                             material,
                                                             typeof(Material),
                                                             editorData,
                                                             false) as Material;

            if (result != material)
            {
                onNewMaterial?.Invoke(result);
            }

            return(editorData.Bool);
        }
예제 #22
0
        private void OnWheelSelect(GameObject selection)
        {
            if (selection == null)
            {
                Debug.LogError("Invalid TrackWheel selection - selected object is null.");
                return;
            }

            if (selection.GetComponentInParent <RigidBody>() == null)
            {
                Debug.LogError("Invalid TrackWheel selection - unable to find RigidBody component.", selection);
                return;
            }

            var createNewComponent = selection.GetComponent <TrackWheel>() == null;

            if (createNewComponent)
            {
                Undo.RegisterCreatedObjectUndo(TrackWheel.Create(selection), "Create TrackWheel");
            }
            else if (Track.Contains(selection.GetComponent <TrackWheel>()))
            {
                Debug.Log("TrackWheel already part of Track - ignoring selection.");
                return;
            }
            // Reconfigure TrackWheel given new or the same selection.
            else
            {
                selection.GetComponent <TrackWheel>().Configure(selection);
            }

            if (!Track.Add(selection.GetComponent <TrackWheel>()))
            {
                Debug.LogError("Track failed to add TrackWheel instance.", Track);
                if (createNewComponent)
                {
                    Object.DestroyImmediate(selection.GetComponent <TrackWheel>());
                }
                return;
            }

            InspectorGUI.GetItemToolArrayGUIData(Track,
                                                 "Wheels",
                                                 selection.GetComponent <TrackWheel>()).Bool = true;

            EditorUtility.SetDirty(Track);
        }
예제 #23
0
        public override void OnPostTargetMembersGUI()
        {
            if (NumTargets != 1)
            {
                return;
            }

            Undo.RecordObject(Emitter, "Emitter template");
            InspectorGUI.ToolListGUI(this,
                                     Emitter.Templates,
                                     "Templates",
                                     OnAddTemplate,
                                     OnRemoveTemplate,
                                     OnRenderProbabilityWeight,
                                     null,
                                     m_availableTemplates);
        }
        private void HandleCollisionGroupEntry(CollisionGroupEntry entry)
        {
            bool buttonPressed = false;

            GUILayout.BeginHorizontal();
            {
                entry.Tag     = GUILayout.TextField(entry.Tag, InspectorEditor.Skin.TextField);
                buttonPressed = InspectorGUI.Button(MiscIcon.ContextDropdown,
                                                    true,
                                                    "Add collision group.",
                                                    1.1f,
                                                    GUILayout.Width(18));
            }
            GUILayout.EndHorizontal();

            if (buttonPressed)
            {
                m_findActiveGroupNameEntry = m_findActiveGroupNameEntry == entry ? null : entry;

                if (m_findActiveGroupNameEntry != null)
                {
                    m_groups = (from cg in Object.FindObjectsOfType <CollisionGroups>()
                                from cgEntry in cg.Groups
                                select cgEntry.Tag).Distinct().ToList();
                    m_groups.Sort(new StringLowerComparer());
                }
            }

            if (m_findActiveGroupNameEntry == entry && buttonPressed)
            {
                GenericMenu groupNameMenu = new GenericMenu();
                groupNameMenu.AddDisabledItem(GUI.MakeLabel("Groups in scene"));
                groupNameMenu.AddSeparator(string.Empty);
                foreach (var groupName in m_groups)
                {
                    groupNameMenu.AddItem(GUI.MakeLabel(groupName), groupName == m_findActiveGroupNameEntry.Tag, () =>
                    {
                        m_findActiveGroupNameEntry.Tag = groupName;
                        m_findActiveGroupNameEntry     = null;
                    });
                }

                groupNameMenu.ShowAsContext();
            }
        }
예제 #25
0
        private void HandleLineToolInspectorGUI(LineTool lineTool, string name)
        {
            // If visible, the vertical maker starts under the foldout, otherwise
            // render the marker through the fouldout label.
            var isVisible = GetLineToggleData(name).Bool;
            var color     = Color.Lerp(lineTool.Color, InspectorGUI.BackgroundColor, 0.25f);

            using (new InspectorGUI.VerticalScopeMarker(color)) {
                if (!InspectorGUI.Foldout(GetLineToggleData(name),
                                          GUI.MakeLabel(name, true)))
                {
                    return;
                }
                //using ( new InspectorGUI.VerticalScopeMarker( color ) )
                using (InspectorGUI.IndentScope.Single)
                    lineTool.OnInspectorGUI();
            }
        }
예제 #26
0
        public override void OnPreTargetMembersGUI()
        {
            if (m_edgeIssues.Count > 0)
            {
                foreach (var issue in m_edgeIssues)
                {
                    InspectorGUI.WarningLabel(issue);
                }
            }

            HandleLineToolInspectorGUI(TopEdgeLineTool, "Top Edge");

            HandleLineToolInspectorGUI(CuttingEdgeLineTool, "Cutting Edge");

            HandleLineToolInspectorGUI(CuttingDirectionLineTool, "Cutting Direction");

            m_requestEdgeValidate = true;
        }
예제 #27
0
        public override void OnPostTargetMembersGUI()
        {
            if (NumTargets > 1)
            {
                return;
            }

            InspectorGUI.ToolListGUI(this,
                                     Belt.Rollers,
                                     "Rollers",
                                     wheel => Belt.Add(wheel),
                                     wheel => Belt.Remove(wheel),
                                     OnRollerGUI);

            using (new GUI.EnabledBlock(false))
                InspectorGUI.ToolArrayGUI(this,
                                          Belt.Tracks,
                                          "Tracks");
        }
예제 #28
0
        public static void OnObjectListsGUI(CustomTargetTool context)
        {
            if (context == null)
            {
                return;
            }

            InspectorGUI.ToolArrayGUI(context,
                                      context.CollectComponentsInChildred <RigidBody>().ToArray(),
                                      "Rigid Bodies");

            InspectorGUI.ToolArrayGUI(context,
                                      context.CollectComponentsInChildred <Constraint>().ToArray(),
                                      "Constraints");

            InspectorGUI.ToolArrayGUI(context,
                                      context.CollectComponentsInChildred <Shape>().ToArray(),
                                      "Shapes");
        }
예제 #29
0
 public override void OnPostTargetMembersGUI()
 {
     if (Targets.Length == 1)
     {
         InspectorGUI.ToolArrayGUI(this, ArticulatedRoot.RigidBodies, "Rigid Bodies");
     }
     else
     {
         for (int i = 0; i < NumTargets; ++i)
         {
             var articulatedRoot = Targets[i] as ArticulatedRoot;
             InspectorGUI.ToolArrayGUI(this,
                                       articulatedRoot.RigidBodies,
                                       $"{GUI.AddColorTag( articulatedRoot.name, InspectorGUISkin.BrandColor )}: Rigid Bodies");
             if (i < NumTargets - 1)
             {
                 InspectorGUI.Separator();
             }
         }
     }
 }
예제 #30
0
        public override void OnPostTargetMembersGUI()
        {
            //var patchTerrainData = GUILayout.Button( GUI.MakeLabel( "Patch terrain data" ), InspectorEditor.Skin.Button );
            //if ( patchTerrainData ) {
            //  foreach ( var terrain in GetTargets<DeformableTerrain>() )
            //    terrain.PatchTerrainData();
            //}

            if (NumTargets > 1)
            {
                return;
            }

            Undo.RecordObject(DeformableTerrain, "Shovel add/remove.");

            InspectorGUI.ToolListGUI(this,
                                     DeformableTerrain.Shovels,
                                     "Shovels",
                                     shovel => DeformableTerrain.Add(shovel),
                                     shovel => DeformableTerrain.Remove(shovel));
        }