protected override void InternalOnSceneGUI()
        {
            var splitter = Splitter;

            if (splitter == null)
            {
                return;
            }

            var positions = splitter.Positions;

            if (positions == null || positions.Count == 0)
            {
                return;
            }

            var sphereScale = BGPrivateField.Get <float>(splitter, "spheresScale");

            BGEditorUtility.SwapHandlesColor(BGPrivateField.Get <Color>(splitter, "spheresColor"), () =>
            {
                var count = Mathf.Min(positions.Count, BGPrivateField.Get <int>(splitter, "spheresCount"));

                var localToWorldMatrix = splitter.transform.localToWorldMatrix;
                for (var i = 0; i < count; i++)
                {
                    var position = positions[i];
                    if (splitter.UseLocal)
                    {
                        position = localToWorldMatrix.MultiplyPoint(position);
                    }

                    Handles.SphereCap(0, position, Quaternion.identity, sphereScale * BGEditorUtility.GetHandleSize(position, .07f));
                }
            });
        }
        protected override void InternalOnSceneGUI()
        {
            var objectRotate = (BGCcCursorObjectRotate)cc;

            var cursor = objectRotate.Cursor;

            if (cursor == null)
            {
                return;
            }

            var math = cursor.Math;

            if (math == null || !math.IsCalculated(BGCurveBaseMath.Field.Tangent))
            {
                return;
            }

            var position = cursor.CalculatePosition();
            var tangent  = cursor.CalculateTangent();

            if (Vector3.SqrMagnitude(tangent) > 0.0001)
            {
                var handleSize = BGEditorUtility.GetHandleSize(position, BGPrivateField.Get <float>(ObjectRotate, "handlesScale"));
                BGEditorUtility.SwapHandlesColor(BGPrivateField.Get <Color>(ObjectRotate, "handlesColor"), () => { Handles.ArrowCap(0, position, Quaternion.LookRotation(tangent), handleSize); });
            }
        }
        protected override void InternalOnSceneGUI()
        {
            var curve = ObjectRotate.Curve;

            if (curve == null || curve.PointsCount == 0)
            {
                return;
            }

            BGCcCursor cursor;

            try
            {
                cursor = ObjectRotate.Cursor;
            }
            catch (MissingReferenceException)
            {
                return;
            }

            if (cursor == null)
            {
                return;
            }

            var math = cursor.Math;

            if (math == null || !math.IsCalculated(BGCurveBaseMath.Field.Tangent))
            {
                return;
            }

            var position = cursor.CalculatePosition();

            //by field
            var result = Quaternion.identity;

            if (!ObjectRotate.TryToCalculateRotation(ref result))
            {
                return;
            }

            var handleSize = BGEditorUtility.GetHandleSize(position, BGPrivateField.Get <float>(ObjectRotate, "handlesScale"));

            BGEditorUtility.SwapHandlesColor(BGPrivateField.Get <Color>(ObjectRotate, "handlesColor"), () =>
            {
#if UNITY_5_6_OR_NEWER
                Handles.ArrowHandleCap(0, position, result, handleSize, EventType.Repaint);
#else
                Handles.ArrowCap(0, position, result, handleSize);
#endif
            });
        }
Exemplo n.º 4
0
        protected override void InternalOnSceneGUI()
        {
            var cursor = (BGCcCursor)cc;

            var position = cursor.CalculatePosition();

            var handleSize = BGEditorUtility.GetHandleSize(position, BGPrivateField.Get <float>(cursor, "handlesScale"));

            BGEditorUtility.SwapHandlesColor(BGPrivateField.Get <Color>(cursor, "handlesColor"), () =>
            {
                Handles.ArrowCap(0, position + Vector3.up * handleSize * 1.2f, Quaternion.LookRotation(Vector3.down), handleSize);
                Handles.SphereCap(0, position, Quaternion.LookRotation(Vector3.down), handleSize * .15f);
            });
        }
Exemplo n.º 5
0
 public CcData(Type type, bool single, BGCc.CcDescriptor ccDescriptor)
     : this(type, single, ccDescriptor.Name)
 {
     Description = ccDescriptor.Description;
     if (!string.IsNullOrEmpty(ccDescriptor.Icon))
     {
         var texture = BGPrivateField.Get <BGEditorIcon>(typeof(BGBinaryResources), ccDescriptor.Icon);
         if (texture != null)
         {
             Icon = texture;
         }
     }
     else if (!string.IsNullOrEmpty(ccDescriptor.Image))
     {
         Icon = BGEditorUtility.LoadCcTexture2D(ccDescriptor.Image);
     }
 }
Exemplo n.º 6
0
        protected override void InternalOnSceneGUI()
        {
            var mathCc = Math;

            if (mathCc == null || mathCc.Math == null || mathCc.Math.SectionsCount == 0)
            {
                return;
            }

            if (mathCc.Curve.ForceChangedEventMode != BGCurve.ForceChangedEventModeEnum.Off)
            {
                mathCc.Recalculate();
            }

            var math = mathCc.Math;

            var sphereScale = BGPrivateField.Get <float>(mathCc, "spheresScale");

            BGEditorUtility.SwapHandlesColor(BGPrivateField.Get <Color>(mathCc, "spheresColor"), () =>
            {
                var count = BGPrivateField.Get <int>(mathCc, "spheresCount");

                for (var i = 0; i < math.SectionsCount; i++)
                {
                    var section = math[i];
                    var points  = section.Points;
                    for (var j = 0; j < points.Count; j++)
                    {
                        var pos = points[j].Position;
#if UNITY_5_6_OR_NEWER
                        Handles.SphereHandleCap(0, pos, Quaternion.identity, sphereScale * BGEditorUtility.GetHandleSize(pos, .07f), EventType.Repaint);
#else
                        Handles.SphereCap(0, pos, Quaternion.identity, sphereScale * BGEditorUtility.GetHandleSize(pos, .07f));
#endif
                        if (count-- <= 0)
                        {
                            return;
                        }
                    }
                }
            });
        }
Exemplo n.º 7
0
        public static void SwapVector2Labels(BGCurve.Mode2DEnum mode2D, Action action)
        {
            var needToSwap = mode2D != BGCurve.Mode2DEnum.Off && mode2D != BGCurve.Mode2DEnum.XY;

            GUIContent[] oldLabels = null;
            if (needToSwap)
            {
                oldLabels = BGPrivateField.Get <GUIContent[]>(typeof(EditorGUI), "s_XYLabels");
                GUIContent[] newLabels;
                switch (mode2D)
                {
                case BGCurve.Mode2DEnum.XZ:
                    newLabels = XZLabels;
                    break;

                case BGCurve.Mode2DEnum.YZ:
                    newLabels = YZLabels;
                    break;

                default:
                    throw new ArgumentOutOfRangeException("mode2D", mode2D, null);
                }
                BGPrivateField.Set(typeof(EditorGUI), "s_XYLabels", newLabels);
            }

            try
            {
                action();
            }
            finally
            {
                if (needToSwap)
                {
                    BGPrivateField.Set(typeof(EditorGUI), "s_XYLabels", oldLabels);
                }
            }
        }
Exemplo n.º 8
0
        protected override void InternalOnSceneGUI()
        {
            var cursor = Cursor;

            if (cursor == null)
            {
                return;
            }

            var position = cursor.CalculatePosition();

            var handleSize = BGEditorUtility.GetHandleSize(position, BGPrivateField.Get <float>(cursor, "handlesScale"));

            BGEditorUtility.SwapHandlesColor(BGPrivateField.Get <Color>(cursor, "handlesColor"), () =>
            {
#if UNITY_5_6_OR_NEWER
                Handles.ArrowHandleCap(0, position + Vector3.up * handleSize * 1.2f, Quaternion.LookRotation(Vector3.down), handleSize, EventType.Repaint);
                Handles.SphereHandleCap(0, position, Quaternion.LookRotation(Vector3.down), handleSize * .15f, EventType.Repaint);
#else
                Handles.ArrowCap(0, position + Vector3.up * handleSize * 1.2f, Quaternion.LookRotation(Vector3.down), handleSize);
                Handles.SphereCap(0, position, Quaternion.LookRotation(Vector3.down), handleSize * .15f);
#endif
            });
        }