Exemplo n.º 1
0
        protected void OnFinishedLoadingAssetReference(AsyncOperation operation)
        {
            ResourceRequest request = (ResourceRequest)operation;

            List <string> assetReferences = AssetReferencesQueue[FIRST];
            string        assetReference  = assetReferences[AssetReferencesLoadedCount];

            if (request.asset == null)
            {
                FCgDebug.LogError("FCgManager_Loading.OnFinishedLoadingAssetReference: Failed to load asset at: " + assetReference);
                return;
            }

            LoadedAssets.Add(request.asset);

            int lastCount = AssetReferencesLoadedCount;

            ++AssetReferencesLoadedCount;

            // Get Memory loaded and the time it took
            int   bytes     = (int)Profiler.GetRuntimeMemorySizeLong(request.asset);
            float kilobytes = FCgCommon.BytesToKilobytes(bytes);
            float megabytes = FCgCommon.BytesToMegabytes(bytes);

            ResourceSizeLoaded.Bytes     += bytes;
            ResourceSizeLoaded.Kilobytes += kilobytes;
            ResourceSizeLoaded.Megabytes += megabytes;

            float currentTime = Time.realtimeSinceStartup;
            float loadingTime = currentTime - LoadingStartTime;

            if (LogLoading.Log())
            {
                FCgDebug.Log("FCsManager_Loading.OnFinishedLoadingAssetReference: Finished Loading " + assetReference + ". " + megabytes + " mb (" + kilobytes + " kb, " + bytes + " bytes) in " + loadingTime + " seconds.");
            }

            // Broadcast the event to anyone listening
            AssetReferenceLoadedCache.Reference      = assetReference;
            AssetReferenceLoadedCache.Count          = lastCount;
            AssetReferenceLoadedCache.Size.Bytes     = bytes;
            AssetReferenceLoadedCache.Size.Kilobytes = kilobytes;
            AssetReferenceLoadedCache.Size.Megabytes = megabytes;
            AssetReferenceLoadedCache.Time           = loadingTime;

            OnFinishedLoadingAssetReference_Event.Broadcast(AssetReferenceLoadedCache);
            // FirstToLast, Queue the NEXT Asset for Async Load
            if (AssetReferencesLoadedCount < assetReferences.Capacity)
            {
                if (LogLoading.Log())
                {
                    FCgDebug.Log("FCsManager_Loading.OnFinishedLoadingAssetReference: Requesting Load of " + assetReferences[AssetReferencesLoadedCount]);
                }
                OnStartLoadingAssetReference_Event.Broadcast(assetReferences[AssetReferencesLoadedCount]);

                ResourceRequest r = Resources.LoadAsync(assetReferences[AssetReferencesLoadedCount]);
                r.completed += OnFinishedLoadingAssetReference;
            }
            LoadingStartTime = currentTime;
        }
Exemplo n.º 2
0
        protected void OnFinishedLoadingAssetReference_Bulk(AsyncOperation operation)
        {
            ResourceRequest request = (ResourceRequest)operation;

#if UNITY_EDITOR
            string assetReference = AssetDatabase.GetAssetPath(request.asset);
#endif // #if UNITY_EDITOR

            if (request.asset == null)
            {
#if UNITY_EDITOR
                FCgDebug.LogError("FCgManager_Loading.OnFinishedLoadingAssetReference_Bulk: Failed to load asset at: " + assetReference);
#else
                FCgDebug.LogError("FCgManager_Loading.OnFinishedLoadingAssetReference_Bulk: Failed to load asset");
#endif // #if UNITY_EDITOR
                return;
            }

            LoadedAssets.Add(request.asset);

            int lastCount = AssetReferencesLoadedCount;

            ++AssetReferencesLoadedCount;

            // Get Memory loaded and the time it took
            int   bytes     = (int)Profiler.GetRuntimeMemorySizeLong(request.asset);
            float kilobytes = FCgCommon.BytesToKilobytes(bytes);
            float megabytes = FCgCommon.BytesToMegabytes(bytes);

            ResourceSizeLoaded.Bytes     += bytes;
            ResourceSizeLoaded.Kilobytes += kilobytes;
            ResourceSizeLoaded.Megabytes += megabytes;

            float currentTime = Time.realtimeSinceStartup;
            float loadingTime = currentTime - LoadingStartTime;

            if (LogLoading.Log())
            {
#if UNITY_EDITOR
                FCgDebug.Log("FCsManager_Loading.OnFinishedLoadingAssetReference_Bulk: Finished Loading " + assetReference + ". " + megabytes + " mb (" + kilobytes + " kb, " + bytes + " bytes).");
#else
                FCgDebug.Log("FCsManager_Loading.OnFinishedLoadingAssetReference_Bulk: Finished Loading an asset. " + megabytes + " mb (" + kilobytes + " kb, " + bytes + " bytes).");
#endif // #if UNITY_EDITOR
            }

#if UNITY_EDITOR
            // Broadcast the event to anyone listening
            AssetReferenceLoadedCache.Reference      = assetReference;
            AssetReferenceLoadedCache.Count          = lastCount;
            AssetReferenceLoadedCache.Size.Bytes     = bytes;
            AssetReferenceLoadedCache.Size.Kilobytes = kilobytes;
            AssetReferenceLoadedCache.Size.Megabytes = megabytes;
            AssetReferenceLoadedCache.Time           = loadingTime;

            OnFinishedLoadingAssetReference_Event.Broadcast(AssetReferenceLoadedCache);
#endif // #if UNITY_EDITOR
        }
Exemplo n.º 3
0
 public string ToStr()
 {
     // Number
     if (ValueType == ECgBlockchainContractFunctionReturnType.Number)
     {
         return(FCgCommon.NumericTypeToString(Value));
     }
     // String
     if (ValueType == ECgBlockchainContractFunctionReturnType.String)
     {
         return((string)Value);
     }
     return("");
 }
Exemplo n.º 4
0
 public string ToStr()
 {
     // Number
     if (ValueType == ECgBlockchainCommandArgumentType.Number)
     {
         return(FCgCommon.NumericTypeToString(Value));
     }
     // String
     if (ValueType == ECgBlockchainCommandArgumentType.String)
     {
         return((string)Value);
     }
     // StringString
     if (ValueType == ECgBlockchainCommandArgumentType.StringString)
     {
         return("\"" + (string)Value + "\"");
     }
     return("");
 }
Exemplo n.º 5
0
        public string ToStr()
        {
            // HACKY: For now add ',' to distinguish between the same input arguments in the ABI

            // Number
            if (ValueType == ECgBlockchainContractArgumentType.Number)
            {
                return(FCgCommon.NumericTypeToString(Value) + ",");
            }
            // String
            if (ValueType == ECgBlockchainContractArgumentType.String)
            {
                return((string)Value + ",");
            }
            // StringString
            if (ValueType == ECgBlockchainContractArgumentType.StringString)
            {
                return("'" + (string)Value + "'" + ",");
            }
            return("");
        }