示例#1
0
        private void OnSceneGUI()
        {
            AudioReverbZone audioReverbZone = (AudioReverbZone)this.target;
            Color           color           = Handles.color;

            if (audioReverbZone.enabled)
            {
                Handles.color = new Color(0.5f, 0.7f, 1f, 0.5f);
            }
            else
            {
                Handles.color = new Color(0.3f, 0.4f, 0.6f, 0.5f);
            }
            Vector3 position = audioReverbZone.transform.position;

            EditorGUI.BeginChangeCheck();
            float minDistance = Handles.RadiusHandle(Quaternion.identity, position, audioReverbZone.minDistance, true);
            float maxDistance = Handles.RadiusHandle(Quaternion.identity, position, audioReverbZone.maxDistance, true);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(audioReverbZone, "Reverb Distance");
                audioReverbZone.minDistance = minDistance;
                audioReverbZone.maxDistance = maxDistance;
            }
            Handles.color = color;
        }
 public void OnSceneGUI()
 {
     if (!Tools.viewToolActive)
     {
         bool             flag             = GUIUtility.hotControl == this.m_HandleControlID;
         CircleCollider2D circleCollider2D = (CircleCollider2D)base.target;
         Color            color            = Handles.color;
         Handles.color = Handles.s_ColliderHandleColor;
         bool enabled = GUI.enabled;
         if (!base.editingCollider && !flag)
         {
             GUI.enabled   = false;
             Handles.color = new Color(0f, 0f, 0f, 0.001f);
         }
         Vector3 lossyScale = circleCollider2D.transform.lossyScale;
         float   num        = Mathf.Max(Mathf.Max(Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.y)), Mathf.Abs(lossyScale.z));
         float   num2       = num * circleCollider2D.radius;
         num2 = Mathf.Abs(num2);
         num2 = Mathf.Max(num2, 1E-05f);
         Vector3 position   = circleCollider2D.transform.TransformPoint(circleCollider2D.offset);
         int     hotControl = GUIUtility.hotControl;
         float   num3       = Handles.RadiusHandle(Quaternion.identity, position, num2, true);
         if (GUI.changed)
         {
             Undo.RecordObject(circleCollider2D, "Adjust Radius");
             circleCollider2D.radius = num3 * 1f / num;
         }
         if (hotControl != GUIUtility.hotControl && GUIUtility.hotControl != 0)
         {
             this.m_HandleControlID = GUIUtility.hotControl;
         }
         Handles.color = color;
         GUI.enabled   = enabled;
     }
 }
        private void OnSceneGUI()
        {
            AudioReverbZone target = (AudioReverbZone)base.target;
            Color           color  = Handles.color;

            if (target.enabled)
            {
                Handles.color = new Color(0.5f, 0.7f, 1f, 0.5f);
            }
            else
            {
                Handles.color = new Color(0.3f, 0.4f, 0.6f, 0.5f);
            }
            Vector3 position = target.transform.position;

            EditorGUI.BeginChangeCheck();
            float num  = Handles.RadiusHandle(Quaternion.identity, position, target.minDistance, true);
            float num2 = Handles.RadiusHandle(Quaternion.identity, position, target.maxDistance, true);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(target, "Reverb Distance");
                target.minDistance = num;
                target.maxDistance = num2;
            }
            Handles.color = color;
        }
        public void OnSceneGUI()
        {
            bool           flag   = GUIUtility.hotControl == this.m_HandleControlID;
            SphereCollider target = (SphereCollider)this.target;
            Color          color  = Handles.color;

            Handles.color = !target.enabled ? Handles.s_ColliderHandleColorDisabled : Handles.s_ColliderHandleColor;
            bool enabled = GUI.enabled;

            if (!this.editingCollider && !flag)
            {
                GUI.enabled   = false;
                Handles.color = new Color(0.0f, 0.0f, 0.0f, 1f / 1000f);
            }
            Vector3    lossyScale = target.transform.lossyScale;
            float      num1       = Mathf.Max(Mathf.Max(Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.y)), Mathf.Abs(lossyScale.z));
            float      radius     = Mathf.Max(Mathf.Abs(num1 * target.radius), 1E-05f);
            Vector3    position   = target.transform.TransformPoint(target.center);
            Quaternion rotation   = target.transform.rotation;
            int        hotControl = GUIUtility.hotControl;
            float      num2       = Handles.RadiusHandle(rotation, position, radius, true);

            if (GUI.changed)
            {
                Undo.RecordObject((Object)target, "Adjust Radius");
                target.radius = num2 * 1f / num1;
            }
            if (hotControl != GUIUtility.hotControl && GUIUtility.hotControl != 0)
            {
                this.m_HandleControlID = GUIUtility.hotControl;
            }
            Handles.color = color;
            GUI.enabled   = enabled;
        }
示例#5
0
        void OnSceneGUI()
        {
            if (!target)
            {
                return;
            }
            AudioSource source = (AudioSource)target;

            Color tempColor = Handles.color;

            if (source.enabled)
            {
                Handles.color = new Color(0.50f, 0.70f, 1.00f, 0.5f);
            }
            else
            {
                Handles.color = new Color(0.30f, 0.40f, 0.60f, 0.5f);
            }

            Vector3 position = source.transform.position;

            EditorGUI.BeginChangeCheck();
            float minDistance = Handles.RadiusHandle(Quaternion.identity, position, source.minDistance, true);
            float maxDistance = Handles.RadiusHandle(Quaternion.identity, position, source.maxDistance, true);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(source, "AudioSource Distance");
                source.minDistance = minDistance;
                source.maxDistance = maxDistance;
            }

            Handles.color = tempColor;
        }
示例#6
0
        void OnSceneGUI()
        {
            AudioReverbZone zone = (AudioReverbZone)target;

            Color tempColor = Handles.color;

            if (zone.enabled)
            {
                Handles.color = new Color(0.50f, 0.70f, 1.00f, 0.5f);
            }
            else
            {
                Handles.color = new Color(0.30f, 0.40f, 0.60f, 0.5f);
            }

            Vector3 position = zone.transform.position;

            EditorGUI.BeginChangeCheck();
            float minDistance = Handles.RadiusHandle(Quaternion.identity, position, zone.minDistance, true);
            float maxDistance = Handles.RadiusHandle(Quaternion.identity, position, zone.maxDistance, true);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(zone, "Reverb Distance");
                zone.minDistance = minDistance;
                zone.maxDistance = maxDistance;
            }

            Handles.color = tempColor;
        }
示例#7
0
        private void OnSceneGUI()
        {
            Light light = (Light)this.target;
            Color color = Handles.color;

            if (light.enabled)
            {
                Handles.color = LightEditor.kGizmoLight;
            }
            else
            {
                Handles.color = LightEditor.kGizmoDisabledLight;
            }
            float num = light.range;

            switch (light.type)
            {
            case LightType.Spot:
            {
                Color color2 = Handles.color;
                color2.a      = Mathf.Clamp01(color.a * 2f);
                Handles.color = color2;
                Vector2 angleAndRange = new Vector2(light.spotAngle, light.range);
                angleAndRange = Handles.ConeHandle(light.transform.rotation, light.transform.position, angleAndRange, 1f, 1f, true);
                if (GUI.changed)
                {
                    Undo.RecordObject(light, "Adjust Spot Light");
                    light.spotAngle = angleAndRange.x;
                    light.range     = Mathf.Max(angleAndRange.y, 0.01f);
                }
                break;
            }

            case LightType.Point:
                num = Handles.RadiusHandle(Quaternion.identity, light.transform.position, num, true);
                if (GUI.changed)
                {
                    Undo.RecordObject(light, "Adjust Point Light");
                    light.range = num;
                }
                break;

            case LightType.Area:
            {
                EditorGUI.BeginChangeCheck();
                Vector2 areaSize = Handles.DoRectHandles(light.transform.rotation, light.transform.position, light.areaSize);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(light, "Adjust Area Light");
                    light.areaSize = areaSize;
                }
                break;
            }
            }
            Handles.color = color;
        }
示例#8
0
        private void OnSceneGUI()
        {
            Light target = (Light)this.target;
            Color color1 = Handles.color;

            Handles.color = !target.enabled ? LightEditor.kGizmoDisabledLight : LightEditor.kGizmoLight;
            float range = target.range;

            switch (target.type)
            {
            case LightType.Spot:
                Color color2 = Handles.color;
                color2.a      = Mathf.Clamp01(color1.a * 2f);
                Handles.color = color2;
                Vector2 angleAndRange = new Vector2(target.spotAngle, target.range);
                angleAndRange = Handles.ConeHandle(target.transform.rotation, target.transform.position, angleAndRange, 1f, 1f, true);
                if (GUI.changed)
                {
                    Undo.RecordObject((Object)target, "Adjust Spot Light");
                    target.spotAngle = angleAndRange.x;
                    target.range     = Mathf.Max(angleAndRange.y, 0.01f);
                    break;
                }
                break;

            case LightType.Point:
                float num = Handles.RadiusHandle(Quaternion.identity, target.transform.position, range, true);
                if (GUI.changed)
                {
                    Undo.RecordObject((Object)target, "Adjust Point Light");
                    target.range = num;
                    break;
                }
                break;

            case LightType.Area:
                EditorGUI.BeginChangeCheck();
                Vector2 vector2 = Handles.DoRectHandles(target.transform.rotation, target.transform.position, target.areaSize);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject((Object)target, "Adjust Area Light");
                    target.areaSize = vector2;
                    break;
                }
                break;
            }
            Handles.color = color1;
        }
        public void OnSceneGUI()
        {
            bool           flag   = GUIUtility.hotControl == this.m_HandleControlID;
            SphereCollider target = (SphereCollider)this.target;
            Color          color  = Handles.color;

            if (target.enabled)
            {
                Handles.color = Handles.s_ColliderHandleColor;
            }
            else
            {
                Handles.color = Handles.s_ColliderHandleColorDisabled;
            }
            bool enabled = GUI.enabled;

            if (!base.editingCollider && !flag)
            {
                GUI.enabled   = false;
                Handles.color = new Color(0f, 0f, 0f, 0.001f);
            }
            Vector3 lossyScale   = target.transform.lossyScale;
            float   a            = Mathf.Abs(lossyScale.x);
            float   introduced12 = Mathf.Max(a, Mathf.Abs(lossyScale.y));
            float   num          = Mathf.Max(introduced12, Mathf.Abs(lossyScale.z));
            float   f            = num * target.radius;

            f = Mathf.Max(Mathf.Abs(f), 1E-05f);
            Vector3    position   = target.transform.TransformPoint(target.center);
            Quaternion rotation   = target.transform.rotation;
            int        hotControl = GUIUtility.hotControl;
            float      num4       = Handles.RadiusHandle(rotation, position, f, true);

            if (GUI.changed)
            {
                Undo.RecordObject(target, "Adjust Radius");
                target.radius = (num4 * 1f) / num;
            }
            if ((hotControl != GUIUtility.hotControl) && (GUIUtility.hotControl != 0))
            {
                this.m_HandleControlID = GUIUtility.hotControl;
            }
            Handles.color = color;
            GUI.enabled   = enabled;
        }
        public void OnSceneGUI()
        {
            bool           flag           = GUIUtility.hotControl == this.m_HandleControlID;
            SphereCollider sphereCollider = (SphereCollider)this.target;
            Color          color          = Handles.color;

            if (sphereCollider.enabled)
            {
                Handles.color = Handles.s_ColliderHandleColor;
            }
            else
            {
                Handles.color = Handles.s_ColliderHandleColorDisabled;
            }
            bool enabled = GUI.enabled;

            if (!base.editingCollider && !flag)
            {
                GUI.enabled   = false;
                Handles.color = new Color(0f, 0f, 0f, 0.001f);
            }
            Vector3 lossyScale = sphereCollider.transform.lossyScale;
            float   num        = Mathf.Max(Mathf.Max(Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.y)), Mathf.Abs(lossyScale.z));
            float   num2       = num * sphereCollider.radius;

            num2 = Mathf.Abs(num2);
            num2 = Mathf.Max(num2, 1E-05f);
            Vector3    position   = sphereCollider.transform.TransformPoint(sphereCollider.center);
            Quaternion rotation   = sphereCollider.transform.rotation;
            int        hotControl = GUIUtility.hotControl;
            float      num3       = Handles.RadiusHandle(rotation, position, num2, true);

            if (GUI.changed)
            {
                Undo.RecordObject(sphereCollider, "Adjust Radius");
                sphereCollider.radius = num3 * 1f / num;
            }
            if (hotControl != GUIUtility.hotControl && GUIUtility.hotControl != 0)
            {
                this.m_HandleControlID = GUIUtility.hotControl;
            }
            Handles.color = color;
            GUI.enabled   = enabled;
        }
        private void OnSceneGUI()
        {
            AudioSource target = (AudioSource)this.target;
            Color       color  = Handles.color;

            Handles.color = !target.enabled ? new Color(0.3f, 0.4f, 0.6f, 0.5f) : new Color(0.5f, 0.7f, 1f, 0.5f);
            Vector3 position = target.transform.position;

            EditorGUI.BeginChangeCheck();
            float num1 = Handles.RadiusHandle(Quaternion.identity, position, target.minDistance, true);
            float num2 = Handles.RadiusHandle(Quaternion.identity, position, target.maxDistance, true);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject((UnityEngine.Object)target, "AudioSource Distance");
                target.minDistance        = num1;
                target.maxDistance        = num2;
                this.m_RefreshCurveEditor = true;
            }
            Handles.color = color;
        }
示例#12
0
        public void OnSceneGUI()
        {
            if (Tools.viewToolActive)
            {
                return;
            }
            bool             flag   = GUIUtility.hotControl == this.m_HandleControlID;
            CircleCollider2D target = (CircleCollider2D)this.target;
            Color            color  = Handles.color;

            Handles.color = Handles.s_ColliderHandleColor;
            bool enabled = GUI.enabled;

            if (!this.editingCollider && !flag)
            {
                GUI.enabled   = false;
                Handles.color = new Color(0.0f, 0.0f, 0.0f, 1f / 1000f);
            }
            Vector3 lossyScale = target.transform.lossyScale;
            float   num1       = Mathf.Max(Mathf.Max(Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.y)), Mathf.Abs(lossyScale.z));
            float   radius     = Mathf.Max(Mathf.Abs(num1 * target.radius), 1E-05f);
            Vector3 position   = target.transform.TransformPoint((Vector3)target.offset);
            int     hotControl = GUIUtility.hotControl;
            float   num2       = Handles.RadiusHandle(Quaternion.identity, position, radius, true);

            if (GUI.changed)
            {
                Undo.RecordObject((Object)target, "Adjust Radius");
                target.radius = num2 * 1f / num1;
            }
            if (hotControl != GUIUtility.hotControl && GUIUtility.hotControl != 0)
            {
                this.m_HandleControlID = GUIUtility.hotControl;
            }
            Handles.color = color;
            GUI.enabled   = enabled;
        }
示例#13
0
 public void OnSceneGUI()
 {
     if (!Tools.viewToolActive)
     {
         bool             flag   = GUIUtility.hotControl == this.m_HandleControlID;
         CircleCollider2D target = (CircleCollider2D)base.target;
         Color            color  = Handles.color;
         Handles.color = Handles.s_ColliderHandleColor;
         bool enabled = GUI.enabled;
         if (!base.editingCollider && !flag)
         {
             GUI.enabled   = false;
             Handles.color = new Color(0f, 0f, 0f, 0.001f);
         }
         Vector3 lossyScale   = target.transform.lossyScale;
         float   a            = Mathf.Abs(lossyScale.x);
         float   introduced11 = Mathf.Max(a, Mathf.Abs(lossyScale.y));
         float   num          = Mathf.Max(introduced11, Mathf.Abs(lossyScale.z));
         float   f            = num * target.radius;
         f = Mathf.Max(Mathf.Abs(f), 1E-05f);
         Vector3 position   = target.transform.TransformPoint((Vector3)target.offset);
         int     hotControl = GUIUtility.hotControl;
         float   num4       = Handles.RadiusHandle(Quaternion.identity, position, f, true);
         if (GUI.changed)
         {
             Undo.RecordObject(target, "Adjust Radius");
             target.radius = (num4 * 1f) / num;
         }
         if ((hotControl != GUIUtility.hotControl) && (GUIUtility.hotControl != 0))
         {
             this.m_HandleControlID = GUIUtility.hotControl;
         }
         Handles.color = color;
         GUI.enabled   = enabled;
     }
 }
示例#14
0
        protected virtual void OnSceneGUI()
        {
            Light t = target as Light;

            Color temp = Handles.color;

            if (t.enabled)
            {
                Handles.color = kGizmoLight;
            }
            else
            {
                Handles.color = kGizmoDisabledLight;
            }

            float thisRange = t.range;

            switch (t.type)
            {
            case LightType.Point:
                thisRange = Handles.RadiusHandle(Quaternion.identity, t.transform.position, thisRange, true);

                if (GUI.changed)
                {
                    Undo.RecordObject(t, "Adjust Point Light");
                    t.range = thisRange;
                }

                break;

            case LightType.Spot:
                // Give handles twice the alpha of the lines
                Color col = Handles.color;
                col.a         = Mathf.Clamp01(temp.a * 2);
                Handles.color = col;

                Vector2 angleAndRange = new Vector2(t.spotAngle, t.range);
                angleAndRange = Handles.ConeHandle(t.transform.rotation, t.transform.position, angleAndRange, 1.0f, 1.0f, true);
                if (GUI.changed)
                {
                    Undo.RecordObject(t, "Adjust Spot Light");
                    t.spotAngle = angleAndRange.x;
                    t.range     = Mathf.Max(angleAndRange.y, 0.01F);
                }
                break;

            case LightType.Area:
                EditorGUI.BeginChangeCheck();
                Vector2 size = Handles.DoRectHandles(t.transform.rotation, t.transform.position, t.areaSize);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(t, "Adjust Area Light");
                    t.areaSize = size;
                }
                break;

            default:
                break;
            }
            Handles.color = temp;
        }
示例#15
0
        protected virtual void OnSceneGUI()
        {
            Light t = target as Light;

            Color temp = Handles.color;

            if (t.enabled)
            {
                Handles.color = kGizmoLight;
            }
            else
            {
                Handles.color = kGizmoDisabledLight;
            }

            float thisRange = t.range;

            switch (t.type)
            {
            case LightType.Directional:
                Vector3 lightPos = t.transform.position;
                float   lightSize;
                using (new Handles.DrawingScope(Matrix4x4.identity))        //be sure no matrix affect the size computation
                {
                    lightSize = HandleUtility.GetHandleSize(lightPos);
                }
                float radius = lightSize * 0.2f;
                using (new Handles.DrawingScope(Matrix4x4.TRS(lightPos, t.transform.rotation, Vector3.one)))
                {
                    Handles.DrawWireDisc(Vector3.zero, Vector3.forward, radius);
                    foreach (Vector3 normalizedPos in directionalLightHandlesRayPositions)
                    {
                        Vector3 pos = normalizedPos * radius;
                        Handles.DrawLine(pos, pos + new Vector3(0, 0, lightSize));
                    }
                }
                break;

            case LightType.Point:
                thisRange = Handles.RadiusHandle(Quaternion.identity, t.transform.position, thisRange);
                if (GUI.changed)
                {
                    Undo.RecordObject(t, "Adjust Point Light");
                    t.range = thisRange;
                }
                break;

            case LightType.Spot:
                Transform tr            = t.transform;
                Vector3   circleCenter  = tr.position;
                Vector3   arrivalCenter = circleCenter + tr.forward * t.range;
                float     lightDisc     = t.range * Mathf.Tan(Mathf.Deg2Rad * t.spotAngle / 2.0f);
                Handles.DrawLine(circleCenter, arrivalCenter + tr.up * lightDisc);
                Handles.DrawLine(circleCenter, arrivalCenter - tr.up * lightDisc);
                Handles.DrawLine(circleCenter, arrivalCenter + tr.right * lightDisc);
                Handles.DrawLine(circleCenter, arrivalCenter - tr.right * lightDisc);
                Handles.DrawWireDisc(arrivalCenter, tr.forward, lightDisc);
                Handles.color = GetLightHandleColor(Handles.color);
                Vector2 angleAndRange = new Vector2(t.spotAngle, t.range);
                angleAndRange = Handles.ConeHandle(t.transform.rotation, t.transform.position, angleAndRange, 1.0f, 1.0f, true);
                if (GUI.changed)
                {
                    Undo.RecordObject(t, "Adjust Spot Light");
                    t.spotAngle = angleAndRange.x;
                    t.range     = Mathf.Max(angleAndRange.y, 0.01F);
                }
                break;

            case LightType.Rectangle:
                EditorGUI.BeginChangeCheck();
                Vector2 size = Handles.DoRectHandles(t.transform.rotation, t.transform.position, t.areaSize, false);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(t, "Adjust Rect Light");
                    t.areaSize = size;
                }
                // Draw the area light's normal only if it will not overlap with the current tool
                if (!((Tools.current == Tool.Move || Tools.current == Tool.Scale) && Tools.pivotRotation == PivotRotation.Local))
                {
                    Handles.DrawLine(t.transform.position, t.transform.position + t.transform.forward);
                }
                break;

            case LightType.Disc:
                m_BoundsHandle.radius         = t.areaSize.x;
                m_BoundsHandle.axes           = IMGUI.Controls.PrimitiveBoundsHandle.Axes.X | IMGUI.Controls.PrimitiveBoundsHandle.Axes.Y;
                m_BoundsHandle.center         = Vector3.zero;
                m_BoundsHandle.wireframeColor = Handles.color;
                m_BoundsHandle.handleColor    = GetLightHandleColor(Handles.color);
                Matrix4x4 mat = new Matrix4x4();
                mat.SetTRS(t.transform.position, t.transform.rotation, new Vector3(1, 1, 1));
                EditorGUI.BeginChangeCheck();
                using (new Handles.DrawingScope(Color.white, mat))
                    m_BoundsHandle.DrawHandle();
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(t, "Adjust Disc Light");
                    t.areaSize = new Vector2(m_BoundsHandle.radius, t.areaSize.y);
                }
                break;
            }
            Handles.color = temp;
        }