|
| 1 | +using UnityEditor; |
| 2 | +using UnityEngine; |
| 3 | +using UnityEngine.UIElements; |
| 4 | +using Banter.SDK; |
| 5 | + |
| 6 | +namespace Banter.SDKEditor |
| 7 | +{ |
| 8 | + [CustomEditor(typeof(BanterAttachedObject))] |
| 9 | + public class BanterAttachedObjectEditor : Editor |
| 10 | + { |
| 11 | + void OnEnable() |
| 12 | + { |
| 13 | + if (target is BanterAttachedObject) |
| 14 | + { |
| 15 | + var script = (BanterAttachedObject)target; |
| 16 | + // script.gameObject.GetComponent<MeshFilter>().hideFlags = HideFlags.HideInInspector; |
| 17 | + var path = AssetDatabase.GetAssetPath(script); |
| 18 | + } |
| 19 | + } |
| 20 | + public override bool UseDefaultMargins() => false; |
| 21 | + public override VisualElement CreateInspectorGUI() |
| 22 | + { |
| 23 | + var script = (BanterAttachedObject)target; |
| 24 | + Editor editor = Editor.CreateEditor(script); |
| 25 | + // script.gameObject.GetComponent<MeshFilter>().hideFlags = HideFlags.HideInInspector; |
| 26 | + VisualElement myInspector = new VisualElement(); |
| 27 | + |
| 28 | + var _mainWindowStyleSheet = Resources.Load<StyleSheet>("BanterCustomInspector"); |
| 29 | + myInspector.styleSheets.Add(_mainWindowStyleSheet); |
| 30 | + |
| 31 | + var title = new Label("PROPERTIES SEEN BY JS"); |
| 32 | + title.style.fontSize = 14; |
| 33 | + myInspector.Add(title); |
| 34 | + var seeFields = new Label("uid, attachmentPosition, attachmentRotation, attachmentType, avatarAttachmentType, avatarAttachmentPoint, attachmentPoint, autoSync, jointAvatar, "); |
| 35 | + seeFields.style.unityFontStyleAndWeight = FontStyle.Bold; |
| 36 | + seeFields.style.flexWrap = Wrap.Wrap; |
| 37 | + seeFields.style.whiteSpace = WhiteSpace.Normal; |
| 38 | + seeFields.style.marginBottom = 10; |
| 39 | + seeFields.style.marginTop = 10; |
| 40 | + seeFields.style.color = Color.gray; |
| 41 | + myInspector.Add(seeFields); |
| 42 | + |
| 43 | + //#if BANTER_EDITOR |
| 44 | + var foldout = new Foldout(); |
| 45 | + foldout.text = "Available Properties"; |
| 46 | + IMGUIContainer inspectorIMGUI = new IMGUIContainer(() => { editor.OnInspectorGUI(); }); |
| 47 | + foldout.value = false; |
| 48 | + foldout.Add(inspectorIMGUI); |
| 49 | + myInspector.Add(foldout); |
| 50 | + //#endif |
| 51 | + |
| 52 | + return myInspector; |
| 53 | + } |
| 54 | + } |
| 55 | +} |
0 commit comments