Exemplo n.º 1
0
 private void OnDisable()
 {
     if (lightingRig != null)
     {
         IconRenderLightingRig.Release();
     }
 }
 public static void Release()
 {
     if (--refCount <= 0 && instance != null)
     {
         instance.cancelLoading = true;
         instance.destroy();
         instance = null;
     }
 }
 public static IconRenderLightingRig Acquire()
 {
     if (instance == null || instance.lightingRig == null)
     {
         instance = new IconRenderLightingRig();
     }
     instance.cancelLoading = false;
     refCount++;
     return(instance);
 }
        private IEnumerator loadRenderGameObjects(DCustomEquipment[] outfit, Color bodyColor, AvatarAnimationFrame avatarFrame, RenderRequest renderRequest)
        {
            if (avatarPrefab == null && isLoadingAvatarPrefab)
            {
                yield return(null);
            }
            if (avatarPrefab == null)
            {
                isLoadingAvatarPrefab = true;
                AssetRequest <GameObject> assetRequest = null;
                try
                {
                    assetRequest = Content.LoadAsync(uiAvatarPrefabContentKey);
                }
                catch (Exception ex)
                {
                    Log.LogError(this, $"Could not load UI Avatar penguin asset {uiAvatarPrefabContentKey.Key}. Message: {ex.Message}");
                }
                if (assetRequest != null)
                {
                    yield return(assetRequest);

                    avatarPrefab          = assetRequest.Asset;
                    isLoadingAvatarPrefab = false;
                }
            }
            if (avatarPrefab != null)
            {
                GameObject            avatarInstance = UnityEngine.Object.Instantiate(avatarPrefab);
                IconRenderLightingRig lightingRig    = IconRenderLightingRig.Acquire();
                while (!lightingRig.IsReady)
                {
                    yield return(null);
                }
                DCustomOutfit avatarOutfit = default(DCustomOutfit);
                avatarOutfit.Equipment = outfit;
                AvatarModel avatarModel = avatarInstance.GetComponent <AvatarModel>();
                yield return(AvatarRenderer.RenderOutfit(avatarOutfit, avatarModel.BeakColor, bodyColor, avatarModel.BellyColor, imageBuilderCameraData, avatarInstance, (ModelRenderer modelRenderer) => onProcessAnimationFrame(modelRenderer, renderRequest.Handle, avatarInstance), avatarFrame));

                IconRenderLightingRig.Release();
            }
            else
            {
                Log.LogErrorFormatted(this, "Unabe to load the UI Avatar Prefab at path {0}", uiAvatarPrefabContentKey.Key);
            }
        }
Exemplo n.º 5
0
 private void OnEnable()
 {
     lightingRig = IconRenderLightingRig.Acquire();
 }