Unity PCG: 功能开发之【Scatter】
测试工具代码。
using UnityEngine; using UnityEditor; using GLight; public class TestFunctionButton : EditorWindow { private float float_value; private int int_value; void OnGUI() { // 在这里绘制GUI界面 GUILayout.Label("Test Function Function", EditorStyles.boldLabel); int_value = EditorGUILayout.IntSlider("Scatter Count", int_value, 0, 10); float_value = EditorGUILayout.Slider("Seed",float_value, 0, 100000); if (GUILayout.Button("Test Function")) { Scatter scatter = new Scatter(); scatter.Execute(Selection.activeGameObject, int_value, Mathf.FloorToInt(float_value)); for (int i = 0; i < scatter.points.Count; i++) { InstancePoint instancePoint = new InstancePoint(scatter.points[i].position, scatter.points[i].orient, new Vector3(1,1,1)); instancePoint.guid = AssetDatabase.AssetPathToGUID("Assets/Art/Darth_Artisan/Free_Trees/Prefabs/Poplar_Tree.prefab"); //树的资产 GameObject GO = (GameObject)PrefabUtility.InstantiatePrefab((Object)AssetDatabase.LoadAssetAtPath<GameObject>(AssetDatabase.GUIDToAssetPath(instancePoint.guid))); GO.transform.localPosition = instancePoint.position; GO.transform.localRotation = instancePoint.orient; GO.transform.localScale = instancePoint.scale; } } } [MenuItem("GLight Tools/Test Function Function")] static void Init() { TestFunctionButton window = (TestFunctionButton)GetWindow(typeof(TestFunctionButton)); window.Show(); } }
- 感谢你赐予我前进的力量
赞赏者名单
因为你们的支持让我意识到写文章的价值🙏
本文是原创文章,采用 CC BY-NC-ND 4.0协议,完整转载请注明来自 零度冰山
评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果
