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; }
private void SetParent(ComponentDataWrapper wrapper) { if (wrapper.TryGetObject(out ILevelEditorObject parent)) { Target.SetParent(parent.MyGameObject.transform); LevelEditorObject.Parent = parent; parent.AddChild(LevelEditorObject); } else { Target.SetParent(null); } lastEditValue = new ComponentDataWrapper(transform.parent); }
public Wrapper(Vector3 position, Vector3 rotation, Vector3 scale, ComponentDataWrapper parent, bool isDirty) { Values = new Dictionary <int, object>(4) { { POSITION_ID, position }, { ROTATION_ID, rotation }, { SCALE_ID, scale }, { PARENT_ID, parent }, }; Dirty = new Dictionary <int, bool>(4) { { POSITION_ID, isDirty }, { ROTATION_ID, isDirty }, { SCALE_ID, isDirty }, { PARENT_ID, isDirty } }; }