Exemplo n.º 1
0
    // Token: 0x060063E4 RID: 25572 RVA: 0x00237354 File Offset: 0x00235754
    private void Start()
    {
        VRCAudioManager.ApplyGameAudioMixerSettings(base.GetComponent <AudioSource>());
        AudioSource component = base.GetComponent <AudioSource>();

        this.SetParameters(ref component);
    }
Exemplo n.º 2
0
 // Token: 0x06005756 RID: 22358 RVA: 0x001E1649 File Offset: 0x001DFA49
 private void Start()
 {
     if (VRCAudioManager.instance != null)
     {
         Debug.LogError("Multiple instances of VRCAudioManager = Bad");
     }
     VRCAudioManager.instance = this;
     VRCAudioManager.SettingsChanged();
 }
Exemplo n.º 3
0
 // Token: 0x06005621 RID: 22049 RVA: 0x001DA987 File Offset: 0x001D8D87
 public static void SettingsChanged(VRCInputManager.InputSetting whichSetting = VRCInputManager.InputSetting.Unknown)
 {
     VRCAudioManager.SettingsChanged();
     VRCPlayer.SettingsChanged();
     if (whichSetting == VRCInputManager.InputSetting.DefaultMute)
     {
         User.SetNetworkProperties();
         ModerationManager.Instance.Updated();
     }
 }
Exemplo n.º 4
0
    /// <summary>
    /// Start this instance.
    /// </summary>
    void Start()
    {
#if VRC_CLIENT
        var source = GetComponent <AudioSource>();

        if (source != null && source.outputAudioMixerGroup != VRCAudioManager.GetAvatarGroup())
        {
            VRCAudioManager.ApplyGameAudioMixerSettings(source);
        }
#endif
    }
Exemplo n.º 5
0
    /// <summary>
    /// Start this instance.
    /// </summary>
    void Start()
    {
#if VRC_CLIENT
        VRCAudioManager.ApplyGameAudioMixerSettings(GetComponent <AudioSource>());
#endif

        // jnuccio: moved SetParameters() call here from Awake
        // We might iterate through multiple sources / game object
        var source = GetComponent <AudioSource>();
        SetParameters(ref source);
    }
Exemplo n.º 6
0
 // Token: 0x06005FEE RID: 24558 RVA: 0x0021BC24 File Offset: 0x0021A024
 public void Start()
 {
     if (this.audioSource == null)
     {
         this.audioSource = base.gameObject.AddComponent <AudioSource>();
         this.audioSource.outputAudioMixerGroup = VRCAudioManager.GetUiGroup();
         this.audioSource.volume = 0.25f;
     }
     if (this.mouseIn == null && this.ui_file_sounds != null && this.ui_file_sounds.MoveOver != null)
     {
         this.mouseIn = this.ui_file_sounds.MoveOver;
     }
     this.mouseOut   = this.ui_file_sounds.MoveOff;
     this.mouseClick = this.ui_file_sounds.Click;
 }
Exemplo n.º 7
0
 // Token: 0x0600575D RID: 22365 RVA: 0x001E1918 File Offset: 0x001DFD18
 public static void ApplyGameAudioMixerSettings(AudioSource audioSource)
 {
     if (audioSource == null)
     {
         return;
     }
     if (audioSource.transform.root.gameObject.CompareTag("VRCGlobalRoot") || audioSource.GetComponent <USpeaker>() != null)
     {
         return;
     }
     try
     {
         audioSource.outputAudioMixerGroup = VRCAudioManager.GetGameGroup();
     }
     catch (Exception exception)
     {
         Debug.LogException(exception, audioSource.gameObject);
     }
 }
Exemplo n.º 8
0
        public override void VRChat_OnUiManagerInit()
        {
            MelonLogger.Msg("Patching methods...");
            _harmony = HarmonyInstance.Create(BuildInfo.Name);

            typeof(DefaultTalkController).GetMethods()
            .Where(m => m.Name.StartsWith("Method_Public_Static_Void_Boolean_") && !m.Name.Contains("PDM")).ToList()
            .ForEach(m =>
            {
                _harmony.Patch(m,
                               prefix: new HarmonyMethod(typeof(Mod).GetMethod("ToggleVoicePrefix",
                                                                               BindingFlags.NonPublic | BindingFlags.Static)));
                MelonLogger.Msg("Patched " + m.Name);
            });

            MelonLogger.Msg("Creating audio source...");

            // this is the actual name of the audio clip lol
            AudioClip Blop = GameObject.Find("UserInterface/UnscaledUI/HudContent/Hud/VoiceDotParent")
                             .GetComponent <HudVoiceIndicator>().field_Public_AudioClip_0;

            _unmuteBlop = GameObject.Find("UserInterface/UnscaledUI/HudContent/Hud/VoiceDotParent")
                          .AddComponent <AudioSource>();

            _unmuteBlop.clip        = Blop;
            _unmuteBlop.playOnAwake = false;
            _unmuteBlop.pitch       = 1.2f;

            // thanks knah https://github.com/knah/VRCMods/blob/142dab764543a17ab10092ec684bf7cf19e72683/JoinNotifier/JoinNotifierMod.cs#L64-L70
            VRCAudioManager audioManager = VRCAudioManager.field_Private_Static_VRCAudioManager_0;

            _unmuteBlop.outputAudioMixerGroup = new[]
            {
                audioManager.field_Public_AudioMixerGroup_0,
                audioManager.field_Public_AudioMixerGroup_1,
                audioManager.field_Public_AudioMixerGroup_2
            }.Single(mg => mg.name == "UI");

            MelonLogger.Msg("Initialized!");
        }
Exemplo n.º 9
0
        public static IEnumerator EnforceAudioSourceLimitsEnumerator(GameObject currentAvatar, System.Action <AudioSource> onFound)
        {
            if (currentAvatar == null)
            {
                yield break;
            }

            Queue <GameObject> children = new Queue <GameObject>();

            if (currentAvatar != null)
            {
                children.Enqueue(currentAvatar.gameObject);
            }
            while (children.Count > 0)
            {
                GameObject child = children.Dequeue();
                if (child == null)
                {
                    continue;
                }

                int childCount = child.transform.childCount;
                for (int idx = 0; idx < child.transform.childCount; ++idx)
                {
                    children.Enqueue(child.transform.GetChild(idx).gameObject);
                }

#if VRC_CLIENT
                if (child.GetComponent <USpeaker>() != null)
                {
                    continue;
                }
#endif

                AudioSource[] sources = child.transform.GetComponents <AudioSource>();
                if (sources != null && sources.Length > 0)
                {
                    AudioSource au = sources[0];
                    if (au == null)
                    {
                        continue;
                    }

#if VRC_CLIENT
                    au.outputAudioMixerGroup = VRCAudioManager.GetAvatarGroup();
#endif

                    if (au.volume > 0.9f)
                    {
                        au.volume = 0.9f;
                    }

#if VRC_CLIENT
                    // someone mucked with the sdk forced settings, shame on them!
                    if (au.spatialize == false)
                    {
                        au.volume = 0;
                    }
#else
                    au.spatialize = true;
#endif

                    au.priority              = Mathf.Clamp(au.priority, 200, 255);
                    au.bypassEffects         = false;
                    au.bypassListenerEffects = false;
                    au.spatialBlend          = 1f;
                    au.spread = 0;

                    au.minDistance = Mathf.Clamp(au.minDistance, 0, 2);
                    au.maxDistance = Mathf.Clamp(au.maxDistance, 0, 30);

                    float range = au.maxDistance - au.minDistance;
                    float min   = au.minDistance;
                    float max   = au.maxDistance;
                    float mult  = 50.0f / range;

                    // setup a custom rolloff curve
                    Keyframe[] keys = new Keyframe[7];
                    keys[0] = new Keyframe(0, 1);
                    keys[1] = new Keyframe(min, 1, 0, -0.4f * mult);
                    keys[2] = new Keyframe(min + 0.022f * range, 0.668f, -0.2f * mult, -0.2f * mult);
                    keys[3] = new Keyframe(min + 0.078f * range, 0.359f, -0.05f * mult, -0.05f * mult);
                    keys[4] = new Keyframe(min + 0.292f * range, 0.102f, -0.01f * mult, -0.01f * mult);
                    keys[5] = new Keyframe(min + 0.625f * range, 0.025f, -0.002f * mult, -0.002f * mult);
                    keys[6] = new Keyframe(max, 0);
                    AnimationCurve curve = new AnimationCurve(keys);

                    au.rolloffMode = AudioRolloffMode.Custom;
                    au.SetCustomCurve(AudioSourceCurveType.CustomRolloff, curve);

                    // if we have an onsp component, also configure that
                    ONSPAudioSource oa = au.GetComponent <ONSPAudioSource>();
                    if (oa)
                    {
                        if (oa.Gain > 10f)
                        {
                            oa.Gain = 10f;
                        }
#if VRC_CLIENT
                        // someone mucked with the sdk forced settings, shame on them!
                        if (oa.enabled == false || oa.EnableSpatialization == false)
                        {
                            oa.Gain   = 0f;
                            au.volume = 0f;
                        }
#else
                        oa.enabled = true;
                        oa.EnableSpatialization = true;
#endif
                        oa.UseInvSqr = true; // This is the ENABLED value for OCULUS ATTENUATION
                        oa.EnableRfl = false;
                        if (oa.Near > 2f)
                        {
                            oa.Near = 2f;
                        }
                        if (oa.Far > 30f)
                        {
                            oa.Far = 30f;
                        }
                        oa.VolumetricRadius = 0f;
                    }

                    onFound(au);

                    if (sources.Length > 1)
                    {
                        Debug.LogError("Disabling extra AudioSources on GameObject(" + child.name + "). Only one is allowed per GameObject.");
                        for (int i = 1; i < sources.Length; i++)
                        {
                            if (sources[i] == null)
                            {
                                continue;
                            }

#if VRC_CLIENT
                            sources[i].enabled = false;
                            sources[i].clip    = null;
#else
                            Validation.RemoveComponent(sources[i]);
#endif
                        }
                    }
                }

                yield return(null);
            }
        }
Exemplo n.º 10
0
        public static IEnumerator EnforceAudioSourceLimitsEnumerator(GameObject currentAvatar, System.Action <AudioSource> onFound)
        {
            if (currentAvatar == null)
            {
                yield break;
            }

            Queue <GameObject> children = new Queue <GameObject>();

            if (currentAvatar != null)
            {
                children.Enqueue(currentAvatar.gameObject);
            }

            while (children.Count > 0)
            {
                if (Time.frameCount > _enforceAudioSourcesFrameNumber)
                {
                    _enforceAudioSourcesFrameNumber        = Time.frameCount;
                    _enforceAudioSourcesProcessedThisFrame = 0;
                }

                if (_enforceAudioSourcesProcessedThisFrame > ENFORCE_AUDIO_SOURCE_GAMEOBJECTS_PER_FRAME)
                {
                    yield return(null);
                }

                Profiler.BeginSample("EnforceAudioSourceLimitsEnumerator");
                _enforceAudioSourcesProcessedThisFrame++;

                GameObject child = children.Dequeue();
                if (child == null)
                {
                    Profiler.EndSample();
                    continue;
                }

                int childCount = child.transform.childCount;
                for (int idx = 0; idx < childCount; ++idx)
                {
                    children.Enqueue(child.transform.GetChild(idx).gameObject);
                }

                #if VRC_CLIENT
                if (child.GetComponent <USpeaker>() != null)
                {
                    Profiler.EndSample();
                    continue;
                }
                #endif

                AudioSource[] sources = child.transform.GetComponents <AudioSource>();
                if (sources != null && sources.Length > 0)
                {
                    AudioSource audioSource = sources[0];
                    if (audioSource == null)
                    {
                        Profiler.EndSample();
                        continue;
                    }

                    VRC_SpatialAudioSource vrcSpatialAudioSource = audioSource.gameObject.GetComponent <VRC_SpatialAudioSource>();

                    #if VRC_CLIENT
                    audioSource.outputAudioMixerGroup = VRCAudioManager.GetAvatarGroup();
                    audioSource.priority = Mathf.Clamp(audioSource.priority, 200, 255);
                    if (vrcSpatialAudioSource != null)
                    {
                        // copy the values into the onsp component
                        var onspAudioSource = audioSource.gameObject.GetOrAddComponent <ONSPAudioSource>();
                        onspAudioSource.Gain                 = vrcSpatialAudioSource.Gain;
                        onspAudioSource.Near                 = vrcSpatialAudioSource.Near;
                        onspAudioSource.Far                  = vrcSpatialAudioSource.Far;
                        onspAudioSource.VolumetricRadius     = vrcSpatialAudioSource.VolumetricRadius;
                        onspAudioSource.EnableSpatialization = vrcSpatialAudioSource.EnableSpatialization;
                        onspAudioSource.UseInvSqr            = !vrcSpatialAudioSource.UseAudioSourceVolumeCurve;
                        if (!vrcSpatialAudioSource.EnableSpatialization)
                        {
                            audioSource.spatialize = false;
                        }
                    }
                    #else
                    // these are SDK only, we rely on AvatarAudioSourceLimiter to enforce
                    // values at runtime

                    #if SUPPORT_DEPRECATED_ONSP
                    ONSPAudioSource[] allOnsp = audioSource.gameObject.GetComponents <ONSPAudioSource>();
                    if (allOnsp != null && allOnsp.Length > 0)
                    {
                        ONSPAudioSource onsp = allOnsp[0];
                        if (vrcSpatialAudioSource == null)
                        {
                            vrcSpatialAudioSource = audioSource.gameObject.AddComponent <VRC_SpatialAudioSource>();
                        }

                        vrcSpatialAudioSource.Gain                      = Mathf.Min(onsp.Gain, VRCSDK2.AudioManagerSettings.AvatarAudioMaxGain);
                        vrcSpatialAudioSource.Far                       = Mathf.Min(onsp.Far, VRCSDK2.AudioManagerSettings.AvatarAudioMaxRange);
                        vrcSpatialAudioSource.VolumetricRadius          = Mathf.Min(onsp.Far, VRCSDK2.AudioManagerSettings.AvatarAudioMaxRange);
                        vrcSpatialAudioSource.Near                      = Mathf.Min(onsp.Near, onsp.Far);
                        vrcSpatialAudioSource.EnableSpatialization      = onsp.EnableSpatialization;
                        vrcSpatialAudioSource.UseAudioSourceVolumeCurve = !onsp.UseInvSqr;

                        Debug.LogWarningFormat("ONSPAudioSource found on {0}. converted to VRC_SpatialAudioSource.", child.name);
                        foreach (var o in allOnsp)
                        {
                            Object.DestroyImmediate(o, true);
                        }
                    }
                    #endif
                    if (vrcSpatialAudioSource == null)
                    {
                        // user has not yet added VRC_SpatialAudioSource (or ONSP)
                        // so set up some defaults
                        vrcSpatialAudioSource                      = audioSource.gameObject.AddComponent <VRC_SpatialAudioSource>();
                        vrcSpatialAudioSource.Gain                 = AudioManagerSettings.AvatarAudioMaxGain;
                        vrcSpatialAudioSource.Far                  = AudioManagerSettings.AvatarAudioMaxRange;
                        vrcSpatialAudioSource.Near                 = 0f;
                        vrcSpatialAudioSource.VolumetricRadius     = 0f;
                        vrcSpatialAudioSource.EnableSpatialization = true;
                        vrcSpatialAudioSource.enabled              = true;
                        audioSource.spatialize                     = true;
                        audioSource.priority              = Mathf.Clamp(audioSource.priority, 200, 255);
                        audioSource.bypassEffects         = false;
                        audioSource.bypassListenerEffects = false;
                        audioSource.spatialBlend          = 1f;
                        audioSource.spread = 0;

                        // user is allowed to change, but for now put a safe default
                        audioSource.maxDistance = AudioManagerSettings.AvatarAudioMaxRange;
                        audioSource.minDistance = audioSource.maxDistance / 500f;
                        audioSource.rolloffMode = AudioRolloffMode.Logarithmic;
                    }
                    #endif //!VRC_CLIENT

                    onFound(audioSource);

                    if (sources.Length > 1)
                    {
                        Debug.LogError("Disabling extra AudioSources on GameObject(" + child.name + "). Only one is allowed per GameObject.");
                        for (int i = 1; i < sources.Length; i++)
                        {
                            if (sources[i] == null)
                            {
                                Profiler.EndSample();
                                continue;
                            }

                            #if VRC_CLIENT
                            sources[i].enabled = false;
                            sources[i].clip    = null;
                            #else
                            ValidationUtils.RemoveComponent(sources[i]);
                            #endif //!VRC_CLIENT
                        }
                    }
                }

                Profiler.EndSample();
            }
        }
Exemplo n.º 11
0
        private static IEnumerator EnforceAudioSourceLimitsEnumerator(GameObject currentAvatar, System.Action <AudioSource> onFound)
        {
            if (currentAvatar == null)
            {
                yield break;
            }

            Queue <GameObject> children = new Queue <GameObject>();

            if (currentAvatar != null)
            {
                children.Enqueue(currentAvatar.gameObject);
            }

            while (children.Count > 0)
            {
                if (Time.frameCount > _enforceAudioSourcesFrameNumber)
                {
                    _enforceAudioSourcesFrameNumber        = Time.frameCount;
                    _enforceAudioSourcesProcessedThisFrame = 0;
                }

                if (_enforceAudioSourcesProcessedThisFrame > ENFORCE_AUDIO_SOURCE_GAMEOBJECTS_PER_FRAME)
                {
                    yield return(null);
                }

                Profiler.BeginSample("EnforceAudioSourceLimitsEnumerator");
                _enforceAudioSourcesProcessedThisFrame++;

                GameObject child = children.Dequeue();
                if (child == null)
                {
                    Profiler.EndSample();
                    continue;
                }

                int childCount = child.transform.childCount;
                for (int idx = 0; idx < childCount; ++idx)
                {
                    children.Enqueue(child.transform.GetChild(idx).gameObject);
                }

#if VRC_CLIENT
                if (child.GetComponent <USpeaker>() != null)
                {
                    Profiler.EndSample();
                    continue;
                }
#endif

                AudioSource[] sources = child.transform.GetComponents <AudioSource>();
                if (sources != null && sources.Length > 0)
                {
                    AudioSource audioSource = sources[0];
                    if (audioSource == null)
                    {
                        Profiler.EndSample();
                        continue;
                    }


#if VRC_CLIENT
                    audioSource.outputAudioMixerGroup = VRCAudioManager.GetAvatarGroup();
                    audioSource.priority = Mathf.Clamp(audioSource.priority, 200, 255);
#else
                    ProcessSpatialAudioSources(audioSource);
#endif //!VRC_CLIENT

                    onFound(audioSource);

                    if (sources.Length > 1)
                    {
                        Debug.LogError("Disabling extra AudioSources on GameObject(" + child.name + "). Only one is allowed per GameObject.");
                        for (int i = 1; i < sources.Length; i++)
                        {
                            if (sources[i] == null)
                            {
                                Profiler.EndSample();
                                continue;
                            }

#if VRC_CLIENT
                            sources[i].enabled = false;
                            sources[i].clip    = null;
#else
                            ValidationUtils.RemoveComponent(sources[i]);
#endif //!VRC_CLIENT
                        }
                    }
                }

                Profiler.EndSample();
            }
        }
        public static void EnforceAudioSourceLimits(GameObject currentAvatar)
        {
            using (_enforceAudioSourceLimitsProfilerMarker.Auto())
            {
                if (currentAvatar == null)
                {
                    return;
                }

                Queue <GameObject> children = new Queue <GameObject>();
                if (currentAvatar != null)
                {
                    children.Enqueue(currentAvatar.gameObject);
                }

                while (children.Count > 0)
                {
                    GameObject child = children.Dequeue();
                    if (child == null)
                    {
                        continue;
                    }

                    int childCount = child.transform.childCount;
                    for (int idx = 0; idx < childCount; ++idx)
                    {
                        children.Enqueue(child.transform.GetChild(idx).gameObject);
                    }

                    #if VRC_CLIENT
                    if (child.GetComponent <USpeaker>() != null)
                    {
                        continue;
                    }
                    #endif

                    AudioSource[] sources = child.transform.GetComponents <AudioSource>();
                    if (sources == null || sources.Length <= 0)
                    {
                        continue;
                    }

                    AudioSource audioSource = sources[0];
                    if (audioSource == null)
                    {
                        continue;
                    }


                    #if VRC_CLIENT
                    audioSource.outputAudioMixerGroup = VRCAudioManager.GetAvatarGroup();
                    audioSource.priority = Mathf.Clamp(audioSource.priority, 200, 255);
                    #else
                    ProcessSpatialAudioSources(audioSource);
                    #endif //!VRC_CLIENT

                    if (sources.Length <= 1)
                    {
                        continue;
                    }

                    Debug.LogError("Disabling extra AudioSources on GameObject(" + child.name + "). Only one is allowed per GameObject.");
                    for (int i = 1; i < sources.Length; i++)
                    {
                        if (sources[i] == null)
                        {
                            Profiler.EndSample();
                            continue;
                        }

                        #if VRC_CLIENT
                        sources[i].enabled = false;
                        sources[i].clip    = null;
                        #else
                        ValidationUtils.RemoveComponent(sources[i]);
                        #endif //!VRC_CLIENT
                    }
                }
            }
        }
Exemplo n.º 13
0
    // Token: 0x06005BD5 RID: 23509 RVA: 0x00200B3C File Offset: 0x001FEF3C
    public IEnumerator ProcessSceneObjects(Action onDone)
    {
        List <Transform> rootTransforms = new List <Transform>();

        Transform[] allTransforms = Tools.FindSceneObjectsOfTypeAll <Transform>();
        foreach (Transform item in from t in allTransforms
                 where t != null && t.parent == null && t.gameObject != null && !t.gameObject.CompareTag("VRCGlobalRoot")
                 select t)
        {
            rootTransforms.Add(item);
        }
        yield return(null);

        if (!this.sceneDescriptor.useAssignedLayers)
        {
            foreach (Transform transform in rootTransforms)
            {
                try
                {
                    Tools.SetLayerRecursively(transform.gameObject, LayerMask.NameToLayer("Environment"), LayerMask.NameToLayer("Interactive"));
                }
                catch (Exception exception)
                {
                    Debug.LogException(exception, transform.gameObject);
                }
            }
        }
        else
        {
            Debug.Log("This level has elected to use it's own Unity Layers. If things like physics and collision are messed up, this is a likely reason.");
        }
        yield return(null);

        Physics.gravity = this.sceneDescriptor.gravity;
        Debug.Log("<color=yellow>Loading scene's render settings.</color>");
        if (this.sceneDescriptor.layerCollisionArr != null)
        {
            bool[,] array = Tools.OneDArrayToTwoDArray <bool>(this.sceneDescriptor.layerCollisionArr, 32, 32);
            int numReservedLayers = Tools.GetNumReservedLayers();
            for (int i = 0; i < 32; i++)
            {
                for (int j = 0; j < 32; j++)
                {
                    if (i >= numReservedLayers || j >= numReservedLayers)
                    {
                        bool ignore = !array[i, j];
                        if (i == LayerMask.NameToLayer("UI") || i == LayerMask.NameToLayer("UiMenu") || i == LayerMask.NameToLayer("StereoLeft") || i == LayerMask.NameToLayer("StereoRight") || j == LayerMask.NameToLayer("UI") || j == LayerMask.NameToLayer("UiMenu") || j == LayerMask.NameToLayer("StereoLeft") || j == LayerMask.NameToLayer("StereoRight"))
                        {
                            ignore = true;
                        }
                        Physics.IgnoreLayerCollision(i, j, ignore);
                    }
                }
            }
        }
        yield return(null);

        VRC_SpecialLayer[] layers = Tools.FindSceneObjectsOfTypeAll <VRC_SpecialLayer>();
        foreach (VRC_SpecialLayer vrc_SpecialLayer in from l in layers
                 where l != null && !l.transform.root.gameObject.CompareTag("VRCGlobalRoot")
                 select l)
        {
            try
            {
                vrc_SpecialLayer.Apply();
            }
            catch (Exception exception2)
            {
                Debug.LogException(exception2, vrc_SpecialLayer.gameObject);
            }
        }
        yield return(null);

        VRCAudioManager.DisableAllExtraAudioListeners();
        yield return(null);

        AudioSource[] audioSources = Tools.FindSceneObjectsOfTypeAll <AudioSource>();
        foreach (AudioSource audioSource in audioSources)
        {
            VRCAudioManager.ApplyGameAudioMixerSettings(audioSource);
        }
        yield return(null);

        if (this.sceneDescriptor.autoSpatializeAudioSources)
        {
            Debug.Log("Auto spatializing AudioSources...");
            try
            {
                AddONSPAudioSourceComponent.ApplyDefaultSpatializationToAudioSources();
            }
            catch (Exception exception3)
            {
                Debug.LogException(exception3, this.sceneDescriptor.gameObject);
            }
        }
        yield return(null);

        onDone();
        yield break;
    }
Exemplo n.º 14
0
    // Token: 0x06005BD3 RID: 23507 RVA: 0x002009DC File Offset: 0x001FEDDC
    public IEnumerator InstantiateDownloadedScene(AssetBundleDownload download, float timeLimit, Action onSuccess, Action <string> onError)
    {
        if (download == null)
        {
            Debug.LogError("Download was null");
            if (onError != null)
            {
                onError("Download was null");
            }
            yield break;
        }
        AssetBundle ab = download.assetBundle;

        if (ab == null)
        {
            Debug.LogError("Asset bundle did not load");
            if (onError != null)
            {
                onError("Asset bundle did not load");
            }
            yield break;
        }
        VRCAudioManager.EnableAllAudio(false);
        string[] sceneFiles = ab.GetAllScenePaths();
        if (sceneFiles.Length != 1)
        {
            Debug.LogWarning("VRCW file has bad scene count - " + download.assetUrl);
        }
        string sceneName = Path.GetFileNameWithoutExtension(sceneFiles[0]);

        Debug.Log("Loading scene: " + sceneName);
        AssetBundleDownloadManager.RegisterManuallyLoadedAssetBundle(download.assetUrl, ab, ab);
        bool loadLevelSuccess = false;

        yield return(AssetManagement.LoadLevelAsync(sceneName, LoadSceneMode.Single, timeLimit, delegate
        {
            loadLevelSuccess = true;
        }));

        if (!loadLevelSuccess)
        {
            Debug.LogError("Failed to load scene " + sceneName + ", LoadLevelAsync failed");
            if (onError != null)
            {
                onError("Failed to load scene " + sceneName + ", LoadLevelAsync failed");
            }
            yield break;
        }
        Scene scene = SceneManager.GetSceneByName(sceneName);

        if (!scene.isLoaded)
        {
            Debug.LogError("Failed to load scene " + sceneName);
            if (onError != null)
            {
                onError("Failed to load scene " + sceneName);
            }
            yield break;
        }
        if (!this.ProcessSceneObjectsImmediate())
        {
            Debug.LogError("Error processing scene objects post load");
            if (onError != null)
            {
                onError("Error processing scene objects post load, scene " + sceneName);
            }
            yield break;
        }
        yield return(null);

        yield return(null);

        SceneManager.SetActiveScene(scene);
        yield return(null);

        onSuccess();
        yield break;
    }