private void OnGUI() { _currentValue.Source = (GameObject)EditorGUILayout.ObjectField("Source", _currentValue.Source, typeof(GameObject), true); if (_currentValue.Source == null) { return; } BindEditorUtility.GetComponent(_currentValue); for (int i = 0; i < _currentValue.MemberInfo.Count; i++) { MemberGUI(i); } GUILayout.BeginHorizontal(); if (GUILayout.Button("+")) { AddMember(); } if (GUILayout.Button("Bind")) { Bind(); } }
internal static void GetComponent(BindValue bindValue) { var types = BindEditorUtility.GetComponentList(bindValue.Source); int selectedIndex = 0; if (bindValue.ComponentType != null) { selectedIndex = types.IndexOf(bindValue.ComponentType.Value); } var index = EditorGUILayout.Popup( selectedIndex == -1 ? 0 : selectedIndex, types.Select(t => t.FrindlyName()).ToArray()); if (bindValue.ComponentType == null) { bindValue.ComponentType = new SType(types[index]); } if (bindValue.ComponentType.Value != types[index]) { bindValue.ComponentType = new SType(types[index]); } }
private void AddMember() { List <MemberInfo> members = BindEditorUtility.NewMembersList(_currentValue); var menu = new GenericMenu(); foreach (var m in members) { menu.AddItem( new GUIContent($"{m.DeclaringType.FrindlyName()}/{m.MemberType}/{m.FrindlyName()}"), false, o => { _currentValue.MemberInfo.Add(new SMemberInfo((MemberInfo)o)); }, m); } menu.ShowAsContext(); }