- Home /
Answered the Question with help of a Friend :)
Change Water via Script?
Hi there
I added the Nighttime Water to my Scene, and manipulated the XYZ/Wind WaveSpeed values. Now, in a different scene, i need other valuas.. but changing them back is changing back the values on the other scene too..
Like all water in the complete game is linked together..
So now my question:
How can i change the values of the water via script, to edit them within each scene?
Like:
using UnityEngine;
using System.Collections;
public class Scene_SetupScript : MonoBehaviour {
public GameObject Water;
public Vector4 Waterspeeds;
// Use this for initialization
void Start () {
if(Water != null){
}
}
}
?
What variables you want to change. In you code you can change in Start() funciton at start time one time, if you want to change not one time you must use void Update() { } function , !
okay.. i think you didn´t get it.. I want to change variables of a Shader.
This one helps.. so.. it´s solved:
go.renderer.material.SetVector("WaveSpeed", new Vector4(x1,y1,x2,y2));
Is there a way to use this code without it instantiating a new material? I just want to change the values of the existing material. $$anonymous$$anually changing the vector in the editor(at runtime) does exactly what I want, but this script causes the main texture to stop scrolling entirely, and leaves only the bump map scrolling. Ideas?
Follow this Question
Related Questions
I've lost the water shader [FX/ water (Simple)] 1 Answer
Shader not found in my application after build 1 Answer
On Collision with water buoyancy and play Swim animation 1 Answer
Low Poly Water 4 Answers
How can I make subnautica style water? 0 Answers