Documentation ¶
Index ¶
- func ChildOverridesField(child Asset, pathToField string) bool
- func FilterFilesByReflectType(typ reflect.Type) ([]string, error)
- func FilterFilesByType[T any]() ([]string, error)
- func GetFlatTag(sf *reflect.StructField, key string) (value string, exists bool)
- func New[T any]() *T
- func ObjectTypeName(obj any) (name string, fullname string)
- func ReadFile(assetPath Path) ([]byte, error)
- func RegisterAsset(zeroAsset any)
- func RegisterAssetFactory(zeroAsset any, factoryFunction FactoryFunc)
- func RegisterFileSystem(filesystem fs.FS, priority int) error
- func RegisterWritableFileSystem(filesystem WriteableFileSystem) error
- func ResetForTest()
- func Save(path Path, toSave Asset) error
- func SetChildOverrideForField(child Asset, pathToField string, enable OverrideEnableType) error
- func SetEditorMode()
- func SetParent(child Asset, parent Asset) error
- func TypeName(t reflect.Type) (name string, fullname string)
- func WalkFiles(fn fs.WalkDirFunc) error
- type Asset
- type AssetDescriptor
- type DefaultInitializer
- type FactoryFunc
- type LoadOptions
- type NamedAsset
- type OverrideEnableType
- type Path
- type PostLoadingAsset
- type PreSavingAsset
- type WriteableFileSystem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChildOverridesField ¶
func FilterFilesByType ¶
func GetFlatTag ¶
func GetFlatTag(sf *reflect.StructField, key string) (value string, exists bool)
func New ¶
func New[T any]() *T
Create a new T and ensure that T and all it's public fields have their DefaultInitializers called.
func ObjectTypeName ¶
func RegisterAsset ¶
func RegisterAsset(zeroAsset any)
func RegisterAssetFactory ¶
func RegisterAssetFactory(zeroAsset any, factoryFunction FactoryFunc)
func RegisterWritableFileSystem ¶
func RegisterWritableFileSystem(filesystem WriteableFileSystem) error
func ResetForTest ¶
func ResetForTest()
func SetChildOverrideForField ¶
func SetChildOverrideForField(child Asset, pathToField string, enable OverrideEnableType) error
func SetEditorMode ¶
func SetEditorMode()
SetEditorMode informs the asset package that it is being used in an editor context. For example when enabled extra meta data about which fields a child asset overrides must be saved.
func SetParent ¶
SetParent is used to set the parent of an Asset. When an Asset is reparented, all values that are not overridden by the child are copied in from the parent. If there is no previous parent then the parent and the child are diffed and in places where they differ the child will override the parent.
func WalkFiles ¶
func WalkFiles(fn fs.WalkDirFunc) error
WalkFiles is like fs.WalkDir, but it will walk all the readable file systems registered with asset.RegisterFileSystem
Types ¶
type Asset ¶
type Asset interface{}
Asset can be any type.
func GetParentAsset ¶
func LoadWithOptions ¶
func LoadWithOptions(assetPath Path, options LoadOptions) (Asset, error)
func NewInstance ¶
type AssetDescriptor ¶
type AssetDescriptor struct { Name string FullName string Create FactoryFunc Type reflect.Type }
func FilterAssetDescriptorsByReflectType ¶
func FilterAssetDescriptorsByReflectType(typ reflect.Type) []*AssetDescriptor
func FilterAssetDescriptorsByType ¶
func FilterAssetDescriptorsByType[T any]() []*AssetDescriptor
func GetAssetDescriptors ¶
func GetAssetDescriptors() []*AssetDescriptor
func GetDescriptorForAsset ¶
func GetDescriptorForAsset(asset Asset) *AssetDescriptor
type DefaultInitializer ¶
type DefaultInitializer interface {
DefaultInitialize()
}
Any type that implements DefaultInitializer will have DefaultInitialize called when assets are created. Types do not need to be assets for this to work.
type FactoryFunc ¶
type LoadOptions ¶
type LoadOptions struct { // ForceReload will reload the asset from disk. If the asset already // exists in memory that same object will be reused. ForceReload bool // contains filtered or unexported fields }
type NamedAsset ¶
type NamedAsset interface {
Name() string
}
NamedAsset allows assets to provide a different Name The editor will use this Name instead of the struct name
type OverrideEnableType ¶
type OverrideEnableType uint8
const ( OverrideEnable OverrideEnableType = iota OverrideDisable )
type Path ¶
type Path string
Path is a distinct type from string so that the editor package can present an autocomplete window. The editor also understands the `filter` tag when used with Path, for example
struct { P Path `filter:"png,jpg"` }
will only show files that contain the text 'png' or 'jpg'
func GetLoadPathForAsset ¶
type PostLoadingAsset ¶
type PostLoadingAsset interface {
PostLoad()
}
type PreSavingAsset ¶
type PreSavingAsset interface {
PreSave()
}
type WriteableFileSystem ¶
func NewWritableFS ¶
func NewWritableFS(basepath Path) WriteableFileSystem