码迷,mamicode.com
首页 > 编程语言 > 详细

unity自定义菜单面板开发

时间:2016-05-05 22:14:03      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:

using UnityEditor;
using UnityEngine;
using CreateTerrainDLL;

public class CreateTerrainMenu : EditorWindow{

[MenuItem("CreateTerrainMenuItem/CreatTerrain")]
public static void OpenTerrainCreatWindow()
{
EditorWindow.GetWindow(typeof(CreateTerrainMenu));
}

Class1 class1 = new Class1();
CreateTerrainDLL.Security se;

void OnEnable()
{
se = new CreateTerrainDLL.Security();
Debug.Log(se.HardWareCode);
class1.GetMeshEvent += Class1_GetMeshEvent;
}

private void Class1_GetMeshEvent(UnityEngine.Mesh mesh)
{
if (mesh == null)
Debug.Log("mesh is null");
else
Debug.Log("mesh created");

GameObject go = GameObject.Find("DEMTerrain");
if (go != null)
DestroyImmediate(go);
go = new GameObject("DEMTerrain");
go.AddComponent<MeshFilter>();
go.AddComponent<MeshRenderer>();
MeshFilter meshFilter = (MeshFilter)GameObject.Find("DEMTerrain").GetComponent(typeof(MeshFilter));
meshFilter.sharedMesh = mesh;
}

void OnGUI()
{
class1.start();
class1.onGUI();
}
}

unity自定义菜单面板开发

标签:

原文地址:http://www.cnblogs.com/943711466qq/p/5463186.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!