static string GetSampleMaterialsPath(ProceduralTree tree) { if (string.IsNullOrEmpty(pathSampleMaterials)) { // Get materials folder pathSampleMaterials = AssetDatabase.GetAssetPath(MonoScript.FromMonoBehaviour(tree)); pathSampleMaterials = System.IO.Path.GetDirectoryName(pathSampleMaterials) + "/SampleMaterials/"; } return(pathSampleMaterials); }
// Use this for initialization void Start() { foreach (Transform child in transform.parent.transform.parent.transform) // in [imageTarget] { if (child.tag == "Tree") { treeScript = child.GetComponent <Wasabimole.ProceduralTree.ProceduralTree>(); treeMaterial = child.GetComponent <Renderer>().sharedMaterial; } } // treeMaterial = GameObject.FindGameObjectWithTag("Tree").GetComponent<Renderer>().sharedMaterial; }
static void GetSampleMaterial(ProceduralTree tree) { // Get sample materials string[] sampleMaterials = System.IO.Directory.GetFiles(GetSampleMaterialsPath(tree), "*.mat", System.IO.SearchOption.AllDirectories); // Return if none found if (sampleMaterials.Length < 1) { return; } // Assign a random sample material tree.Renderer.sharedMaterial = AssetDatabase.LoadAssetAtPath(sampleMaterials[Random.Range(0, sampleMaterials.Length)], typeof(Material)) as Material; }
static string GetSampleMaterialsPath(ProceduralTree tree) { if (string.IsNullOrEmpty(pathSampleMaterials)) { // Get materials folder pathSampleMaterials = AssetDatabase.GetAssetPath(MonoScript.FromMonoBehaviour(tree)); pathSampleMaterials = System.IO.Path.GetDirectoryName(pathSampleMaterials) + "/SampleMaterials/"; } return pathSampleMaterials; }
static void GetSampleMaterial(ProceduralTree tree) { // Get sample materials string[] sampleMaterials = System.IO.Directory.GetFiles(GetSampleMaterialsPath(tree), "*.mat", System.IO.SearchOption.AllDirectories); // Return if none found if (sampleMaterials.Length < 1) return; // Assign a random sample material tree.Renderer.sharedMaterial = AssetDatabase.LoadAssetAtPath(sampleMaterials[Random.Range(0, sampleMaterials.Length)], typeof(Material)) as Material; }
// Use this for initialization void Start() { tree = GetComponent <Wasabimole.ProceduralTree.ProceduralTree>(); cam = Camera.main.transform; }
// Use this for initialization void Start() { tree = treeObject.GetComponent <Wasabimole.ProceduralTree.ProceduralTree>(); audioSource = GetComponent <AudioSource>(); }