Ejemplo n.º 1
0
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
        public static Boolean Loadable(Enum index)
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
        {
            if (AssetsCore.assetAssociations.TryGetValue(index.GetType(), out Type assetType))
            {
                return(AssetsCore.ReflectedCanLoadAsset(assetType, index));
            }
            throw new ArgumentException("Invalid index type");
        }
Ejemplo n.º 2
0
        internal Boolean CanLoad()
        {
            Boolean val = true;

            for (Int32 i = 0; i < this.dependencies.Length; ++i)
            {
                val &= AssetsCore.Loadable(this.dependencies[i]);
            }
            return(val);
        }
Ejemplo n.º 3
0
        internal static Boolean CanGetAsset(Enum index)
        {
            if (!AssetsCore.MatchAssetIndexType(typeof(TAsset), index.GetType()))
            {
                throw new ArgumentException("Incorrect index type", nameof(index));
            }

            UInt64 ind = index.GetValue <UInt64>();

            return(assets[ind].CanLoad());
        }
Ejemplo n.º 4
0
        internal AssetAccessor(Enum index, AssetAccessDelegate <TAsset> del, params Enum[] dependencies)
        {
            if (!AssetsCore.MatchAssetIndexType(typeof(TAsset), index.GetType()))
            {
                throw new ArgumentException("Incorrect index type");
            }

            this.index          = index;
            this.accessDelegate = del;
            this.dependencies   = dependencies;
        }
Ejemplo n.º 5
0
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
        public static Boolean CanLoadAsset <TAsset>(Enum index) where TAsset : UnityEngine.Object
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
        {
            if (!AssetsCore.loaded)
            {
                throw new CoreNotLoadedException(nameof(AssetsCore));
            }
            if (!AssetsCore.MatchAssetIndexType(typeof(TAsset), index.GetType()))
            {
                throw new ArgumentException("Incorrect index type", "index");
            }
            return(AssetLibrary <TAsset> .CanGetAsset(index));
        }
Ejemplo n.º 6
0
        internal static TAsset GetAsset(Enum index)
        {
            if (!AssetsCore.MatchAssetIndexType(typeof(TAsset), index.GetType()))
            {
                throw new ArgumentException("Incorrect index type.", nameof(index));
            }

            UInt64 ind = index.GetValue <UInt64>();

            if (assets.TryGetValue(ind, out AssetAccessor <TAsset> asset))
            {
                return(asset.value);
            }
            else
            {
                throw new KeyNotFoundException(String.Format("The Key:{0} was not found.", index.GetName()));
            }
        }
Ejemplo n.º 7
0
        public static TAsset LoadAsset <TAsset>(Enum index) where TAsset : UnityEngine.Object
        {
            //var timer = new Stopwatch();
            //timer.Start();

            if (!AssetsCore.loaded)
            {
                throw new CoreNotLoadedException(nameof(AssetsCore));
            }
            if (!AssetsCore.MatchAssetIndexType(typeof(TAsset), index.GetType()))
            {
                throw new ArgumentException("Incorrect index type", nameof(index));
            }

            TAsset asset = AssetLibrary <TAsset> .GetAsset(index);

            //timer.Stop();
            //Log.Warning( String.Format( "Time for asset {0}: {1} ticks, {2} ms", index.GetName(), timer.ElapsedTicks, timer.ElapsedMilliseconds ) );
            return(asset);
        }