You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
686 B
23 lines
686 B
using UnityEngine; |
|
using UnityEditor; |
|
|
|
public class TreeViewEditor : Editor |
|
{ |
|
[MenuItem("GameObject/UI/TreeView")] |
|
static void CreateTreeView() |
|
{ |
|
GameObject canvas = GameObject.Find("Canvas"); |
|
|
|
if (canvas == null) |
|
{ |
|
EditorUtility.DisplayDialog("提示", "场景中不存在至少一个画布!", "确定"); |
|
return; |
|
} |
|
|
|
GameObject treeView = Instantiate(Resources.Load("TreeView") as GameObject); |
|
treeView.name = "TreeView"; |
|
treeView.transform.SetParent(canvas.transform); |
|
treeView.transform.localPosition = Vector3.zero; |
|
treeView.transform.localScale = Vector3.one; |
|
} |
|
}
|
|
|