private static string PropertiesPopup(Rect rect, object target, string memberName, Type propertyType, GUIContent content, OSCReflectionAccess access) { var members = OSCReflection.GetMembersByType(target, propertyType, access, OSCReflectionType.All); var clearName = new List <GUIContent>(); var currentIndex = 0; // GET INDEX foreach (var member in members) { if (member.Name == memberName) { currentIndex = clearName.Count; } clearName.Add(new GUIContent(OSCEditorUtils.MemberName(member))); } if (clearName.Count == 0) { clearName.Add(new GUIContent("- None -")); } currentIndex = EditorGUI.Popup(rect, content, currentIndex, clearName.ToArray()); currentIndex = Mathf.Clamp(currentIndex, 0, clearName.Count - 1); return(members.Length > 0 ? members[currentIndex].Name : "- None -"); }
private void RecacheMember() { // Check is we have target. var targetObject = _targetProperty.objectReferenceValue; if (targetObject == null) { return; } _members = OSCReflection.GetMembersByType(targetObject, _memberType, _reflectionAccess, _reflectionType); // Stop method is we do not have any members. var membersLength = _members.Length; if (membersLength == 0) { return; } _membersNames = new GUIContent[membersLength + 1]; _membersNames[0] = _memberNoneContent; // Creating member names. for (var i = 0; i < membersLength; i++) { var member = _members[i]; var content = new GUIContent(); if (OnMemberName != null) { content.text = OnMemberName.Invoke(member); } else { content.text = OSCEditorUtils.MemberName(member); } _membersNames[i + 1] = content; } }