Esempio n. 1
0
 void InitializeMembers()
 {
     mesh = targetObject.GetComponent<SkinnedMeshRenderer>().sharedMesh;
     mat = new Material(Shader.Find("Diffuse"));
     vertices = mesh.vertices;
     normals = mesh.normals;
     mayaCamera = GetComponent<MayaCamera>();
 }
Esempio n. 2
0
    void OnGUI()
    {
        GUILayout.BeginArea(new Rect(0, 0, Screen.width, Screen.height));
        GUILayout.Space(10);     // top padding
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Open on GitHub"))
        {
            Application.OpenURL("https://github.com/noisefloordev/mosaix");
        }
        GUILayout.Space(10);     // right padding
        GUILayout.EndHorizontal();
        GUILayout.EndArea();

        GUILayout.BeginArea(new Rect(10, 10, Screen.width - 20, Screen.height - 20));
        GUILayout.BeginVertical(MakePaddedBoxStyle(10, 10), GUILayout.MinWidth(Open? 250:10));
        Open = GUILayout.Toggle(Open, "Mosaic Controls");
        if (Open)
        {
            ControlWindow();
        }
        GUILayout.EndVertical();

        // Hack: Tell MayaCamera where our main UI box is, so clicking inside it doesn't move the
        // camera.  There's no GUILayout API to do this.
        MayaCamera mayaCamera = gameObject.GetComponent <MayaCamera>();

        if (Event.current.type == EventType.Repaint && mayaCamera != null)
        {
            // Get the rect for the vertical area we just drew.
            Rect LatestUIRect = GUILayoutUtility.GetLastRect();

            // GetLastRect doesn't take the area position into account, so we have to add the
            // origin given to BeginArea.  This is not a good API.
            LatestUIRect.x += 10;
            LatestUIRect.y += 10;

            // Different coordinate spaces:
            LatestUIRect.y = Screen.height - LatestUIRect.x - LatestUIRect.height;

            mayaCamera.IgnoreRect = LatestUIRect;
        }

        GUILayout.EndArea();

        Refresh();
    }