Exemple #1
0
        public void SetRI(Camera c, RawImage ri, IsometricOrtho_Container scs, ScrollRect sr)
        {
            if (scs.isAnimated == false)
            {
                ri.material.SetFloat("_Near", scs.FloatForNearClip);
                ri.material.SetFloat("_Far", scs.FloatForFarClip);
                //Debug.Log("Nice: " + (((2 * c.scaledPixelWidth) / 1280.0f) - 1.0f));

                // This works for texture of 2560, scalar is 1.0f, for texture of 5120, scalar is 2.0f
                ri.rectTransform.sizeDelta = new Vector2(scs.widthFromTexture * scs.multiplierFromTexture, scs.heightFromTexture * scs.multiplierFromTexture);
                // this works for scaling (WORK ON THIS LATER)    //ri.rectTransform.sizeDelta = new Vector2(scs.widthFromTexture * ((c.scaledPixelWidth) / 960.0f) / scs.rectSizeScalar, scs.heightFromTexture * ((c.scaledPixelHeight) / 540.0f) / scs.rectSizeScalar); // For 1920x1080
                //ri.rectTransform.sizeDelta = new Vector2(scs.widthFromTexture * 1.333f, scs.heightFromTexture * 1.333f); // For 1280x720
                //ri.rectTransform.sizeDelta = new Vector2(scs.widthFromTexture * (((2 * c.scaledPixelWidth ) / 1280.0f) - 1.0f), scs.heightFromTexture * (((2 * c.scaledPixelHeight) / 720.0f) - 1.0f));

                ri.material.SetTexture("_RenderedTex", scs.renderedTexture);
                ri.material.SetTexture("_DepthTex", scs.depthTexture);
            }

            if (scs.isAnimated == true)
            {
                ri.material.SetFloat("_Near", scs.FloatForNearClip);
                ri.material.SetFloat("_Far", scs.FloatForFarClip);

                ri.rectTransform.sizeDelta = new Vector2(scs.widthFromTexture * scs.multiplierFromTexture, scs.heightFromTexture * scs.multiplierFromTexture);
            }

            sr.viewport.sizeDelta = new Vector2(Screen.width, Screen.height);
        }
        public override void Execute(Camera c, RawImage ri, IsometricOrtho_Container scs, GameObject cH)
        {
            /*
             * if (followModeOn.value == true)
             * {
             *      if (cameraTransEvent.value == true)
             *      {
             *              SetOrthoVector3(ri, c, scs);
             *      }
             * }*/


            /*
             * if (Input.GetMouseButtonDown(0))
             * {
             *      Ray myThirdRay = c.ScreenPointToRay(Input.mousePosition);
             *
             *      RaycastHit hitInfo;
             *
             *      if (Physics.Raycast(myThirdRay, out hitInfo, 100, clickOnMyLayerDaddy))
             *      {
             *              myAgent.SetDestination(hitInfo.point);
             *      }
             * }*/

            //base.Execute(c, ri, scs, cH);
        }
Exemple #3
0
        public Vector2 SetOrthoCamToRI(RawImage ri, Camera c, IsometricOrtho_Container scs, Vector3 abc)
        {
            // Okay, need to set in SCS. for 5120 mulx = 320 ...., for 2560 muly = 180,
            float mulx = scs.rayXOffset * abc.x * (0.32f * ((orthoScaledSizeFromTexture.value) / c.orthographicSize));
            float muly = scs.rayYOffset * abc.y * (0.568889f * ((orthoScaledSizeFromTexture.value) / c.orthographicSize));

            return(new Vector2(mulx, muly));
        }
Exemple #4
0
 public override void UpdateIsoScene(Camera c, RawImage ri, IsometricOrtho_Container scs, ScrollRect sr, Camera oc, GameObject cH)
 {
     if (scs.isAnimated == true)
     {
         playAnimationEvent.value = true;
     }
     else
     {
         playAnimationEvent.value = false;
     }
 }
 // Implement an OnEnable Variable for the new Set Container System.
 IEnumerator PlayPrerenderedAnimation_Coroutine(Camera c, RawImage ri, IsometricOrtho_Container ico, float time)
 {
     // This is Logic for a Loopable Animation : Good for backgrounds
     while (playAnimEvent.value == true)
     {
         for (int i = 0; i < ico.depthTextureSequence.Count; i++)
         {
             ri.material.SetTexture("_RenderedTex", ico.depthTextureSequence[i]);
             ri.material.SetTexture("_DepthTex", ico.depthTextureSequence[i]);
             yield return(new WaitForSeconds(time));
         }
     }
 }
Exemple #6
0
        public void SetOrthoVector3(RawImage ri, Camera c, IsometricOrtho_Container scs)
        {
            float newMulForZoomAndScreenX = ((2 / ri.rectTransform.sizeDelta.x) * (ri.rectTransform.sizeDelta.x - c.scaledPixelWidth));
            float newMulForZoomAndScreenY = ((2 / ri.rectTransform.sizeDelta.y) * (ri.rectTransform.sizeDelta.y - c.scaledPixelHeight));

            c.transform.localPosition = new Vector3(
                Mathf.Clamp(-ri.rectTransform.anchoredPosition.x * 0.0195313f * ((scs.xAnchoredOffset * 2) / ri.rectTransform.sizeDelta.x),
                            -scs.xOffset * newMulForZoomAndScreenX, scs.xOffset * newMulForZoomAndScreenX),
                Mathf.Clamp(-ri.rectTransform.anchoredPosition.y * 0.0195313f * ((scs.yAnchoredOffset * 2) / ri.rectTransform.sizeDelta.y),
                            -scs.yOffset * newMulForZoomAndScreenY, scs.yOffset * newMulForZoomAndScreenY), 0);

            //runtimeVector3.value = c.transform.localPosition;
        }
        public override void UpdateIsoScene(Camera c, RawImage ri, IsometricOrtho_Container scs, ScrollRect sr, Camera oc, GameObject cH)
        {
            SetRI(c, ri, scs, sr);
            SetC(c, ri, scs);
            SetCHolder(c, ri, scs, cH);

            #region trash
            //thePosition = cH.transform.TransformPoint(Vector3.right);
            //Instantiate(c, thePosition, cH.transform.rotation);
            //Debug.Log("The Position is: " + thePosition);
            //Vector3 localDirection = c.transform.InverseTransformDirection(

            //base.UpdateScene(c, ri, scs, sr, oc);
            #endregion
        }
Exemple #8
0
        public void SetC(Camera c, RawImage ri, IsometricOrtho_Container scs)
        {
            c.nearClipPlane = scs.FloatForNearClip;
            c.farClipPlane  = scs.FloatForFarClip;

            c.transform.localEulerAngles = new Vector3(0, 0, 0);

            c.orthographic = true;

            //float a1 = scs.multiplierFromTexture
            //c.orthographicSize = 5.265f;
            //c.orthographicSize = (scs.orthoSizeFromTexture - (scs.orthoSizeFromTexture / 4.0f)); //(1280.0f / (1920.0f - 960.0f)));
            //c.orthographicSize = 5.265f;
            //c.orthographicSize = scs.orthoSizeFromTexture * ((c.scaledPixelWidth) / (c.scaledPixelWidth - 640.0f)) / 2.0f;
            //c.orthographicSize = (scs.orthoSizeFromTexture * (1.5f)) / scs.multiplierFromTexture;
            c.orthographicSize = (scs.orthoSizeFromTexture * (c.scaledPixelWidth / 1280.0f)) / scs.multiplierFromTexture;
        }
Exemple #9
0
        public override void Execute(Camera c, RawImage ri, IsometricOrtho_Container scs, GameObject cH)
        {
            //ri.material.SetMatrix("_Perspective", c.projectionMatrix);
            // Get mouse axis
            mouseAxis = Input.GetAxis("Mouse ScrollWheel");

            orthoScaledSizeFromTexture.value = (scs.orthoSizeFromTexture * (c.scaledPixelWidth / 1280.0f));

            // This should run every frame.
            runtimeVector2.value = new Vector2(
                ri.rectTransform.anchoredPosition.x * (c.orthographicSize / (orthoScaledSizeFromTexture.value)) * (5120.0f / scs.widthFromTexture),
                ri.rectTransform.anchoredPosition.y * (c.orthographicSize / (orthoScaledSizeFromTexture.value)) * (5120.0f / scs.widthFromTexture));

            // For Panning Operation
            if (horizontalAxis.value > 0 || horizontalAxis.value < 0 || verticalAxis.value > 0 || verticalAxis.value < 0)
            {
                panBool.value = true;
            }
            else
            {
                panBool.value = false;
            }

            // For Zooming Operation
            if (mouseAxis > 0 || mouseAxis < 0)
            {
                zoomBool.value = true;
                if (mouseAxis > 0)
                {
                    amount.value = 1.1f;
                }
                else if (mouseAxis < 0)
                {
                    amount.value = 0.9f;
                }
            }
            else
            {
                zoomBool.value = false;
            }

            // For Ray Operation
        }
Exemple #10
0
        public override void Execute(Camera c, RawImage ri, IsometricOrtho_Container scs, GameObject cH)
        {
            if (panBool.value == true)
            {
                cameraTransEvent.value = false;
                Debug.Log("Pan Operation Is On!");

                if (horizontalAxis.value < -0.15)
                {
                    ri.rectTransform.anchoredPosition += new Vector2(Mathf.Lerp(0, -horizontalAxis.value * 25, delta.value * 100), 0);                     //Original delta = Time.deltaTime * 100
                    SetOrthoVector3(ri, c, scs);
                }

                if (horizontalAxis.value > 0.15)
                {
                    ri.rectTransform.anchoredPosition -= new Vector2(Mathf.Lerp(0, horizontalAxis.value * 25, delta.value * 100), 0);
                    SetOrthoVector3(ri, c, scs);
                }

                if (verticalAxis.value < -0.15)
                {
                    ri.rectTransform.anchoredPosition += new Vector2(0, Mathf.Lerp(0, -verticalAxis.value * 25, delta.value * 100));
                    SetOrthoVector3(ri, c, scs);
                }

                if (verticalAxis.value > 0.15)
                {
                    ri.rectTransform.anchoredPosition -= new Vector2(0, Mathf.Lerp(0, verticalAxis.value * 25, delta.value * 100));
                    SetOrthoVector3(ri, c, scs);
                }
            }
            else
            {
                //cameraTransEvent.value = true;
                Debug.Log("Pan Operation Is Off!");
            }

            // No clue what this does...
            //base.Execute(c, ri, scs);
        }
Exemple #11
0
 public abstract void UpdateIsoScene(Camera c, RawImage ri, IsometricOrtho_Container io_c, ScrollRect sr, Camera oc, GameObject cH);
Exemple #12
0
 public void SetCHolder(Camera c, RawImage ri, IsometricOrtho_Container scs, GameObject cH)
 {
     cH.transform.localPosition    = scs.CameraPosition;
     cH.transform.localEulerAngles = scs.CameraRotation;
 }
 public abstract void Execute(Camera c, RawImage ri, IsometricOrtho_Container io_c, GameObject cH);
        public override void Execute(Camera c, RawImage ri, IsometricOrtho_Container scs, GameObject cH)
        {
            // WHAT AM I TRYING TO DO?
            // 1. Converting local position to with accuracy
            // 2. Move capsule to

            /*if (myAgent != null)
             * {
             *
             * }*/

            if (Input.GetMouseButtonDown(0))
            {
                //Ray myRayScreen = c.ViewportPointToRay(new Vector3(0.5F, 0.5F, 0));
                Ray myRay = c.ScreenPointToRay(Input.mousePosition);

                RaycastHit hitInfoViewOffset;

                if (Physics.Raycast(myRay, out hitInfoViewOffset, 100, raycastLayer))
                {
                    #region InternalInformation
                    // cH.transform.InverseTransformDirection is what I want!
                    // Bounds are -25.0 to 25.0 for x.
                    // Bounds are x to y, but... they do sum up to -14.0265 to 14.0265 for y.
                    #endregion

                    //cameraTransEvent.value = false;

                    Vector3 destination = cH.transform.InverseTransformDirection(hitInfoViewOffset.point);

                    setVec2.value = SetOrthoCamToRI(ri, c, scs, new Vector3(-destination.x, -destination.y, 0));
                    setVec3.value = hitInfoViewOffset.point;

                    SetOrthoVector3(ri, c, scs);

                    cameraTransEvent.value = true;

                    /*
                     * if (followModeOn.value == true)
                     * {
                     *      cameraTransEvent.value = true;
                     * }
                     * else
                     * {
                     *      cameraTransEvent.value = false;
                     * }*/

                    #region testingStuff
                    // The offset for x or y is based on the centre of the camera in maya from 0.
                    // The really easy way to solve this problem is to just render with the centre on world 0.
                    // For SCS_09 destination.y is 'destination.y - 8.303098f'

                    //Debug.Log("hitInfo.point X: " + destination.x + ", hitInfo.point Y: " + destination.y);


                    //ri.rectTransform.anchoredPosition = new Vector2(setVec2.value.x, setVec2.value.y);
                    //ri.rectTransform.anchoredPosition = new Vector2(Mathf.Lerp(ri.rectTransform.anchoredPosition.x, setVec2.value.x, Time.deltaTime), Mathf.Lerp(ri.rectTransform.anchoredPosition.y, setVec2.value.y, Time.deltaTime));


                    //Debug.Log(SetOrthoCamToRI(ri, c, scs, new Vector3(charTest.transform.position.x, charTest.transform.position.y, 0)));
                    #endregion
                }
            }

            if (cameraTransEvent.value == true)
            {
                SetOrthoVector3(ri, c, scs);
            }

            if (Input.GetMouseButtonDown(1))
            {
                Debug.Log("Currently mouse button 2 does nothing");
            }

            //base.Execute(c, ri, scs);
        }
        public override void Execute(Camera c, RawImage ri, IsometricOrtho_Container scs, GameObject cH)
        {
            //base.Execute(c, ri, scs);
            if (zoomBool.value == true)
            {
                cameraTransEvent.value = false;
                Debug.Log("Zoom Operation Is On!");

                c.orthographicSize         /= amount.value;
                ri.rectTransform.sizeDelta *= new Vector2(amount.value, amount.value);

                // Limit Zoom (Ortho Size)
                if (c.orthographicSize >= orthoScaledSizeFromTexture.value / scs.multiplierFromTexture)
                {
                    c.orthographicSize = orthoScaledSizeFromTexture.value / scs.multiplierFromTexture;
                }
                if (c.orthographicSize <= orthoScaledSizeFromTexture.value / scs.secondMultiplierFromTexture)
                {
                    c.orthographicSize = orthoScaledSizeFromTexture.value / scs.secondMultiplierFromTexture;
                }

                // Limit Zoom (Raw Image Size Delta)
                if (ri.rectTransform.sizeDelta.x <= scs.widthFromTexture * scs.multiplierFromTexture)
                {
                    ri.rectTransform.sizeDelta = new Vector2(scs.widthFromTexture * scs.multiplierFromTexture, scs.heightFromTexture * scs.multiplierFromTexture);
                }
                if (ri.rectTransform.sizeDelta.x >= scs.widthFromTexture * scs.secondMultiplierFromTexture)
                {
                    ri.rectTransform.sizeDelta = new Vector2(scs.widthFromTexture * scs.secondMultiplierFromTexture, scs.heightFromTexture * scs.secondMultiplierFromTexture);
                }

                if (c.transform.localPosition.x > 0)
                {
                    if (c.transform.localPosition.y > 0)
                    {
                        targetString = "x > 0, y > 0";
                        ri.rectTransform.anchoredPosition = new Vector2(
                            Mathf.Clamp(ri.rectTransform.anchoredPosition.x * amount.value, runtimeVector2.value.x * 2, runtimeVector2.value.x),
                            Mathf.Clamp(ri.rectTransform.anchoredPosition.y * amount.value, runtimeVector2.value.y * 2, runtimeVector2.value.y));
                        SetOrthoVector3(ri, c, scs);
                    }
                    else if (c.transform.localPosition.y < 0)
                    {
                        targetString = "x > 0, y < 0";
                        ri.rectTransform.anchoredPosition = new Vector2(
                            Mathf.Clamp(ri.rectTransform.anchoredPosition.x * amount.value, runtimeVector2.value.x * 2, runtimeVector2.value.x),
                            Mathf.Clamp(ri.rectTransform.anchoredPosition.y * amount.value, runtimeVector2.value.y, runtimeVector2.value.y * 2));
                        SetOrthoVector3(ri, c, scs);
                    }
                }

                // if x < 0
                if (c.transform.localPosition.x < 0)
                {
                    if (c.transform.localPosition.y > 0)
                    {
                        targetString = "x < 0, y > 0";
                        ri.rectTransform.anchoredPosition = new Vector2(
                            Mathf.Clamp(ri.rectTransform.anchoredPosition.x * amount.value, runtimeVector2.value.x, runtimeVector2.value.x * 2),
                            Mathf.Clamp(ri.rectTransform.anchoredPosition.y * amount.value, runtimeVector2.value.y * 2, runtimeVector2.value.y));
                        SetOrthoVector3(ri, c, scs);
                    }
                    else if (c.transform.localPosition.y < 0)
                    {
                        targetString = "x < 0, y < 0";
                        ri.rectTransform.anchoredPosition = new Vector2(
                            Mathf.Clamp(ri.rectTransform.anchoredPosition.x * amount.value, runtimeVector2.value.x, runtimeVector2.value.x * 2),
                            Mathf.Clamp(ri.rectTransform.anchoredPosition.y * amount.value, runtimeVector2.value.y, runtimeVector2.value.y * 2));
                        SetOrthoVector3(ri, c, scs);
                    }
                }

                // If x = 0
                if (c.transform.localPosition.x == 0)
                {
                    if (c.transform.localPosition.y > 0)
                    {
                        targetString = "x = 0, y > 0";
                        ri.rectTransform.anchoredPosition = new Vector2(
                            0,
                            Mathf.Clamp(ri.rectTransform.anchoredPosition.y * amount.value, runtimeVector2.value.y * 2, runtimeVector2.value.y));
                        SetOrthoVector3(ri, c, scs);
                    }
                    else if (c.transform.localPosition.y < 0)
                    {
                        targetString = "x = 0, y < 0";
                        ri.rectTransform.anchoredPosition = new Vector2(
                            0,
                            Mathf.Clamp(ri.rectTransform.anchoredPosition.y * amount.value, runtimeVector2.value.y, runtimeVector2.value.y * 2));
                        SetOrthoVector3(ri, c, scs);
                    }
                }

                // If y = 0
                if (c.transform.localPosition.y == 0)
                {
                    if (c.transform.localPosition.x > 0)
                    {
                        targetString = "x > 0, y = 0";
                        ri.rectTransform.anchoredPosition = new Vector2(
                            Mathf.Clamp(ri.rectTransform.anchoredPosition.x * amount.value, runtimeVector2.value.x * 2, runtimeVector2.value.x),
                            0);
                        SetOrthoVector3(ri, c, scs);
                    }
                    else if (c.transform.localPosition.x < 0)
                    {
                        targetString = "x < 0, y = 0";
                        ri.rectTransform.anchoredPosition = new Vector2(
                            Mathf.Clamp(ri.rectTransform.anchoredPosition.x * amount.value, runtimeVector2.value.x, runtimeVector2.value.x * 2),
                            0);
                        SetOrthoVector3(ri, c, scs);
                    }
                }
            }
            else
            {
                //cameraTransEvent.value = true;
                Debug.Log("Zoom Operation Is Off!");
            }
        }