日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Unity3D研究院之Editor下监听Transform变化

發布時間:2025/7/14 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Unity3D研究院之Editor下监听Transform变化 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

美術有可以直接在Editor下操作Transform,我想去修正他們編輯的數值,所以我就得監聽Transform。

?

C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 using UnityEngine; using System.Collections; using UnityEditor; using System.Reflection; [CustomEditor(typeof(Transform))] public class TransformEditor :Editor { [InitializeOnLoadMethod] static void IInitializeOnLoadMethod() { TransformEditor.onPostion =delegate(Transform transform) { Debug.Log(string.Format("transform = {0}??positon = {1}",transform.name,transform.localPosition)); }; TransformEditor.onRotation =delegate(Transform transform) { Debug.Log(string.Format("transform = {0}?? rotation = {1}",transform.name,transform.localRotation.eulerAngles)); }; TransformEditor.onScale =delegate(Transform transform) { Debug.Log(string.Format("transform = {0}?? scale = {1}",transform.name,transform.localScale)); }; } public delegate void Change(Transform transform); static public Change onPostion; static public Change onRotation; static public Change onScale; private Editor editor; private Transform transform; private Vector3 startPostion =Vector3.zero; private Vector3 startRotation =Vector3.zero; private Vector3 startScale =Vector3.zero; void OnEnable() { transform = target as Transform; editor = Editor.CreateEditor(target, Assembly.GetAssembly(typeof(Editor)).GetType("UnityEditor.TransformInspector",true)); startPostion = transform.localPosition; startRotation = transform.localRotation.eulerAngles; startScale = transform.localScale; } public override void OnInspectorGUI () { editor.OnInspectorGUI(); if(GUI.changed) { if(startPostion != transform.localPosition) { if(onPostion != null) onPostion(transform); } if(startRotation !=??transform.localRotation.eulerAngles) { if(onRotation != null) onRotation(transform); } if(startScale !=??transform.localScale) { if(onScale != null) onScale(transform); } startPostion = transform.localPosition; startRotation = transform.localRotation.eulerAngles; startScale = transform.localScale; } } }

?

  • 本文固定鏈接: http://www.xuanyusong.com/archives/4018
  • 轉載請注明: 雨松MOMO 2016年04月20日 于 雨松MOMO程序研究院 發表

轉載于:https://www.cnblogs.com/android-blogs/p/6088039.html

總結

以上是生活随笔為你收集整理的Unity3D研究院之Editor下监听Transform变化的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。