您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
31 行
663 B
31 行
663 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class VegetationSystem : MonoBehaviour {
|
|
|
|
MaterialPropertyBlock props;
|
|
|
|
void Start()
|
|
{
|
|
props = new MaterialPropertyBlock();
|
|
SetProperties(transform);
|
|
}
|
|
|
|
void SetProperties(Transform t)
|
|
{
|
|
MeshRenderer rend;
|
|
foreach (Transform child in t)
|
|
{
|
|
rend = child.gameObject.GetComponent<MeshRenderer>();
|
|
if (rend)
|
|
{
|
|
props.SetVector("_Position", child.position);
|
|
rend.SetPropertyBlock(props);
|
|
}
|
|
if(child.childCount > 0)
|
|
SetProperties(child);
|
|
}
|
|
}
|
|
|
|
}
|