示例#1
0
 public LevelEditorPropertyData(ExposedProperty property, IExposedToLevelEditor exposedComponent)
 {
     id    = property.ID;
     value = exposedComponent?.GetValue(property.ID);
     // Used for Unity references. They need to be converted to a simple component.
     type = property.Type;
     if (property is ExposedArray array)
     {
         if (array.ElementType.IsSubclassOf(typeof(Component)))
         {
             if (type.IsGenericType && (type.GetGenericTypeDefinition() == typeof(List <>)))
             {
                 //type = typeof(List<>).MakeGenericType(typeof(Component));
                 throw new NotSupportedException($"List<{array.ElementType}> is not supported. For collection of Unity objects, use array instead.");
             }
             else
             {
                 type = typeof(Component).MakeArrayType();
             }
         }
     }
     else
     {
         // type = property.Type.IsSubclassOf(typeof(Component)) ? typeof(Component) : property.Type;
         type = ComponentDataWrapper.IsComponent(property.Type) ? typeof(ComponentDataWrapper) : property.Type;
     }
     typeName = type.FullName;
 }
示例#2
0
        protected LevelEditorInspectorField GetField <T>(ExposedProperty property, string label)
        {
            LevelEditorInspectorField field = GetField <T>(property);

            field.Label = label;

            return(field);
        }
示例#3
0
        protected LevelEditorInspectorField GetField <T>(ExposedProperty property)
        {
            if (TryGetField <T>(property, out LevelEditorInspectorField field))
            {
                return(field);
            }

            throw new ArgumentException($"There's no InspectorField that supports type '{typeof(T).FullName}'.");
        }
示例#4
0
 protected bool TryGetField <T>(ExposedProperty property, string label, out LevelEditorInspectorField field)
 {
     if (TryGetField <T>(property, out field))
     {
         field.Label = label;
         return(true);
     }
     else
     {
         return(false);
     }
 }
 public virtual bool SupportsType(ExposedProperty property)
 {
     //TODO: Support arrays
     return(SupportsType(property.Type, property.Type.IsArray));
 }
示例#6
0
 protected bool TryAddField <T>(ExposedProperty property, string label)
 {
     return(TryGetField <T>(property, label, out _));
 }
示例#7
0
 protected bool TryAddField <T>(ExposedProperty property)
 {
     return(TryGetField <T>(property, out _));
 }
示例#8
0
 protected void AddField <T>(ExposedProperty property, string label)
 {
     GetField <T>(property, label);
 }
示例#9
0
 protected void AddField <T>(ExposedProperty property)
 {
     GetField <T>(property);
 }