/// <summary> /// Setup constructor /// </summary> /// <param name="parameters">Load parameters</param> /// <param name="errors">Error collection</param> /// <param name="reader">XML reader positioned at the element that created this builder</param> /// <param name="parentBuilder">Parent builder</param> public AssetBuilder( ComponentLoadParameters parameters, ErrorCollection errors, XmlReader reader, BaseBuilder parentBuilder ) : base(parameters, errors, reader, parentBuilder) { string assetPath = reader.GetAttribute( "path" ); string instance = reader.GetAttribute( "instance" ); m_Instance = string.IsNullOrEmpty( instance ) ? false : bool.Parse( instance ); m_Loader = AssetManager.Instance.CreateLoadState( Locations.NewLocation( assetPath ), null ); string useCurrentParams = reader.GetAttribute( "useCurrentParameters" ); if ( useCurrentParams != null ) { if ( bool.Parse( useCurrentParams ) ) { m_Loader.Parameters = Parameters; } } }
/// <summary> /// Loads an asset at a given location, with specified parameters /// </summary> /// <param name="source">Asset source</param> /// <param name="parameters">Loading parameters</param> /// <returns>Returns the loaded asset</returns> public object Load( ISource source, LoadParameters parameters ) { if ( source == null ) { throw new ArgumentNullException( "source", "Asset source was null - check that location exists" ); } foreach ( IAssetLoader loader in m_Loaders ) { if ( loader.CanLoad( source ) ) { LoadState loadState = new LoadState( loader, source, parameters ); return loadState.Load( ); } } throw new ArgumentException( string.Format( "No loader could load asset \"{0}\"", source ) ); }