Created
April 21, 2020 12:26
-
-
Save openroomxyz/263bddba8e2dc1c279e6002906b715d0 to your computer and use it in GitHub Desktop.
Unity : How can we generate material in code?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Vector3 pos = new Vector3(x, y, z); | |
| GameObject cube = GameObject.Instantiate(block, pos, Quaternion.identity); | |
| cube.GetComponent<Renderer>().material = new Material(Shader.Find("Standard")); | |
| cube.GetComponent<Renderer>().material.color = Random.ColorHSV(); | |
| cube.name = x + "_" + y + "_" + z; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment