Zone View Mousedrag & Background Parallax
This commit is contained in:
parent
4221f304f1
commit
6dd43fc193
9 changed files with 113 additions and 5 deletions
|
|
@ -10,19 +10,19 @@ public class BackgroundRenderer : MonoBehaviour
|
|||
// public float RotationSpeed2 = 1;
|
||||
private Camera _camera;
|
||||
private float _ratio;
|
||||
//private Material _material;
|
||||
private Material _material;
|
||||
private float _depth;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_camera = GetComponent<Camera>();
|
||||
_depth = Background.position.z;
|
||||
//_material = Background.GetComponent<MeshRenderer>().material;
|
||||
_material = Background.GetComponent<MeshRenderer>().material;
|
||||
}
|
||||
|
||||
private void OnPreRender()
|
||||
{
|
||||
//_material.SetVector("Rot1", );
|
||||
_material.SetVector("ParallaxDirection", transform.position);
|
||||
_ratio = (float) Screen.height / Screen.width;
|
||||
Background.position = new Vector3(transform.position.x, transform.position.y, _depth);
|
||||
var size = _camera.orthographicSize;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using UnityEngine;
|
|||
|
||||
public class ZoneRenderer : MonoBehaviour
|
||||
{
|
||||
public Camera FollowCamera;
|
||||
public Material BackgroundMaterial;
|
||||
public RenderTexture GravityTexture;
|
||||
public MeshRenderer GravityRenderer;
|
||||
|
|
@ -20,6 +21,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
|
||||
private void OnPreRender()
|
||||
{
|
||||
_camera.transform.position = FollowCamera.transform.position;
|
||||
if (Screen.width != _resX || Screen.height != _resY)
|
||||
{
|
||||
_resX = Screen.width;
|
||||
|
|
|
|||
Loading…
Reference in a new issue