Example #1
0
        public override void Draw(SVArgs args, ref object value)
        {
            Vector3?mVec = value as Vector3?;

            if (mVec == null)
            {
                return;
            }

            Handles.SphereHandleCap(0, mVec.Value, Quaternion.identity, 0.25f, EventType.Repaint);
        }
Example #2
0
        public override void Draw(SVArgs args, ref object value)
        {
            Vector3 inPoint = (value as Vector3?).GetValueOrDefault();

            if (SceneViewHandles.DoFade(inPoint))
            {
                return;
            }

            value = Handles.DoPositionHandle(inPoint, Quaternion.identity);
        }
Example #3
0
        public override void Draw(SVArgs args, ref object value)
        {
            Vector3Int[] inPoints = value as Vector3Int[];

            for (int i = 0; i < inPoints.Length; i++)
            {
                if (SceneViewHandles.DoFade(inPoints[i]))
                {
                    continue;
                }
                inPoints[i] = Vector3Int.RoundToInt(Handles.DoPositionHandle(inPoints[i], Quaternion.identity));
            }

            value = inPoints;
        }
Example #4
0
        public override void Draw(SVArgs args, ref object value)
        {
            Vector3[] inPoints = value as Vector3[];

            EditorGUI.BeginChangeCheck();
            for (int i = 0; i < inPoints.Length; i++)
            {
                if (SceneViewHandles.DoFade(inPoints[i]))
                {
                    continue;
                }
                inPoints[i] = Handles.DoPositionHandle(inPoints[i], Quaternion.identity);
            }

            value = inPoints;
        }
Example #5
0
        public override void Draw(SVArgs args, ref object value)
        {
            Transform t = args.MonoInstance.transform;

            Bounds inBounds  = (value as Bounds?).GetValueOrDefault();
            Bounds outBounds = inBounds;

            if (SceneViewHandles.DoFade(t.TransformPoint(inBounds.center)))
            {
                return;
            }

            outBounds.center = t.InverseTransformPoint(Handles.DoPositionHandle(t.TransformPoint(inBounds.center), Quaternion.identity));
            //outBounds.size = Handles.DoScaleHandle(inBounds.size, t.TransformPoint(outBounds.center), Quaternion.identity, 1f);

            Vector3 center  = t.TransformPoint(outBounds.center);
            Vector3 extents = outBounds.extents;

            // Draw our handles for dragging scale.
            Vector3 outSize = outBounds.size;

            outSize.x = Handles.ScaleSlider(outSize.x, center + (Vector3.right * outSize.x / 2f), Vector3.right, Quaternion.LookRotation(Vector3.right), HandleUtility.GetHandleSize(center + (Vector3.right * outSize.x / 2f)), 1f);
            outSize.x = Handles.ScaleSlider(outSize.x, center + (Vector3.left * outSize.x / 2f), Vector3.left, Quaternion.LookRotation(Vector3.left), HandleUtility.GetHandleSize(center + (Vector3.left * outSize.x / 2f)), 1f);

            outSize.y = Handles.ScaleSlider(outSize.y, center + (Vector3.up * outSize.y / 2f), Vector3.up, Quaternion.LookRotation(Vector3.up), HandleUtility.GetHandleSize(center + (Vector3.up * outSize.y / 2f)), 1f);
            outSize.y = Handles.ScaleSlider(outSize.y, center + (Vector3.down * outSize.y / 2f), Vector3.down, Quaternion.LookRotation(Vector3.down), HandleUtility.GetHandleSize(center + (Vector3.down * outSize.y / 2f)), 1f);

            outSize.z = Handles.ScaleSlider(outSize.z, center + (Vector3.forward * outSize.z / 2f), Vector3.forward, Quaternion.LookRotation(Vector3.forward), HandleUtility.GetHandleSize(center + (Vector3.forward * outSize.z / 2f)), 1f);
            outSize.z = Handles.ScaleSlider(outSize.z, center + (Vector3.back * outSize.z / 2f), Vector3.back, Quaternion.LookRotation(Vector3.back), HandleUtility.GetHandleSize(center + (Vector3.back * outSize.z / 2f)), 1f);

            outBounds.size = outSize;

            Handles.DrawWireCube(t.TransformPoint(outBounds.center), outBounds.size);

            value = outBounds;
        }
Example #6
0
        public override void Draw(SVArgs args, ref object value)
        {
            Ray?ray = value as Ray?;

            Handles.ArrowHandleCap(0, ray.Value.origin, Quaternion.LookRotation(ray.Value.direction), 1f, EventType.Repaint);
        }
Example #7
0
    private static void OnSceneGUI(SceneView sceneView)
    {
        if (attributes == null)
        {
            SweepForComponents();
        }

        Color cachedHandlesColor = Handles.color;

        for (int i = attributes.Count; i >= 0; i--)
        {
            MonoAttributeCollection attribute = attributes[i];

            // If there is no mono instance, assume our component has been removed.
            if (attribute.MonoInstance == null)
            {
                attributes.Remove(attribute);
                continue;
            }

            if (displayMode == DisplayMode.SelectedObject && !Selection.Contains(attribute.MonoInstance.gameObject))
            {
                continue;
            }

            // Draw our SVDebugs
            foreach (var kvPair in attribute.SVHandles)
            {
                object value = kvPair.Key.GetValue(attribute.MonoInstance);
                Type   type  = kvPair.Key.FieldType;

                if (value == null)
                {
                    attributes.Remove(attribute);
                    break;
                }

                if (!handleDisplays.ContainsKey(type))
                {
                    Debug.LogWarning("Attempt to draw debug for a type which doesn't have a ITypeDisplay.\nPerhaps you should add one?");
                    continue;
                }

                SVArgs args = new SVArgs(value, attribute.MonoInstance);

                Handles.color = attribute.SVHandles[kvPair.Key].Color;

                EditorGUI.BeginChangeCheck();
                {
                    // If the attribute has a specific Display defined, use that.
                    if (kvPair.Value.Type != null)
                    {
                        handleDisplays[type][kvPair.Value.Type].Draw(args, ref value);
                    }
                    else
                    {
                        SVHandleDisplay currentDisp = null;
                        using (var e = handleDisplays[type].Values.GetEnumerator())
                        {
                            while (e.MoveNext())
                            {
                                if (currentDisp == null || e.Current.Priority > currentDisp.Priority)
                                {
                                    currentDisp = e.Current;
                                }
                                e.MoveNext();
                            }
                        }

                        if (currentDisp != null)
                        {
                            currentDisp.Draw(args, ref value);
                        }
                    }
                }
                if (EditorGUI.EndChangeCheck())
                {
                    kvPair.Key.SetValue(attribute.MonoInstance, value);
                }
            }
        }

        Handles.color = cachedHandlesColor;
    }
Example #8
0
 public abstract void Draw(SVArgs args, ref object val);