Esempio n. 1
0
        /// <summary>
        /// Called when [selected type name].
        /// </summary>
        /// <param name="userData">The user data.</param>
        private static void OnSelectedTypeName(object userData)
        {
            var selectedType = userData as Type;

            s_SelectedClassRef = ClassTypeReference.GetClassRef(selectedType);
            var typeReferenceUpdatedEvent = EditorGUIUtility.CommandEvent("TypeReferenceUpdated");

            EditorWindow.focusedWindow.SendEvent(typeReferenceUpdatedEvent);
        }
Esempio n. 2
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        EditorGUI.BeginProperty(position, label, property);
        position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
        // Don't make child fields be indented
        var indent = EditorGUI.indentLevel;

        EditorGUI.indentLevel = 0;

        Rect main = new Rect(position.x, position.y, position.width, position.height);


        ClassTypeParentAttribute attr = null;

        object[] attributes = fieldInfo.GetCustomAttributes(typeof(ClassTypeParentAttribute), false);
        if (attributes.Length > 0)
        {
            attr = (ClassTypeParentAttribute)attributes.First();

            List <Type> types = new List <Type>();
            PopulateEntries(attr);
            int index = GetIndexOfType(property);

            int newIndex = EditorGUI.Popup(main, index, entries.ToArray());

            if (index != newIndex)
            {
                Type t = tEntries[newIndex];
                property.FindPropertyRelative("_classRef").stringValue = ClassTypeReference.GetClassRef(t);
            }
        }
        else
        {
            EditorGUI.LabelField(main, "Please use ClassTypeParentAttribute");
        }



        // Set indent back to what it was
        EditorGUI.indentLevel = indent;

        EditorGUI.EndProperty();
    }