示例#1
0
        public void OnInspectorGUI(BaseDestructable[] targets)
        {
            obj.Update();
            EditorGUILayout.Separator();

            EditorGUILayout.PropertyField(useMyTag, new GUIContent("Use Tag Of This Object"));
            EditorGUILayout.PropertyField(useMyLayer, new GUIContent("Use Layer Of This Object"));

            EditorGUILayout.Separator();

            LinkObjectsOnDestroy linkObjects = targets[0].GetComponent<LinkObjectsOnDestroy>();
            bool linkedToggle = EditorGUILayout.Toggle(new GUIContent("Link Objects On Destroy"), linkObjects != null);
            if (linkedToggle && linkObjects == null)
            {
                foreach (var baseDestructable in targets)
                {
                    baseDestructable.gameObject.AddComponent<LinkObjectsOnDestroy>();
                }
            }
            else if (!linkedToggle && linkObjects != null)
            {
                Object.DestroyImmediate(linkObjects);
            }
            obj.ApplyModifiedProperties();
        }
示例#2
0
        public void OnInspectorGUI(BaseDestructable[] targets)
        {
            if (targets == null) return;

            GUILayout.Label("This tool can be used to create a structural integrity simulation of sorts.", EditorStyles.miniBoldLabel);
            GUILayout.Label("The joints used are a first pass implementation, \nand just work with binary connectivity rather than \nstrength of bonds.", EditorStyles.miniBoldLabel);

            GUILayout.Space(5);

            setting = (Quality)EditorGUILayout.EnumPopup("Quality Setting", setting);

            GUILayout.Space(5);

            if (GUILayout.Button("Select Adjacent Colliders", GUILayout.Width(300)))
            {
                foreach(BaseDestructable t in targets)
                {
                    if (cancellLastAction) break;
                    currentCollider = t.GetComponent<Collider>();
                    new FloodFiller3(Cancelled, SatisfiedContraint, SelectOnComplete, t.GetComponent<Collider>().bounds.center, t.GetComponent<Collider>().bounds.min, t.GetComponent<Collider>().bounds.size * 2, GetErrorRadiusFromQuality());
                }

                cancellLastAction = false;
            }

            if (GUILayout.Button("Connect Adjacent Colliders", GUILayout.Width(300)))
            {
                RemoveAllJoints(targets);
                foreach (BaseDestructable t in targets)
                {
                    if (cancellLastAction) break;

                    currentCollider = t.GetComponent<Collider>();
                    new FloodFiller3(Cancelled, SatisfiedContraint, OnComplete, t.GetComponent<Collider>().bounds.center, t.GetComponent<Collider>().bounds.min, t.GetComponent<Collider>().bounds.size * 2, GetErrorRadiusFromQuality());
                }

                cancellLastAction = false;
            }

            if (GUILayout.Button("Remove Joints", GUILayout.Width(300)))
            {
                RemoveAllJoints(targets);
            }
        }
示例#3
0
        public void OnInspectorGUI(BaseDestructable[] target)
        {
            if (target == null) return;

            obj.Update();

            EditorGUILayout.Separator();

            EditorGUILayout.PropertyField(destroyWhenOffscreen, new GUIContent("Destroy When Offscreen"));
            if (destroyWhenOffscreen.boolValue)
            {
                EditorGUILayout.PropertyField(offscreenTimer, new GUIContent("Time To Live Offscreen"), true);
            }
            EditorGUILayout.Separator();

            EditorGUILayout.PropertyField(useDestroyTimer, new GUIContent("Destroy After Time"));
            if (useDestroyTimer.boolValue)
            {
                EditorGUILayout.PropertyField(destroyTime, new GUIContent("Time To Live"), true);
            }
            EditorGUILayout.Separator();

            obj.ApplyModifiedProperties();
        }
示例#4
0
 public void OnSceneGUI(BaseDestructable target)
 {
 }
示例#5
0
 private static void RemoveAllJoints(BaseDestructable[] targets)
 {
     foreach (BaseDestructable t in targets)
     {
         if (t.GetComponent<RigidJoint>() != null)
         {
             foreach (var joint in t.GetComponents<RigidJoint>())
             {
                 Object.DestroyImmediate(joint);
             }
         }
     }
 }
示例#6
0
 public void OnPreDestruction(BaseDestructable objectToDestroy)
 {
 }
 void IDestructionAffectable.OnPreDestruction(BaseDestructable objectToDestroy)
 {
 }
示例#8
0
        public void OnInspectorGUI(BaseDestructable[] targets)
        {
            if (targets == null || targets.Length == 0 || targets[0] == null) return;
            if (targets.Length > 1)
            {
                using (new GUIColor(new Color(1.0f, 0.3f, 0.3f)))
                {
                    GUILayout.Label("Cannot use this tool with more than one destructable object selected.", EditorStyles.miniBoldLabel);
                }
                return;
            }

            if (targets[0].stickyZones != null && targets[0].stickyZones.Length != 0)
            {
                using (HorizontalScroll scrollbar = new HorizontalScroll(scrollPosition, Mathf.Min(100, targets[0].stickyZones.Length * 20 + 10)))
                {
                    scrollPosition = scrollbar.Position;
                    using (new Vertical("box"))
                    {
                        foreach (StickyZone zone in targets[0].stickyZones)
                        {
                            using (new Horizontal("toolbarbutton"))
                            {
                                if (zone == null)
                                {
                                    ArrayUtility.Remove(ref targets[0].stickyZones, null);
                                    break;
                                }

                                EditorGUILayout.ObjectField(zone, typeof(StickyZone), false);

                                using (new GUIBackgroundColor(new Color(0.8f, 0.8f, 1.0f)))
                                {
                                    if (GUILayout.Button("Select", "toolbarbutton"))
                                    {
                                        activeObject = zone.gameObject;
                                    }
                                }

                                if (GUILayout.Button("Zero", "toolbarbutton"))
                                {
                                    zone.transform.position = targets[0].transform.position + Vector3.one;
                                    zone.transform.rotation = targets[0].transform.rotation;
                                    zone.transform.localScale = Vector3.one;
                                }

                                using (new GUIBackgroundColor(Color.red))
                                {
                                    if (GUILayout.Button("X", "toolbarbutton", GUILayout.Width(30)))
                                    {
                                        Object.DestroyImmediate(zone.gameObject);
                                        ArrayUtility.Remove(ref targets[0].stickyZones, zone);
                                        break;
                                    }
                                }
                            }
                        }

                        GUILayout.FlexibleSpace();
                    }
                }
            }

            using (new Horizontal("toolbarbutton"))
            {
                GUILayout.FlexibleSpace();

                if (GUILayout.Button("Add New", "toolbarbutton"))
                {
                    var newZone = CreateStickyZone();
                    activeObject = newZone.gameObject;
                    ArrayUtility.Add(ref targets[0].stickyZones, newZone);
                }
            }
        }
示例#9
0
        public void OnSceneGUI(BaseDestructable target)
        {
            if (target == null) return;

            if (target.stickyZones == null)
            {
                target.stickyZones = new StickyZone[0];
            }

            for (int i = 0; i < target.stickyZones.Length; i++)
            {
                if (target.stickyZones[i] == null) continue;

                target.stickyZones[i].gameObject.name = "Sticky Zone - " + i;
                Handles.Label(target.stickyZones[i].transform.position, "   " + i.ToString(CultureInfo.InvariantCulture), EditorStyles.largeLabel);
            }

            if (activeObject == null) return;

            Event current = Event.current;
            switch (current.type)
            {
                case EventType.KeyDown:
                    if (current.keyCode == KeyCode.S)
                    {
                        showScaleHandle = true;
                    }
                    break;

                case EventType.KeyUp:
                    if (current.keyCode == KeyCode.S)
                    {
                        showScaleHandle = false;
                    }
                    break;
            }

            if (showScaleHandle)
            {
                activeObject.transform.localScale = Handles.ScaleHandle(activeObject.transform.localScale, activeObject.transform.position, Quaternion.identity, 1);
            }
            else
            {
                activeObject.transform.position = Handles.PositionHandle(activeObject.transform.position, Quaternion.identity);
            }
        }