Exemplo n.º 1
0
        private void DrawTarget(UnityObject target)
        {
            Action <UnityObject, BaseGUI> draw;

            if (customEditors.TryGetValue(target.GetType(), out draw))
            {
                draw(target, gui);
            }
            else
            {
                RecursiveDrawer.DrawRecursive(target, gui, id, unityTarget);
            }
        }
Exemplo n.º 2
0
        public InlineDrawer()
        {
            customEditors = new Dictionary <Type, Action <UnityObject, BaseGUI> >
            {
                {
                    typeof(Transform), (target, gui) =>
                    {
                        RecursiveDrawer.DrawRecursive(target, gui, id, target,
                                                      "localPosition", "localRotation", "localScale");
                    }
                },
                {
                    typeof(Rigidbody), (target, gui) =>
                    {
                        RecursiveDrawer.DrawRecursive(target, gui, id, target,
                                                      "mass", "drag", "angularDrag", "useGravity", "isKinematic", "interpolation", "collisionDetectionMode");

                        using (gui.Indent())
                        {
                            var rb = target as Rigidbody;
                            rb.constraints = (RigidbodyConstraints)gui.BunnyMask("Constraints", rb.constraints);
                        }
                    }
                },
                {
                    typeof(BoxCollider), (target, gui) =>
                    {
                        RecursiveDrawer.DrawRecursive(target, gui, id, target,
                                                      "isTrigger", "sharedMaterial", "center", "size");
                    }
                },
                {
                    typeof(SphereCollider), (target, gui) =>
                    {
                        RecursiveDrawer.DrawRecursive(target, gui, id, target,
                                                      "isTrigger", "sharedMaterial", "center", "radius");
                    }
                },
                {
                    typeof(Animator), (target, gui) =>
                    {
                        RecursiveDrawer.DrawRecursive(target, gui, id, target,
                                                      "runtimeAnimatorController", "avatar", "applyRootMotion", "updateMode", "cullingMode");
                    }
                },
                {
                    typeof(Camera), (target, gui) =>
                    {
                        RecursiveDrawer.DrawRecursive(target, gui, id, target,
                                                      "clearFlags", "backgroundColor", "cullingMask", "nearClipPlane", "farClipPlane",
                                                      "rect", "depth", "renderingPath", "targetTexture", "useOcclusionCulling", "hdr",
                                                      "isOrthoGraphic");

                        // TODO: improve cullingMask drawing. right now it's a float, gui.Layer doesn't cut it too

                        using (gui.Indent())
                        {
                            var c = target as Camera;
                            if (c.orthographic)
                            {
                                c.orthographicSize = gui.Float("Size", c.orthographicSize);
                            }
                            else
                            {
                                c.fieldOfView = gui.FloatSlider("FOV", c.fieldOfView, 1, 179);
                            }
                        }
                    }
                },
                {
                    typeof(MeshRenderer), (target, gui) =>
                    {
                        RecursiveDrawer.DrawRecursive(target, gui, id, target,
                                                      "castShadows", "receiveShadows", "sharedMaterials", "useLightProbes");
                    }
                },
                {
                    typeof(AudioSource), (target, gui) =>
                    {
                        RecursiveDrawer.DrawRecursive(target, gui, id, target,
                                                      "mute", "bypassEffects", "bypassListenerEffects", "bypassReverbZones", "playOnAwake", "loop");

                        using (gui.Indent())
                        {
                            var source = target as AudioSource;
                            source.priority = gui.IntSlider("Priority", source.priority, 0, 128);
                            source.volume   = gui.FloatSlider("Volume", source.volume, 0f, 1f);
                            source.pitch    = gui.FloatSlider("Pitch", source.pitch, -3f, 3f);
                        }
                    }
                },
            };
        }