You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.4 KiB

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class WaterSetUp : MonoBehaviour {
  5. // Use this for initialization
  6. void Start () {
  7. Vector3 originalScale = transform.localScale;
  8. Vector2 texScale = Vector3.one;// GetComponent<Renderer>().material.GetTextureScale("_Perlin");
  9. transform.localScale = Vector3.one;
  10. for (float x = -originalScale.x/2; x < originalScale.x / 2; x++) {
  11. for (float z = -originalScale.z / 2; z < originalScale.z/2; z++) {
  12. //Debug.Log("blah");
  13. Vector3 pos = transform.position;
  14. pos.x += transform.lossyScale.x * x;
  15. pos.z += transform.lossyScale.z * z;
  16. Vector2 texOffset = new Vector2(texScale.x * x, texScale.y * z);
  17. GameObject waterClone = Instantiate(gameObject, pos, transform.rotation, transform);
  18. // waterClone.GetComponent<Renderer>().material.SetTextureOffset("_Diffuse", texOffset);
  19. // waterClone.GetComponent<Renderer>().material.SetTextureOffset("_Normals", texOffset);
  20. // waterClone.GetComponent<Renderer>().material.SetTextureOffset("_Perlin", texOffset);
  21. // waterClone.GetComponent<Renderer>().material.SetTextureOffset("_Perlin_copy", texOffset);
  22. }
  23. }
  24. Debug.Log("blah");
  25. }
  26. }