Exemple #1
0
        /// <summary>
        /// Initializes the new path.
        /// </summary>
        public void InitializePath()
        {
            _type         = PathTemplateType.Linear;
            _sameXYRadius = true;

            _yAdvance = 0f;
            _periods  = 1f;

            _radiusX           = 20f;
            _radiusY           = 20f;
            _samples           = 5;
            _closed            = true;
            _startAngle        = 0f;
            _endAngle          = 360f;
            _tangentMode       = TangentMode.Tangent;
            _inTangentRadius   = .5f;
            _outTangentRadius  = .5f;
            _sameTangentRadius = true;

            _go = null;
            CreateThePath();
        }
Exemple #2
0
        /// <summary>
        /// Raises the GUI event.
        /// </summary>
        void OnGUI()
        {
            EditorGUILayout.LabelField(new GUIContent(pathMagicLogo), GUILayout.Width(142), GUILayout.Height(28));

            if (_go == null)
            {
                EditorGUILayout.HelpBox("Create a new parameter path by pressing the New button", MessageType.Info);
            }
            else
            {
                EditorGUI.BeginChangeCheck();

                EditorGUILayout.LabelField(new GUIContent("General"));
                EditorGUILayout.BeginVertical("Box");
                _type = (PathTemplateType)EditorGUILayout.EnumPopup(new GUIContent("Path template", "Select a template path"), _type);

                _samples = EditorGUILayout.IntField(new GUIContent("Samples", "Number of samples to generate"), _samples);

                if (_samples < 3)
                {
                    _samples = 3;
                }
                _closed = EditorGUILayout.Toggle(new GUIContent("Closed", "Generate a loop-ed path"), _closed);
                EditorGUILayout.EndVertical();

                EditorGUILayout.LabelField("Prperties");
                EditorGUILayout.BeginVertical("Box");

                if (_type == PathTemplateType.Circular)
                {
                    _sameXYRadius = EditorGUILayout.Toggle(new GUIContent("Same X/Y radius", "Circle have same X/Y radius?"), _sameXYRadius);
                }

                if (_sameXYRadius || _type == PathTemplateType.Linear)
                {
                    _radiusX = _radiusY = EditorGUILayout.FloatField(new GUIContent("Radius", "The radius of the circle"), _radiusX);
                }
                else
                {
                    _radiusX = EditorGUILayout.FloatField(new GUIContent("Radius X", "The X radius of the circle"), _radiusX);
                    _radiusY = EditorGUILayout.FloatField(new GUIContent("Radius Y", "The Y radius of the circle"), _radiusY);
                }

                if (_type == PathTemplateType.Circular)
                {
                    _yAdvance = EditorGUILayout.FloatField(new GUIContent("Y Advance", "Eache waypoint Y is increased by this value (Spiral template)"), _yAdvance);
                    _periods  = EditorGUILayout.FloatField(new GUIContent("Cycles", "Number of cycles around the circle"), _periods);

                    EditorGUILayout.MinMaxSlider(new GUIContent("Min/Max angles", "Start angle and end angle"), ref _startAngle, ref _endAngle, 0f, 360f);
                    _tangentMode = (TangentMode)EditorGUILayout.EnumPopup(new GUIContent("Tangents align", "Type of generated bezier tangents"), _tangentMode);
                }

                _sameTangentRadius = EditorGUILayout.Toggle(new GUIContent("Same tangent radius", "Tangents are symmetric in radius?"), _sameTangentRadius);
                if (_sameTangentRadius)
                {
                    _inTangentRadius = _outTangentRadius = EditorGUILayout.FloatField(new GUIContent("Tangents radius", "In and out tangents radius"), _inTangentRadius);
                }
                else
                {
                    _inTangentRadius  = EditorGUILayout.FloatField(new GUIContent("In tangent radius", "In tangent radius"), _inTangentRadius);
                    _outTangentRadius = EditorGUILayout.FloatField(new GUIContent("Out tangent radius", "Out tangent radius"), _outTangentRadius);
                }
                EditorGUILayout.EndVertical();

                if (EditorGUI.EndChangeCheck())
                {
                    CreateThePath();
                }
            }

            if (GUILayout.Button(new GUIContent("New", "Leaves current generated path (if there is one) and create a new one")))
            {
                InitializePath();
            }
        }