void OnGUI() { targetGo = (GameObject)EditorGUILayout.ObjectField(targetGo, typeof(GameObject), true); subPath = targetGo == null ? subPath : targetGo.name; EditorGUILayout.LabelField(string.Format("保存路径output path:{0}", Path.Combine(path, subPath))); //获得一个长300的框 Rect rect = EditorGUILayout.GetControlRect(GUILayout.Width(400)); //将上面的框作为文本输入框 path = EditorGUI.TextField(rect, path); subPath = EditorGUILayout.TextField(subPath); //如果鼠标正在拖拽中或拖拽结束时,并且鼠标所在位置在文本输入框内 if ((Event.current.type == EventType.DragUpdated || Event.current.type == EventType.DragExited) && rect.Contains(Event.current.mousePosition)) { //改变鼠标的外表 DragAndDrop.visualMode = DragAndDropVisualMode.Generic; if (DragAndDrop.paths != null && DragAndDrop.paths.Length > 0) { path = DragAndDrop.paths[0]; } } stratege = (SaveStrategy)EditorGUILayout.EnumPopup("保存策略output type:", stratege); if (stratege == SaveStrategy.Prefab || stratege == SaveStrategy.Mat) { targetMat = (Material)EditorGUILayout.ObjectField(targetMat, typeof(Material), true); } if (GUILayout.Button("Bake")) { if (targetGo == null) { EditorUtility.DisplayDialog("err", "targetGo is null, 请填第一个空!", "OK"); return; } if (baker == null) { baker = new AnimMapBaker(); } baker.SetAnimData(targetGo); List <BakedData> list = baker.Bake(); if (list != null) { for (int i = 0; i < list.Count; i++) { BakedData data = list[i]; Save(ref data); } } } }
public static void ShowWindow() { EditorWindow.GetWindow(typeof(AnimMapBakerWindow)); baker = new AnimMapBaker(); animMapShader = Shader.Find("capstone/AnimMapShader"); }