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

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WaterSetUp : MonoBehaviour {
// Use this for initialization
void Start () {
Vector3 originalScale = transform.localScale;
Vector2 texScale = Vector3.one;// GetComponent<Renderer>().material.GetTextureScale("_Perlin");
transform.localScale = Vector3.one;
for (float x = -originalScale.x/2; x < originalScale.x / 2; x++) {
for (float z = -originalScale.z / 2; z < originalScale.z/2; z++) {
//Debug.Log("blah");
Vector3 pos = transform.position;
pos.x += transform.lossyScale.x * x;
pos.z += transform.lossyScale.z * z;
Vector2 texOffset = new Vector2(texScale.x * x, texScale.y * z);
GameObject waterClone = Instantiate(gameObject, pos, transform.rotation, transform);
// waterClone.GetComponent<Renderer>().material.SetTextureOffset("_Diffuse", texOffset);
// waterClone.GetComponent<Renderer>().material.SetTextureOffset("_Normals", texOffset);
// waterClone.GetComponent<Renderer>().material.SetTextureOffset("_Perlin", texOffset);
// waterClone.GetComponent<Renderer>().material.SetTextureOffset("_Perlin_copy", texOffset);
}
}
Debug.Log("blah");
}
}