Exemplo n.º 1
0
        public static void ShowComponentProperties <T>(T component)
            where T : IComponent
        {
            var componentProperties = component.GetType().GetProperties();

            foreach (var property in componentProperties)
            {
                EditorGUILayout.BeginHorizontal();
                var propertyType  = property.PropertyType;
                var propertyValue = property.GetValue(component, null);

                var handler = DefaultEditorInputRegistry.GetHandlerFor(propertyType);
                if (handler == null)
                {
                    Debug.LogWarning("This type is not supported: " + propertyType.Name + " - In component: " + component.GetType().Name);
                    continue;
                }

                var updatedValue = handler.CreateUI(property.Name, propertyValue);

                if (updatedValue != null)
                {
                    property.SetValue(component, updatedValue, null);
                }

                EditorGUILayout.EndHorizontal();
            }
        }
Exemplo n.º 2
0
    private static void DrawComponent(GameObject gameObject, IComponent component)
    {
        var componentProperties = component.FieldInfos;

        foreach (var property in componentProperties)
        {
            var propertyType = property.FieldType;

            var handler = DefaultEditorInputRegistry.GetHandlerFor(propertyType);

            if (handler == null)
            {
                Debug.LogWarning("This type is not supported: " + propertyType.Name + " - In component: " +
                                 component.Type.Name);
                continue;
            }

            EditorGUILayout.BeginHorizontal();
            handler.DrawComponentElementUI(gameObject, component, property);
            EditorGUILayout.EndHorizontal();
        }
    }