Unity3D 扩展 Scene
来源:互联网 发布:淘宝投诉盗版书 编辑:程序博客网 时间:2024/06/11 09:23
[CustomEditor(typeof(Test))]
// 可以做成,直接把Prefab拖到场景中,自动合并,
// 获得是,地点选择,就合并到那个中
public class TestEditor : Editor {
void InitStyle()
{
_boneNameStyle.normal.textColor = Color.red;
_windowTextStyle.fontSize = 15;
_windowTextStyle.normal.textColor = Color.white;
}
//[DrawGizmo(GizmoType.NotInSelectionHierarchy)]
//static void DrawGameObjectName(Transform transform, GizmoType gizmoType)
//{
// //Gizmos.DrawWireSphere(transform.position, 2);
// if (_curSelectBone != null)
// {
// Gizmos.color = Color.red;
// Gizmos.DrawSphere(_curSelectBone.transform.position, 0.6f);
// }
//}
void OnSceneGUI()
{
Test test = target as Test;
InitStyle();
// 显示文字
//Handles.Label(test.transform.position, test.transform.gameObject.name, style);
// 显示按钮
//if (Handles.Button(test.transform.position, Quaternion.identity, 0.5f, 0.5f, Handles.SphereCap)) {
// Debug.Log("aaaaa");
//}
// 显示全部的骨骼的信息
Transform[] bones = test.transform.Find("Bip001").GetComponentsInChildren<Transform>();
for (int index = 0; index < bones.Length; index++)
{
Transform b = bones[index];
if( _curSelectBone != null && b == _curSelectBone.transform) Handles.color = Color.yellow;
else Handles.color = Color.white;
// 点击一个骨骼,就弹出一个界面,让用户进行选择
if (Handles.Button(b.transform.position, Quaternion.identity, 0.5f, 0.5f, Handles.SphereCap))
{
Debug.Log(b.name);
//标记哪一个被点中, 给出提示,一个红点
_curSelectBone = b.gameObject;
}
Handles.Label(b.transform.position, b.transform.gameObject.name, _boneNameStyle);
}
// 检测是否有东西拖到Scene中
if (Event.current.type == EventType.DragPerform){
Debug.Log("Good");
DragAndDrop.AcceptDrag();
foreach (Object obj in DragAndDrop.objectReferences)
{
string file = AssetDatabase.GetAssetPath(obj);
Debug.LogFormat(" ** {0}", file);
}
//可以获得Drop的对象,但是是topLevel的
/*
Debug.Log(Selection.activeObject.name);
*/
//Event.current.Use();
}
// 显示具体的消息
Handles.BeginGUI();
_windowRect = GUILayout.Window(0, _windowRect, MergeInfoWindow, "Merge Bone Info");
Handles.EndGUI();
}
void MergeInfoWindow(int windowID)
{
//EditorGUILayout.BeginVertical();
GUILayout.Label(" ** 具体信息 ** ", _windowTextStyle);
string selectStr = "";
if (_curSelectBone != null){
selectStr = string.Format("选中了 {0} ", _curSelectBone.name);
}
GUILayout.Label(selectStr, _windowTextStyle);
//EditorGUILayout.EndVertical();
}
GUIStyle _boneNameStyle = new GUIStyle();
GUIStyle _windowTextStyle = new GUIStyle();
Rect _windowRect = new Rect(20, 20, 120, 20);
GameObject _curSelectBone = null;
}
- Unity3D 扩展 Scene
- Unity3D场景管理插件Scene Manager
- Unity3D说明文档翻译-Scene View Navigation
- scene
- Scene
- Unity3D编辑器的结构介绍之Scene视图
- Unity3D开发(三):场景管理插件Scene Manager
- Calling a web-service from a Unity3D scene
- Unity3D之在Scene窗口显示Waypoint路径
- unity3d之Assetbundle打包预设Prefab和场景Scene
- Unity3D说明文档翻译-The Scene View Window
- Unity3D说明文档翻译-Scene View Control Bar
- Unity3D 自定义 Editor 扩展
- Unity3D-C#扩展方法
- unity3d扩展编辑器
- Unity3d 编辑器扩展
- Unity3D-扩展编辑器
- Unity3D StateMachine扩展优化
- 网络链路层
- leetcode 76:Minimum Window Substring
- 数据结构——查找和删除指定连接点(java实现)
- Android学习系列(1)--为App签名(为apk签名)
- WebX Q&A
- Unity3D 扩展 Scene
- android事件处理机制
- 基本数据类型与引用数据类型
- Android Paint和Canvas常用方法和效果
- 这个月小结
- 南大软院大神养成计划——第十一天
- Go struct
- 自定义标题栏
- linux应用编程笔记(13)信号量同步编程