Ejemplo n.º 1
0
 public static void ShowWindow()
 {
     if (window == null)
     {
         window = GetWindow <MainWindow>(" Settings", true);
         Texture2D tex = Resources.Load("Icons/mouse", typeof(Texture2D)) as Texture2D;
         window.titleContent.image = tex;
         Rect pos = window.position;
         pos.x           = Screen.currentResolution.width * 0.75f;
         pos.y           = Screen.currentResolution.height * 0.5f;
         pos.width       = 385;
         pos.height      = 520;
         window.position = pos;
         // Call tab windows.
         ActorWindow.ShowWindow();
         DisplaysWindow.ShowWindow();
         // Refocus to main.
         window.Focus();
     }
 }
Ejemplo n.º 2
0
    private void ImportSetup()
    {
        // Import dialogue (Continue: Yes/No)
        bool choice = EditorUtility.DisplayDialog("Erase current setup?",
                                                  "Importing this setup will remove all current Actors,Controllers and Displays", "Continue", "Cancel");

        if (!choice)
        {
            return;
        }
        // File Dialogue.
        string inputFile = EditorUtility.OpenFilePanel("Import Setup", Application.dataPath, "gimblsetup");

        if (inputFile.Length == 0)
        {
            return;
        }
        // Remove Actors and Controllers (repopulate..)
        DestroyImmediate(GameObject.Find("Actors"));
        DestroyImmediate(GameObject.Find("Controllers"));
        //Import package.
        AssetDatabase.ImportPackage(inputFile, false);
        //Instantiate Actors.
        Object     actObj = AssetDatabase.LoadAssetAtPath("Assets/tempActors.prefab", typeof(Object));
        GameObject actors = Instantiate(actObj) as GameObject;

        actors.name = "Actors";
        //Instantiate Controllers..
        Object     contObj     = AssetDatabase.LoadAssetAtPath("Assets/tempControllers.prefab", typeof(Object));
        GameObject controllers = Instantiate(contObj) as GameObject;

        controllers.name = "Controllers";
        // Load Camera setup. (stored in Assets/VRSettings/Displays/savedFullScreenViews.asset).
        DisplaysWindow win = (DisplaysWindow)GetWindow(typeof(DisplaysWindow));

        win.fullScreenManager.LoadCameras();
        // Set render layers.
        foreach (ActorObject act in actors.GetComponentsInChildren <ActorObject>())
        {
            //Create layer.
            if (LayerMask.NameToLayer(act.name) == -1)
            {
                TagLayerEditor.TagsAndLayers.AddLayer(act.name);
            }
            GameObject model = act.GetComponentInChildren <MeshRenderer>().gameObject;
            //Set Layer.
            model.layer = LayerMask.NameToLayer(act.name);
            // Set Culling mask.
            if (act.gameObject.GetComponentInChildren <DisplayObject>() != null)
            {
                foreach (Camera cam in act.gameObject.GetComponentInChildren <DisplayObject>().GetComponentsInChildren <Camera>())
                {
                    cam.cullingMask  = -1; // show everything
                    cam.cullingMask &= ~(1 << LayerMask.NameToLayer(act.name));
                }
            }
        }
        // Remove tmeporary assets.
        AssetDatabase.DeleteAsset("Assets/tempActors.prefab");
        AssetDatabase.DeleteAsset("Assets/tempControllers.prefab");
    }