コード例 #1
0
        /// <summary>
        /// Draws a point list into a draw area. The difference between this and DrawGesture is that
        /// this method draws a gesture before it is saved as a gesture (hence, draw "point list").
        /// </summary>
        /// <param name="points">Point list to draw</param>
        /// <param name="drawArea">Area to draw the list on</param>
        public static void DrawPointList(List <Point> points, Rect drawArea)
        {
            Handles.BeginGUI();

            int currentStrokeID = 0;

            for (int i = 0; i < points.Count; i++)
            {
                Handles.color = LineColor;

                if (i != points.Count - 1)
                {
                    if (currentStrokeID == points[i + 1].StrokeID)
                    {
                        GestureEditorUtility.DrawBezier(
                            TranslateToDrawArea(points[i].Position, drawArea, true),
                            TranslateToDrawArea(points[i + 1].Position, drawArea, true)
                            );
                    }
                    else
                    {
                        currentStrokeID++;
                    }
                }
            }

            Handles.EndGUI();
        }
コード例 #2
0
        /// <summary>
        /// Draws a gesture into a draw area
        /// </summary>
        /// <param name="g">Gesture to draw</param>
        /// <param name="drawArea">Area to draw the gesture on</param>
        public static void DrawGesture(Gesture g, Rect drawArea)
        {
            Handles.BeginGUI();

            int currentStrokeID = 0;

            for (int i = 0; i < g.OriginalPoints.Length; i++)
            {
                Handles.color = LineColor;

                if (i != g.OriginalPoints.Length - 1)
                {
                    if (currentStrokeID == g.OriginalPoints[i + 1].StrokeID)
                    {
                        GestureEditorUtility.DrawBezier(
                            TranslateToDrawArea(g.OriginalPoints[i].Position, drawArea, true),
                            TranslateToDrawArea(g.OriginalPoints[i + 1].Position, drawArea, true)
                            );
                    }
                    else
                    {
                        currentStrokeID++;
                    }
                }
            }

            Handles.EndGUI();
        }
コード例 #3
0
ファイル: GestureEditor.cs プロジェクト: PRomanUA/GR_3
        private void OnGUIEditorView()
        {
            editorView = new Rect(0, 0, Mathf.FloorToInt(position.width * viewRatio), position.height);

            GUILayout.BeginArea(editorView, EditorStyles.inspectorFullWidthMargins);

            if (isAddingGesture)
            {
                DrawGestureArea();
                DrawInstructions();
                GestureEditorUtility.DrawPointList(points, gestureDrawArea);
            }
            else
            {
                if (currentGesture != null)
                {
                    DrawGestureArea();
                    GestureEditorUtility.DrawGesture(currentGesture, gestureDrawArea);
                }
            }

            GUILayout.EndArea();
        }