Exemple #1
0
 public virtual void Start()
 {
     mainCamObj   = GameObject.FindWithTag("MainCamera");                       // Main Camera
     cursorObj    = GameObject.FindWithTag("cursor");
     cursorScript = (s3dGuiCursor)cursorObj.GetComponent(typeof(s3dGuiCursor)); // Main Stereo Camera Script
     startPos     = transform.position;
     startRot     = transform.rotation;
     GetComponent <Rigidbody>().centerOfMass = customCenterOfMass;
 }
Exemple #2
0
 public virtual void Start()
 {
     this.mainCamObj   = GameObject.FindWithTag("MainCamera"); // Main Camera
     this.cursorObj    = GameObject.FindWithTag("cursor");
     this.cursorScript = (s3dGuiCursor)this.cursorObj.GetComponent(typeof(s3dGuiCursor));
     if (!this.GetComponent <Rigidbody>())
     {
         this.startPos      = this.transform.position;
         this.startRot      = this.transform.rotation;
         this.foundStartPos = true;
     }
 }
Exemple #3
0
    public virtual IEnumerator Start()
    {
        findS3dCamera();
        checkpoints = new Vector2[5];
        objectCopyR = UnityEngine.Object.Instantiate(gameObject, transform.position, transform.rotation);
        UnityEngine.Object.Destroy((s3dGuiTexture)objectCopyR.GetComponent(typeof(s3dGuiTexture)));
        objectCopyR.name  = gameObject.name + "_R";
        gameObject.name   = gameObject.name + "_L";
        gameObject.layer  = camera3D.leftOnlyLayer;
        objectCopyR.layer = camera3D.rightOnlyLayer;
        obPosition        = gameObject.transform.position;

        // if using stereo shader + side-by-side + not squeezed, double width of guiTexture
        if ((camera3D.useStereoShader && (camera3D.format3D == (mode3D)0)) && !camera3D.sideBySideSqueezed)
        {
            xWidth = GetComponent <GUITexture>().pixelInset.width * 2;

            {
                float _33 = xWidth;
                Rect  _34 = gameObject.GetComponent <GUITexture>().pixelInset;
                _34.width = _33;
                gameObject.GetComponent <GUITexture>().pixelInset = _34;
            }

            {
                float _35 = xWidth;
                Rect  _36 = objectCopyR.GetComponent <GUITexture>().pixelInset;
                _36.width = _35;
                objectCopyR.GetComponent <GUITexture>().pixelInset = _36;
            }
            xInset = gameObject.GetComponent <GUITexture>().pixelInset.width / -2;

            {
                float _37 = xInset;
                Rect  _38 = gameObject.GetComponent <GUITexture>().pixelInset;
                _38.x = _37;
                gameObject.GetComponent <GUITexture>().pixelInset = _38;
            }

            {
                float _39 = xInset;
                Rect  _40 = objectCopyR.GetComponent <GUITexture>().pixelInset;
                _40.x = _39;
                objectCopyR.GetComponent <GUITexture>().pixelInset = _40;
            }
        }
        else
        {
            // if not using stereo shader + squeezed, halve width of guiTexture
            if (!camera3D.useStereoShader && camera3D.sideBySideSqueezed)
            {
                xWidth = gameObject.GetComponent <GUITexture>().pixelInset.width * 0.5f;

                {
                    float _41 = xWidth;
                    Rect  _42 = gameObject.GetComponent <GUITexture>().pixelInset;
                    _42.width = _41;
                    gameObject.GetComponent <GUITexture>().pixelInset = _42;
                }

                {
                    float _43 = xWidth;
                    Rect  _44 = objectCopyR.GetComponent <GUITexture>().pixelInset;
                    _44.width = _43;
                    objectCopyR.GetComponent <GUITexture>().pixelInset = _44;
                }
                xInset = gameObject.GetComponent <GUITexture>().pixelInset.width / -2;

                {
                    float _45 = xInset;
                    Rect  _46 = gameObject.GetComponent <GUITexture>().pixelInset;
                    _46.x = _45;
                    gameObject.GetComponent <GUITexture>().pixelInset = _46;
                }

                {
                    float _47 = xInset;
                    Rect  _48 = objectCopyR.GetComponent <GUITexture>().pixelInset;
                    _48.x = _47;
                    objectCopyR.GetComponent <GUITexture>().pixelInset = _48;
                }
            }
        }
        // find corner offset
        corner = new Vector2((gameObject.GetComponent <GUITexture>().pixelInset.width / 2) / Screen.width, (gameObject.GetComponent <GUITexture>().pixelInset.height / 2) / Screen.height);
        toggleVisible(beginVisible);
        float horizontalFOV = (2 * Mathf.Atan(Mathf.Tan((camera3D.GetComponent <Camera>().fieldOfView *Mathf.Deg2Rad) / 2) * camera3D.GetComponent <Camera>().aspect)) * Mathf.Rad2Deg;

        unitWidth   = Mathf.Tan((horizontalFOV / 2) * Mathf.Deg2Rad); // need unit width to calculate cursor depth when there's a HIT (horizontal image transform)
        screenWidth = (unitWidth * camera3D.zeroPrlxDist) * 2;
        setScreenParallax();
        if (timeToDisplay != 0f)
        {
            yield return(new WaitForSeconds(timeToDisplay));

            toggleVisible(false);
        }
        s3dCursor = (s3dGuiCursor)gameObject.GetComponent(typeof(s3dGuiCursor));
        if (s3dCursor)
        {
            s3dCursor.initialize();
        }
    }