Exemplo n.º 1
0
    private void Update()
    {
        float input1 = InputVR.GetPress(true, InputVR.ButtonMask.Trigger) ? 1 : 0.1f;
        float input2 = InputVR.GetPress(false, InputVR.ButtonMask.Trigger) ? 1 : 0.1f;

        trigPress1.localScale = new Vector3(1, input1, 1);
        trigPress2.localScale = new Vector3(1, input2, 1);

        float axis1 = InputVR.GetAxis(true, InputVR.ButtonMask.Trigger).x;
        float axis2 = InputVR.GetAxis(false, InputVR.ButtonMask.Trigger).x;

        trigAxis1.localScale = new Vector3(1, axis1, 1);
        trigAxis2.localScale = new Vector3(1, axis2, 1);
    }
 // change to the nice generic system
 public bool GetPressUpButton()
 {
     return(InputVR.GetPressUp(isLeft, InputVR.ButtonMask.Trigger));
     //return controllerWrapper.GetPressUp(ControllerWrapper.ButtonMask.Trigger);
 }
Exemplo n.º 3
0
    void OnGUI()
    {
        EditorGUILayout.LabelField("Resolution", EditorStyles.boldLabel);
        resWidth  = EditorGUILayout.IntField("Width", resWidth);
        resHeight = EditorGUILayout.IntField("Height", resHeight);

        EditorGUILayout.Space();

        scale = EditorGUILayout.IntSlider("Scale", scale, 1, 15);

        EditorGUILayout.HelpBox("The default mode of screenshot is crop - so choose a proper width and height. The scale is a factor " +
                                "to multiply or enlarge the renders without loosing quality.", MessageType.None);


        EditorGUILayout.Space();


        GUILayout.Label("Save Path", EditorStyles.boldLabel);

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.TextField(path, GUILayout.ExpandWidth(false));
        if (GUILayout.Button("Browse", GUILayout.ExpandWidth(false)))
        {
            path = EditorUtility.SaveFolderPanel("Path to Save Images", path, Application.dataPath);
        }

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.HelpBox("Choose the folder in which to save the screenshots ", MessageType.None);
        EditorGUILayout.Space();



        //isTransparent = EditorGUILayout.Toggle(isTransparent,"Transparent Background");



        GUILayout.Label("Select Camera", EditorStyles.boldLabel);


        myCamera = EditorGUILayout.ObjectField(myCamera, typeof(Camera), true, null) as Camera;


        if (myCamera == null)
        {
            myCamera = Camera.main;
        }

        isTransparent = EditorGUILayout.Toggle("Transparent Background", isTransparent);


        EditorGUILayout.HelpBox("Choose the camera of which to capture the render. You can make the background transparent using the transparency option.", MessageType.None);

        EditorGUILayout.Space();
        EditorGUILayout.BeginVertical();
        EditorGUILayout.LabelField("Default Options", EditorStyles.boldLabel);


        if (GUILayout.Button("Set To Screen Size"))
        {
            resHeight = (int)Handles.GetMainGameViewSize().y;
            resWidth  = (int)Handles.GetMainGameViewSize().x;
        }


        if (GUILayout.Button("Default Size"))
        {
            resHeight = 1440;
            resWidth  = 2560;
            scale     = 1;
        }



        EditorGUILayout.EndVertical();

        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Screenshot will be taken at " + resWidth * scale + " x " + resHeight * scale + " px", EditorStyles.boldLabel);

        if (GUILayout.Button("Take Screenshot", GUILayout.MinHeight(60)))
        {
            if (path == "")
            {
                path = EditorUtility.SaveFolderPanel("Path to Save Images", path, Application.dataPath);
                Debug.Log("Path Set");
                TakeHiResShot();
            }
            else
            {
                TakeHiResShot();
            }
        }

        openFolderAfterEachShot = GUILayout.Toggle(openFolderAfterEachShot, "Open Folder after each shot?");

        if (GUILayout.Button("Take Screenshots every X seconds", GUILayout.MinHeight(60)))
        {
            if (takingManyScreenshots)
            {
                takingManyScreenshots = false;
            }
            else
            {
                takingManyScreenshots = true;
                if (Application.isPlaying)
                {
                    FindObjectOfType <MonoBehaviour>().StartCoroutine(TakeManyScreenshots());
                }
            }
        }
        screenshotEveryXSeconds = EditorGUILayout.FloatField(screenshotEveryXSeconds);

        useController = EditorGUILayout.Toggle("Use controller", useController);
        if (useController)
        {
            if (InputVR.GetPressDown(false, InputVR.ButtonMask.Touchpad) || InputVR.GetPressDown(true, InputVR.ButtonMask.Touchpad))
            {
                TakeHiResShot();
            }
        }

        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button("Open Last Screenshot", GUILayout.MaxWidth(160), GUILayout.MinHeight(40)))
        {
            if (lastScreenshot != "")
            {
                Application.OpenURL("file://" + lastScreenshot);
                Debug.Log("Opening File " + lastScreenshot);
            }
        }

        if (GUILayout.Button("Open Folder", GUILayout.MaxWidth(100), GUILayout.MinHeight(40)))
        {
            Application.OpenURL("file://" + path);
        }

        if (GUILayout.Button("More Assets", GUILayout.MaxWidth(100), GUILayout.MinHeight(40)))
        {
            Application.OpenURL("https://www.assetstore.unity3d.com/en/#!/publisher/5951");
        }

        EditorGUILayout.EndHorizontal();


        if (takeHiResShot)
        {
            int           resWidthN  = resWidth * scale;
            int           resHeightN = resHeight * scale;
            RenderTexture rt         = new RenderTexture(resWidthN, resHeightN, 24);
            myCamera.targetTexture = rt;

            TextureFormat tFormat;
            if (isTransparent)
            {
                tFormat = TextureFormat.ARGB32;
            }
            else
            {
                tFormat = TextureFormat.RGB24;
            }


            if (screenShot == null)
            {
                screenShot = new Texture2D(resWidthN, resHeightN, tFormat, false);
            }
            myCamera.Render();
            RenderTexture.active = rt;
            screenShot.ReadPixels(new Rect(0, 0, resWidthN, resHeightN), 0, 0);
            myCamera.targetTexture = null;
            RenderTexture.active   = null;
            bytes = screenShot.EncodeToPNG();
            string filename = ScreenShotName(resWidthN, resHeightN);

            System.IO.File.WriteAllBytes(filename, bytes);
            Debug.Log(string.Format("Took screenshot to: {0}", filename));

            if (openFolderAfterEachShot)
            {
                Application.OpenURL(filename);
            }
            takeHiResShot = false;
        }

        EditorGUILayout.HelpBox("In case of any error, make sure you have Unity Pro as the plugin requires Unity Pro to work.", MessageType.Info);
    }