SkyBackground.cs 623 B

12345678910111213141516171819202122232425
  1. using UnityEngine;
  2. using System.Collections;
  3. public class SkyBackground : MonoBehaviour {
  4. //支持中文%
  5. // Use this for initialization
  6. void Start () {
  7. Update();
  8. }
  9. // Update is called once per frame
  10. public void Update ()
  11. {
  12. Vector3 left = Camera.main.ScreenToWorldPoint(new Vector3(0, Screen.height/2f, 0));
  13. Vector3 position = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width/2f, Screen.height/2f, 50f));
  14. transform.position = position;
  15. float width = Mathf.Abs(position.x-left.x);
  16. Vector3 scale = transform.localScale;
  17. scale.x = scale.y = width*2f;
  18. transform.localScale = scale;
  19. }
  20. }