void Start() { //NB: this will throw null reference if GameInspectorManager is not in the scene. manager = GameObject.Find("/GameInspectorManager").GetComponent <GameInspectorManager>(); foreach (var component in gameObject.GetComponents <Component> ()) { var fields = component.GetType().GetFields(); foreach (var info in fields) { var attributes = info.GetCustomAttributes(true); foreach (var a in attributes) { if (a.GetType() == typeof(InspectableAttribute)) { descriptors.Add(new Descriptor(component, info, a as InspectableAttribute)); } } } } //sort the Inspectable values using the rank value. descriptors.Sort(delegate(Descriptor A, Descriptor B) { if (A.attr.rank == B.attr.rank) { return(0); } return(A.attr.rank < B.attr.rank ? -1 : 1); }); }
void Update() { if (alwaysTitle.Length > 0) { if (manager == null) { manager = gameObject.AddComponent <GameInspectorManager>(); } manager.windowTitle = alwaysTitle; manager.followMouse = false; manager.bound = bound; manager.Show(this); } else { if (manager != null) { manager.Hide(this); } } }
void Start() { //NB: this will throw null reference if GameInspectorManager is not in the scene. manager = GameObject.Find("/GameInspectorManager").GetComponent<GameInspectorManager>(); foreach (var component in gameObject.GetComponents<Component> ()) { var fields = component.GetType ().GetFields (); foreach (var info in fields) { var attributes = info.GetCustomAttributes (true); foreach (var a in attributes) { if (a.GetType () == typeof(InspectableAttribute)) { descriptors.Add (new Descriptor (component, info, a as InspectableAttribute)); } } } } //sort the Inspectable values using the rank value. descriptors.Sort (delegate(Descriptor A, Descriptor B) { if (A.attr.rank == B.attr.rank) return 0; return A.attr.rank < B.attr.rank ? -1 : 1; }); }
void Start() { if (Platform.isEditor) { GameObject managerObj = GameObject.Find("/InspectorManager"); if (managerObj == null) { managerObj = new GameObject("InspectorManager"); sharedManager = managerObj.AddComponent <GameInspectorManager>(); GameObject.DontDestroyOnLoad(managerObj); } else { sharedManager = managerObj.GetComponent <GameInspectorManager>(); } AddDescriptors(descriptors); } else { Debug.LogWarning("Remove Inspector"); Destroy(this); } }