예제 #1
0
        public IEnumerator InitThings()
        {
            MelonLogger.Log("Waiting for init");

            while (ReferenceEquals(NetworkManager.field_Internal_Static_NetworkManager_0, null))
            {
                yield return(null);
            }
            while (ReferenceEquals(VRCAudioManager.field_Private_Static_VRCAudioManager_0, null))
            {
                yield return(null);
            }
            while (ReferenceEquals(VRCUiManager.field_Protected_Static_VRCUiManager_0, null))
            {
                yield return(null);
            }

            MelonLogger.Log("Start init");

            NetworkManagerHooks.Initialize();

            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("JoinNotifier.joinnotifier.assetbundle"))
                using (var tempStream = new MemoryStream((int)stream.Length))
                {
                    stream.CopyTo(tempStream);

                    myAssetBundle            = AssetBundle.LoadFromMemory_Internal(tempStream.ToArray(), 0);
                    myAssetBundle.hideFlags |= HideFlags.DontUnloadUnusedAsset;
                }

            myJoinSprite            = myAssetBundle.LoadAsset_Internal("Assets/JoinNotifier/JoinIcon.png", Il2CppType.Of <Sprite>()).Cast <Sprite>();
            myJoinSprite.hideFlags |= HideFlags.DontUnloadUnusedAsset;

            myJoinClip            = myAssetBundle.LoadAsset_Internal("Assets/JoinNotifier/Chime.ogg", Il2CppType.Of <AudioClip>()).Cast <AudioClip>();
            myJoinClip.hideFlags |= HideFlags.DontUnloadUnusedAsset;

            myLeaveClip            = myAssetBundle.LoadAsset_Internal("Assets/JoinNotifier/DoorClose.ogg", Il2CppType.Of <AudioClip>()).Cast <AudioClip>();
            myLeaveClip.hideFlags |= HideFlags.DontUnloadUnusedAsset;

            CreateGameObjects();

            NetworkManagerHooks.OnJoin  += OnPlayerJoined;
            NetworkManagerHooks.OnLeave += OnPlayerLeft;
        }
예제 #2
0
        public IEnumerator InitThings()
        {
            MelonLogger.Log("Waiting for init");

            while (ReferenceEquals(NetworkManager.field_Internal_Static_NetworkManager_0, null))
            {
                yield return(null);
            }
            while (ReferenceEquals(VRCAudioManager.field_Private_Static_VRCAudioManager_0, null))
            {
                yield return(null);
            }
            while (ReferenceEquals(VRCUiManager.prop_VRCUiManager_0, null))
            {
                yield return(null);
            }

            var audioManager = VRCAudioManager.field_Private_Static_VRCAudioManager_0;

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

            MelonLogger.Log("Start init");

            NetworkManagerHooks.Initialize();

            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("JoinNotifier.joinnotifier.assetbundle"))
                using (var tempStream = new MemoryStream((int)stream.Length))
                {
                    stream.CopyTo(tempStream);

                    myAssetBundle            = AssetBundle.LoadFromMemory_Internal(tempStream.ToArray(), 0);
                    myAssetBundle.hideFlags |= HideFlags.DontUnloadUnusedAsset;
                }

            myJoinSprite            = myAssetBundle.LoadAsset_Internal("Assets/JoinNotifier/JoinIcon.png", Il2CppType.Of <Sprite>()).Cast <Sprite>();
            myJoinSprite.hideFlags |= HideFlags.DontUnloadUnusedAsset;

            if (File.Exists(CustomJoinSoundFileName))
            {
                MelonLogger.Msg("Loading custom join sound");
                var uwr     = UnityWebRequest.Get($"file://{Path.Combine(Environment.CurrentDirectory, CustomJoinSoundFileName)}");
                var asyncOp = uwr.SendWebRequest();

                while (uwr.isDone)
                {
                    yield return(null);
                }

                myJoinClip = WebRequestWWW.InternalCreateAudioClipUsingDH(uwr.downloadHandler, uwr.url, false, false, AudioType.UNKNOWN);
            }

            if (myJoinClip == null)
            {
                myJoinClip = myAssetBundle.LoadAsset_Internal("Assets/JoinNotifier/Chime.ogg", Il2CppType.Of <AudioClip>()).Cast <AudioClip>();
            }

            myJoinClip.hideFlags |= HideFlags.DontUnloadUnusedAsset;

            if (File.Exists(CustomLeaveSoundFileName))
            {
                MelonLogger.Msg("Loading custom leave sound");

                var uwr     = UnityWebRequest.Get($"file://{Path.Combine(Environment.CurrentDirectory, CustomLeaveSoundFileName)}");
                var asyncOp = uwr.SendWebRequest();

                while (uwr.isDone)
                {
                    yield return(null);
                }

                myLeaveClip = WebRequestWWW.InternalCreateAudioClipUsingDH(uwr.downloadHandler, uwr.url, false, false, AudioType.UNKNOWN);
            }

            if (myLeaveClip == null)
            {
                myLeaveClip = myAssetBundle.LoadAsset_Internal("Assets/JoinNotifier/DoorClose.ogg", Il2CppType.Of <AudioClip>()).Cast <AudioClip>();
            }

            myLeaveClip.hideFlags |= HideFlags.DontUnloadUnusedAsset;

            CreateGameObjects();

            NetworkManagerHooks.OnJoin  += OnPlayerJoined;
            NetworkManagerHooks.OnLeave += OnPlayerLeft;
        }