상속: UnityEngine.ScriptableObject
    public override void OnInspectorGUI()
    {
#if UNITY_3_5
        EditorGUIUtility.LookLikeInspector();
#endif

        PointCloudGestureTemplate template = target as PointCloudGestureTemplate;

        if (GUILayout.Button("Edit", GUILayout.Height(50)))
        {
            PointCloudGestureEditor.Open(template);
        }

        /*
         * if( GUILayout.Button( "Triangle" ) )
         * {
         *  template.BeginPoints();
         *  template.AddPoint( 0, 1, 1 );
         *  template.AddPoint( 0, 2, 2 );
         *  template.AddPoint( 0, 3, 1 );
         *  template.AddPoint( 0, 1, 1 );
         *  template.EndPoints();
         * }
         *
         * if( GUILayout.Button( "Square" ) )
         * {
         *  template.BeginPoints();
         *  template.AddPoint( 0, 2, 1 );
         *  template.AddPoint( 0, 2, 3 );
         *  template.AddPoint( 0, 4, 3 );
         *  template.AddPoint( 0, 4, 1 );
         *  template.AddPoint( 0, 2, 1 );
         *  template.EndPoints();
         * }*/
    }
    public override void OnPreviewGUI(Rect r, GUIStyle background)
    {
        base.OnPreviewGUI(r, background);

        float size       = 0.95f * Mathf.Min(r.width, r.height);
        Rect  canvasRect = new Rect(r.center.x - 0.5f * size, r.center.y - 0.5f * size, size, size);

        PointCloudGestureTemplate template = target as PointCloudGestureTemplate;

        Vector2 center = canvasRect.center;

        float scale = 0.95f * size;

        Handles.color = Color.white;
        for (int i = 1; i < template.PointCount; ++i)
        {
            Vector2 p1 = template.GetPosition(i - 1);
            Vector2 p2 = template.GetPosition(i);

            p1.y = -p1.y;
            p2.y = -p2.y;

            p1 = center + scale * p1;
            p2 = center + scale * p2;

            if (canvasRect.width > 100)
            {
                float handleSize = canvasRect.width / 200.0f;
                Handles.CircleHandleCap(0, p1, Quaternion.identity, handleSize, EventType.MouseDown);
            }

            Handles.DrawLine(p1, p2);
        }
    }
    public override void OnPreviewSettings()
    {
        base.OnPreviewSettings();

        PointCloudGestureTemplate template = target as PointCloudGestureTemplate;

        GUILayout.Label(template.PointCount + " points, " + template.StrokeCount + " stroke(s)");
    }
    protected override void OnToolbar()
    {
        base.OnToolbar();

        if (GUILayout.Button("New Gesture Template"))
        {
            PointCloudGestureTemplate template = FingerGesturesEditorUtils.CreateAsset <PointCloudGestureTemplate>();
            Gesture.Templates.Add(template);
        }
    }
예제 #5
0
    public static PointCloudGestureEditor Open( PointCloudGestureTemplate template )
    {
        PointCloudGestureEditor window = EditorWindow.GetWindow<PointCloudGestureEditor>( true, "Gesture Editor: " + template.name );
        window.maxSize = new Vector2( GestureAreaSize, GestureAreaSize + ToolbarHeight + 22 );
        window.minSize = window.maxSize;
        //window.wantsMouseMove = true;
        window.Init( template );
        window.Focus();

        return window;
    }
    public bool Render( PointCloudGestureTemplate template )
    {
        if( template.PointCount < 2 )
            return false;

        lineRenderer.SetVertexCount( template.PointCount );

        for( int i = 0; i < template.PointCount; ++i )
            lineRenderer.SetPosition( i, template.GetPosition( i ) );

        return true;
    }
    public static PointCloudGestureEditor Open(PointCloudGestureTemplate template)
    {
        PointCloudGestureEditor window = EditorWindow.GetWindow <PointCloudGestureEditor>(true, "Gesture Editor: " + template.name);

        window.maxSize = new Vector2(GestureAreaSize, GestureAreaSize + ToolbarHeight + 22);
        window.minSize = window.maxSize;
        //window.wantsMouseMove = true;
        window.Init(template);
        window.Focus();

        return(window);
    }
    public bool Render(PointCloudGestureTemplate template)
    {
        if (template.PointCount < 2)
        {
            return(false);
        }

        lineRenderer.positionCount = template.PointCount;

        for (int i = 0; i < template.PointCount; ++i)
        {
            lineRenderer.SetPosition(i, template.GetPosition(i));
        }

        return(true);
    }
예제 #9
0
    public bool AddTemplate(PointCloudGestureTemplate template)
    {
        if (FindNormalizedTemplate(template) != null)
        {
            Debug.LogWarning("The PointCloud template " + template.name + " is already present in the list");
            return(false);
        }

        // convert template point entry to recognizer point
        List <Point> points = new List <Point>();

        for (int i = 0; i < template.PointCount; ++i)
        {
            points.Add(new Point(template.GetStrokeId(i), template.GetPosition(i)));
        }

        NormalizedTemplate nt = new NormalizedTemplate();

        nt.Source = template;
        nt.Points = Normalize(points);

        normalizedTemplates.Add(nt);
        return(true);
    }
예제 #10
0
 NormalizedTemplate FindNormalizedTemplate(PointCloudGestureTemplate template)
 {
     return(normalizedTemplates.Find(t => (t.Source == template)));
 }
    public static void CreatePointCloudGesture()
    {
        PointCloudGestureTemplate template = FingerGesturesEditorUtils.CreateAsset <PointCloudGestureTemplate>();

        FingerGesturesEditorUtils.SelectAssetInProjectView(template);
    }
 PointCloudGestureRenderer FindGestureRenderer( PointCloudGestureTemplate template )
 {
     return gestureRenderers.Find( gr => gr.GestureTemplate == template );
 }
예제 #13
0
 void Init( PointCloudGestureTemplate template )
 {
     this.template = template;
     points = new List<Vector2>();
 }
 void Init(PointCloudGestureTemplate template)
 {
     this.template = template;
     points        = new List <Vector2>();
 }
예제 #15
0
 PointCloudGestureRenderer FindGestureRenderer(PointCloudGestureTemplate template)
 {
     return(gestureRenderers.Find(gr => gr.GestureTemplate == template));
 }