示例#1
0
        public override void OnApplicationStart()
        {
            Instance = this;
            try
            {
                //Adapted from knah's JoinNotifier mod found here: https://github.com/knah/VRCMods/blob/master/JoinNotifier/JoinNotifierMod.cs
                using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ActionMenuUtils.icons"))
                    using (var tempStream = new MemoryStream((int)stream.Length))
                    {
                        stream.CopyTo(tempStream);

                        iconsAssetBundle            = AssetBundle.LoadFromMemory_Internal(tempStream.ToArray(), 0);
                        iconsAssetBundle.hideFlags |= HideFlags.DontUnloadUnusedAsset;
                    }
                respawnIcon            = iconsAssetBundle.LoadAsset_Internal("Assets/Resources/Refresh.png", Il2CppType.Of <Texture2D>()).Cast <Texture2D>();
                respawnIcon.hideFlags |= HideFlags.DontUnloadUnusedAsset;
                helpIcon                      = iconsAssetBundle.LoadAsset_Internal("Assets/Resources/Help.png", Il2CppType.Of <Texture2D>()).Cast <Texture2D>();
                helpIcon.hideFlags           |= HideFlags.DontUnloadUnusedAsset;
                goHomeIcon                    = iconsAssetBundle.LoadAsset_Internal("Assets/Resources/Home.png", Il2CppType.Of <Texture2D>()).Cast <Texture2D>();
                goHomeIcon.hideFlags         |= HideFlags.DontUnloadUnusedAsset;
                resetAvatarIcon               = iconsAssetBundle.LoadAsset_Internal("Assets/Resources/Avatar.png", Il2CppType.Of <Texture2D>()).Cast <Texture2D>();
                resetAvatarIcon.hideFlags    |= HideFlags.DontUnloadUnusedAsset;
                rejoinInstanceIcon            = iconsAssetBundle.LoadAsset_Internal("Assets/Resources/Pin.png", Il2CppType.Of <Texture2D>()).Cast <Texture2D>();
                rejoinInstanceIcon.hideFlags |= HideFlags.DontUnloadUnusedAsset;
            }
            catch (Exception e) {
                MelonLogger.Warning("Consider checking for newer version as mod possibly no longer working, Exception occured OnAppStart(): " + e.Message);
            }
            // Creates new Api instance and patches all required methods if found
            actionMenuApi = new ActionMenuAPI();
            ModSettings.RegisterSettings();
            ModSettings.Apply();
            SetupButtons();
            //_ = Utils.GetGoHomeDelegate;
        }
示例#2
0
        public override void VRChat_OnUiManagerInit()
        {
            // while (ReferenceEquals(VRCAudioManager.field_Private_Static_VRCAudioManager_0, null)) yield return null;
            MelonLogger.Log("Start init 2: electric boogaloo");

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

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

            loadScreenPrefab            = assets.LoadAsset_Internal("Assets/Bundle/OldLoadingScreen.prefab", Il2CppType.Of <GameObject>()).Cast <GameObject>();
            loadScreenPrefab.hideFlags |= HideFlags.DontUnloadUnusedAsset;

            cavernDry            = assets.LoadAsset_Internal("Assets/Bundle/CavernDry.prefab", Il2CppType.Of <GameObject>()).Cast <GameObject>();
            cavernDry.hideFlags |= HideFlags.DontUnloadUnusedAsset;

            newCube              = assets.LoadAsset_Internal("Assets/Bundle/Cube.prefab", Il2CppType.Of <GameObject>()).Cast <GameObject>();
            cavernDry.hideFlags |= HideFlags.DontUnloadUnusedAsset;

            CreateGameObjects();
        }
示例#3
0
        private static Material LoadMateral(string assetToLoad)
        {
            Material loadedMaterial = Bundle.LoadAsset_Internal(assetToLoad, Il2CppType.Of <Material>()).Cast <Material>();

            loadedMaterial.hideFlags |= HideFlags.DontUnloadUnusedAsset;
            return(loadedMaterial);
        }
示例#4
0
        public static void Setup()
        {
            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("WorldPredownload.gompowpd"))
                using (var tempStream = new MemoryStream((int)stream.Length))
                {
                    stream.CopyTo(tempStream);

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

            hudIcon = iconsAssetBundle.LoadAsset_Internal("Assets/DownloadIcon.png", Il2CppType.Of <Sprite>())
                      .Cast <Sprite>();
            hudIcon.hideFlags |= HideFlags.DontUnloadUnusedAsset;
            var Main      = CreateImage("DownloadStatusProgress");
            var Secondary = CreateImage("DownloadStatusTransparent");

            Secondary.color = new Color(1, 1, 1, 0.4f);
            Main.type       = Image.Type.Filled;
            Main.fillMethod = Image.FillMethod.Horizontal;
            Main.fillOrigin = (int)Image.OriginHorizontal.Left;
            Main.fillAmount = 0f;
            Heavy           = Main;
            Fade            = Secondary;
            Disable();
        }
示例#5
0
        public static T LoadAsset <T>(AssetBundle assetBundle, string assetPath) where T : Object
        {
            var asset = assetBundle.LoadAsset_Internal(assetPath, Il2CppType.Of <T>()).Cast <T>();

            asset.hideFlags |= HideFlags.DontUnloadUnusedAsset;
            return(asset);
        }
示例#6
0
        private static Texture2D LoadTexture(string texture)
        {
            var texture2 = _bundle.LoadAsset_Internal(texture, Il2CppType.Of <Texture2D>()).Cast <Texture2D>();

            texture2.hideFlags |= HideFlags.DontUnloadUnusedAsset | HideFlags.HideAndDontSave;
            return(texture2);
        }
        public PreloadedBundleContents(AssetBundle bundle)
        {
            StoredThingsParent = new GameObject("ModUiPreloadedBundleContents");
            Object.DontDestroyOnLoad(StoredThingsParent);
            StoredThingsParent.SetActive(false);

            GameObject Load(string str)
            {
                var objectFromBundle = bundle.LoadAsset_Internal(str, Il2CppType.Of <GameObject>()).Cast <GameObject>();
                var newObject        = Object.Instantiate(objectFromBundle, StoredThingsParent.transform);

                newObject.SetActive(true);
                return(newObject.NoUnload());
            }

            BigMenuExpando      = Load("Assets/ModUI/BigMenuSideExpando.prefab");
            SettingsMenuExpando = Load("Assets/ModUI/ModSettingsTopExpando.prefab");
            QuickMenuExpando    = Load("Assets/ModUI/QuickMenuExpandoRoot.prefab");

            QuickMenuButton = Load("Assets/ModUI/BigMenuSideButton.prefab");
            QuickMenuToggle = Load("Assets/ModUI/ToggleButton.prefab");

            SettingsCategory = Load("Assets/ModUI/CategoryElement.prefab");
            SettingsBool     = Load("Assets/ModUI/CheckboxGroup.prefab");
            SettingsText     = Load("Assets/ModUI/TextInputGroup.prefab");
        }
示例#8
0
        private static Texture2D LoadTexture(string Texture)
        { // https://github.com/KortyBoi/VRChat-TeleporterVR/blob/59bdfb200497db665621b519a9ff9c3d1c3f2bc8/Utils/ResourceManager.cs#L32
            Texture2D Texture2 = assetBundleIcons.LoadAsset_Internal(Texture, Il2CppType.Of <Texture2D>()).Cast <Texture2D>();

            Texture2.hideFlags |= HideFlags.DontUnloadUnusedAsset;
            //Texture2.hideFlags = HideFlags.HideAndDontSave;
            return(Texture2);
        }
示例#9
0
#pragma warning restore 414
        public override void OnApplicationStart()
        {
            using (var stream = Assembly.GetExecutingAssembly()
                                .GetManifestResourceStream("ActionMenuTestMod.customicons"))
                using (var tempStream = new MemoryStream((int)stream.Length))
                {
                    stream.CopyTo(tempStream);
                    iconsAssetBundle            = AssetBundle.LoadFromMemory_Internal(tempStream.ToArray(), 0);
                    iconsAssetBundle.hideFlags |= HideFlags.DontUnloadUnusedAsset;
                }

            radialIcon = iconsAssetBundle
                         .LoadAsset_Internal("Assets/Resources/Icons/sound-full.png", Il2CppType.Of <Texture2D>())
                         .Cast <Texture2D>();
            radialIcon.hideFlags |= HideFlags.DontUnloadUnusedAsset;
            toggleIcon            = iconsAssetBundle
                                    .LoadAsset_Internal("Assets/Resources/Icons/zero.png", Il2CppType.Of <Texture2D>()).Cast <Texture2D>();
            toggleIcon.hideFlags |= HideFlags.DontUnloadUnusedAsset;
            subMenuIcon           = iconsAssetBundle
                                    .LoadAsset_Internal("Assets/Resources/Icons/file-transfer.png", Il2CppType.Of <Texture2D>())
                                    .Cast <Texture2D>();
            subMenuIcon.hideFlags |= HideFlags.DontUnloadUnusedAsset;
            buttonIcon             = iconsAssetBundle
                                     .LoadAsset_Internal("Assets/Resources/Icons/cloud-data-download.png", Il2CppType.Of <Texture2D>())
                                     .Cast <Texture2D>();
            buttonIcon.hideFlags |= HideFlags.DontUnloadUnusedAsset;

            AMAPI.AddButtonPedalToMenu(ActionMenuPageType.Main, () => MelonLogger.Msg("Pressed Button"), "Button", buttonIcon);

            AMAPI.AddSubMenuToMenu(ActionMenuPageType.Options,
                                   delegate
            {
                MelonLogger.Msg("Sub Menu Opened");
                AMAPI.AddFourAxisPedalToSubMenu("Reposition cube X/Y", testVector, (v) => RePositionCubeXY(v), toggleIcon);
                AMAPI.AddFourAxisPedalToSubMenu("Reposition cube Z/Y", testVector, (v) => RePositionCubeZY(v), toggleIcon);
                AMAPI.AddFourAxisPedalToSubMenu("Reposition cube X/Z", testVector, (v) => RePositionCubeXZ(v), toggleIcon);
                AMAPI.AddRadialPedalToSubMenu(f => RotateCubeX(f), "X", x, radialIcon);
                AMAPI.AddRadialPedalToSubMenu(f => RotateCubeY(f), "Y", y, radialIcon);
                AMAPI.AddRadialPedalToSubMenu(f => RotateCubeZ(f), "Z", z, radialIcon);
                AMAPI.AddButtonPedalToSubMenu(CreateCube, "Spawn Cube", buttonIcon);
                AMAPI.AddButtonPedalToSubMenu(() => controllingGameObject.transform.localPosition = VRCPlayer.field_Internal_Static_VRCPlayer_0.transform.localPosition, "Tp Cube To Player", buttonIcon);
            },
                                   "Sub Menu",
                                   subMenuIcon
                                   );
        }
示例#10
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;
        }
示例#11
0
        internal ToyActionMenu()
        {
            try {
                //Adapted from knah's JoinNotifier mod found here: https://github.com/knah/VRCMods/blob/master/JoinNotifier/JoinNotifierMod.cs
                using (var stream = Assembly.GetExecutingAssembly()
                                    .GetManifestResourceStream("Vibrator_Controller.icons"))
                    using (var tempStream = new MemoryStream((int)stream.Length)) {
                        stream.CopyTo(tempStream);

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

                logo = iconsAssetBundle.LoadAsset_Internal("Assets/logo.png", Il2CppType.Of <Texture2D>())
                       .Cast <Texture2D>();
                logo.hideFlags |= HideFlags.DontUnloadUnusedAsset;

                foreach (string toy_name in available_toys)
                {
                    var logo = iconsAssetBundle
                               .LoadAsset_Internal($"Assets/{toy_name.ToLower()}-x64.png", Il2CppType.Of <Texture2D>())
                               .Cast <Texture2D>();
                    logo.hideFlags |= HideFlags.DontUnloadUnusedAsset;
                    toy_icons.Add(toy_name, logo);
                }

                foreach (int purcent in available_purcent)
                {
                    var logo = iconsAssetBundle.LoadAsset_Internal($"Assets/{purcent}.png", Il2CppType.Of <Texture2D>())
                               .Cast <Texture2D>();
                    logo.hideFlags |= HideFlags.DontUnloadUnusedAsset;
                    purcent_icons.Add(purcent, logo);
                }
            } catch (Exception e) {
                MelonLogger.Warning(
                    "Consider checking for newer version as mod possibly no longer working, Exception occured OnAppStart(): " +
                    e.Message);
            }

            // actionMenuApi = new ActionMenuAPI();

            SetupButtons();
        }
示例#12
0
        public override void OnApplicationStart()
        {
            ExpansionKitApi.GetExpandedMenu(ExpandedMenu.QuickMenu).AddSimpleButton("Toggle Trigger ESP", OnESPToggle);

            category       = MelonPreferences.CreateCategory("TriggerESP", "TriggerESP Config");
            randomESPColor = category.CreateEntry(nameof(randomESPColor), false, "Enable/Disable random color of ESP");
            espColorR      = category.CreateEntry(nameof(espColorR), 0f, "The red color of the ESP. Will be ignored if random ESP color is on");
            espColorG      = category.CreateEntry(nameof(espColorG), 255f, "The green of the ESP. Will be ignored if random ESP color is on");
            espColorB      = category.CreateEntry(nameof(espColorB), 0f, "The blue color of the ESP. Will be ignored if random ESP color is on");

            foreach (MelonPreferences_Entry entry in category.Entries)
            {
                entry.OnValueChangedUntyped += TriggerESPComponent.OnColorPrefChanged;
            }

            shouldUseOutline = category.CreateEntry(nameof(shouldUseOutline), false, "Enable = use outline shader/Disable = use wireframe shader");
            shouldUseOutline.OnValueChanged += TriggerESPComponent.OnShouldUseOutlineChanged;

            wireframeWidth = category.CreateEntry(nameof(wireframeWidth), 0.1f, "The width of the wireframe");
            wireframeWidth.OnValueChangedUntyped += TriggerESPComponent.OnThicknessPrefChanged;
            outlineStrength = category.CreateEntry(nameof(outlineStrength), 0.9f, "The strength of the outline");
            outlineStrength.OnValueChangedUntyped += TriggerESPComponent.OnThicknessPrefChanged;

            sphere  = Resources.Load("PrimitiveMeshes/sphere").Cast <Mesh>();
            cube    = Resources.Load("PrimitiveMeshes/cube").Cast <Mesh>();
            capsule = Resources.Load("PrimitiveMeshes/capsule").Cast <Mesh>();

            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("TriggerESP.triggerespshader.assetbundle"))
            {
                using (var memoryStream = new MemoryStream((int)stream.Length))
                {
                    stream.CopyTo(memoryStream);
                    AssetBundle assetBundle = AssetBundle.LoadFromMemory_Internal(memoryStream.ToArray(), 0);
                    wireframeShader            = assetBundle.LoadAsset_Internal("Assets/Shaders/Wireframe.shader", Il2CppType.Of <Shader>()).Cast <Shader>();
                    wireframeShader.hideFlags |= HideFlags.DontUnloadUnusedAsset;
                    outlineShader              = assetBundle.LoadAsset_Internal("Assets/Shaders/Outline.shader", Il2CppType.Of <Shader>()).Cast <Shader>();
                    outlineShader.hideFlags   |= HideFlags.DontUnloadUnusedAsset;
                }
            }

            VRCUtils.OnEmmWorldCheckCompleted += OnEmmWorldCheckCompleted;
        }
        public void OnUiManagerInit()
        {
            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("OldLoadingScreen.loading.assetbundle"))
                using (var tempStream = new MemoryStream((int)stream.Length))
                {
                    stream.CopyTo(tempStream);

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

            loadScreenPrefab            = assets.LoadAsset_Internal("Assets/Bundle/LoadingBackground.prefab", Il2CppType.Of <GameObject>()).Cast <GameObject>();
            loadScreenPrefab.hideFlags |= HideFlags.DontUnloadUnusedAsset;

            loginPrefab            = assets.LoadAsset_Internal("Assets/Bundle/Login.prefab", Il2CppType.Of <GameObject>()).Cast <GameObject>();
            loginPrefab.hideFlags |= HideFlags.DontUnloadUnusedAsset;

            OldLoadingScreenSettings.RegisterSettings();
            CreateGameObjects();
        }
示例#14
0
        public static void LoadAssetBundle()
        {
            // Stolen from UIExpansionKit (https://github.com/knah/VRCMods/blob/master/UIExpansionKit) #Imnotaskidiswear
            MelonLogger.Msg("Loading List UI...");
            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("PlayerList.playerlistmod.assetbundle"))
            {
                using (var memoryStream = new MemoryStream((int)stream.Length))
                {
                    stream.CopyTo(memoryStream);
                    AssetBundle assetBundle = AssetBundle.LoadFromMemory_Internal(memoryStream.ToArray(), 0);
                    assetBundle.hideFlags |= HideFlags.DontUnloadUnusedAsset;
                    playerList             = UnityEngine.Object.Instantiate(assetBundle.LoadAsset_Internal("Assets/Prefabs/PlayerListMod.prefab", Il2CppType.Of <GameObject>()).Cast <GameObject>(), Constants.quickMenu.transform);
                    menuButton             = UnityEngine.Object.Instantiate(assetBundle.LoadAsset_Internal("Assets/Prefabs/PlayerListMenuButton.prefab", Il2CppType.Of <GameObject>()).Cast <GameObject>(), Constants.shortcutMenu.transform);
                }
            }
            menuButton.SetLayerRecursive(12);
            menuButton.transform.localPosition = Converters.ConvertToUnityUnits(new Vector3(4, -1));
            menuButton.GetComponent <RectTransform>().pivot = new Vector2(0, 0);

            UiTooltip tooltip = menuButton.AddComponent <UiTooltip>();

            tooltip.field_Public_String_0 = "Open PlayerList menu";
            tooltip.field_Public_String_1 = "Open PlayerList menu";

            playerList.SetLayerRecursive(12);
            playerListRect = playerList.GetComponent <RectTransform>();
            playerListRect.anchoredPosition = Config.PlayerListPosition;
            playerListRect.localPosition    = new Vector3(playerListRect.localPosition.x, playerListRect.localPosition.y, 25); // Do this or else it looks off for whatever reason
            playerList.SetActive(false);

            MenuManager.shouldStayHidden = !Config.enabledOnStart.Value;
            _fontSize          = Config.fontSize.Value;
            MenuButtonPosition = Config.MenuButtonPosition;

            Constants.playerListLayout  = playerList.transform.Find("PlayerList Viewport/PlayerList").GetComponent <VerticalLayoutGroup>();
            Constants.generalInfoLayout = playerList.transform.Find("GeneralInfo Viewport/GeneralInfo").GetComponent <VerticalLayoutGroup>();

            EnableDisableListener playerListListener = playerList.AddComponent <EnableDisableListener>();

            playerListListener.OnEnableEvent += EntryManager.RefreshAllEntries;
        }
        static VibratorController()
        {
            //Clean up old file, call as earlöy as possible so file isnt loaded by VibeGoBrr
            if (File.Exists(Environment.CurrentDirectory + @"\buttplug_rs_ffi.dll"))
            {
                File.Delete(Environment.CurrentDirectory + @"\buttplug_rs_ffi.dll");
            }
            try
            {
                //Adapted from knah's JoinNotifier mod found here: https://github.com/knah/VRCMods/blob/master/JoinNotifier/JoinNotifierMod.cs
                using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Vibrator_Controller.icons"))
                    using (var tempStream = new MemoryStream((int)stream.Length))
                    {
                        stream.CopyTo(tempStream);
                        iconsAssetBundle            = AssetBundle.LoadFromMemory_Internal(tempStream.ToArray(), 0);
                        iconsAssetBundle.hideFlags |= HideFlags.DontUnloadUnusedAsset;
                    }

                logo            = iconsAssetBundle.LoadAsset_Internal("Assets/logo.png", Il2CppType.Of <Texture2D>()).Cast <Texture2D>();
                logo.hideFlags |= HideFlags.DontUnloadUnusedAsset;

                foreach (string toy_name in available_toys)
                {
                    var logo = iconsAssetBundle.LoadAsset_Internal($"Assets/{toy_name.ToLower()}-x64.png", Il2CppType.Of <Texture2D>()).Cast <Texture2D>();
                    logo.hideFlags |= HideFlags.DontUnloadUnusedAsset;
                    toy_icons.Add(toy_name, logo);
                }

                foreach (int purcent in available_purcent)
                {
                    var logo = iconsAssetBundle.LoadAsset_Internal($"Assets/{purcent}.png", Il2CppType.Of <Texture2D>()).Cast <Texture2D>();
                    logo.hideFlags |= HideFlags.DontUnloadUnusedAsset;
                    purcent_icons.Add(purcent, logo);
                }
            }
            catch (Exception e)
            {
                MelonLogger.Warning("Consider checking for newer version as mod possibly no longer working, Exception occured OnAppStart(): " + e.Message);
            }
        }
示例#16
0
        public static void Load()
        {
            T NoUnload <T>(T obj) where T : Object
            {
                obj.hideFlags |= HideFlags.DontUnloadUnusedAsset;
                return(obj);
            }

            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("FavCat.extraui"))
                using (var tempStream = new MemoryStream((int)stream.Length))
                {
                    stream.CopyTo(tempStream);

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

            var screensRoot = GameObject.Find("UserInterface/MenuContent/Screens").transform;

            ListPrefab = Object.Instantiate(myAssetBundle.LoadAsset_Internal("Assets/ExtraUi/CustomUiList.prefab", Il2CppType.Of <GameObject>()).Cast <GameObject>(), screensRoot, false);
            ListPrefab.SetActive(false);

            var pickerPoolRoot = new GameObject("CustomPickerPool");

            pickerPoolRoot.transform.SetParent(screensRoot);

            var pickerPrefab = Object.Instantiate(myAssetBundle.LoadAsset_Internal("Assets/ExtraUi/CustomPicker.prefab", Il2CppType.Of <GameObject>()).Cast <GameObject>(), screensRoot, false);

            pickerPrefab.SetActive(false);
            PickerPrefab = pickerPrefab;

            IconPC    = NoUnload(myAssetBundle.LoadAsset("Assets/ExtraUI/EUI-IconPC.png", Il2CppType.Of <Sprite>()).Cast <Sprite>());
            IconQuest = NoUnload(myAssetBundle.LoadAsset("Assets/ExtraUI/EUI-IconQ.png", Il2CppType.Of <Sprite>()).Cast <Sprite>());
            IconUni   = NoUnload(myAssetBundle.LoadAsset("Assets/ExtraUI/EUI-IconU.png", Il2CppType.Of <Sprite>()).Cast <Sprite>());

            PreviewLoading = NoUnload(myAssetBundle.LoadAsset("Assets/ExtraUI/EUI-LoadingPreview.png", Il2CppType.Of <Sprite>()).Cast <Sprite>());
            PreviewError   = NoUnload(myAssetBundle.LoadAsset("Assets/ExtraUI/EUI-ErrorPreview.png", Il2CppType.Of <Sprite>()).Cast <Sprite>());

            new PickerPool(pickerPrefab, pickerPoolRoot);
        }
示例#17
0
文件: Main.cs 项目: Nirv-git/VRMods
        private static Sprite LoadTextureSprite(string Texture)
        { // https://github.com/KortyBoi/VRChat-TeleporterVR/blob/59bdfb200497db665621b519a9ff9c3d1c3f2bc8/Utils/ResourceManager.cs#L32
            Texture2D Texture2 = assetBundleIcons.LoadAsset_Internal(Texture, Il2CppType.Of <Texture2D>()).Cast <Texture2D>();

            Texture2.hideFlags |= HideFlags.DontUnloadUnusedAsset;

            var rec    = new Rect(0.0f, 0.0f, Texture2.width, Texture2.height);
            var piv    = new Vector2(.5f, 5f);
            var border = Vector4.zero;
            var s      = Sprite.CreateSprite_Injected(Texture2, ref rec, ref piv, 100.0f, 0, SpriteMeshType.Tight, ref border, false);

            s.hideFlags |= HideFlags.DontUnloadUnusedAsset;
            return(s);
        }
示例#18
0
        public static void AssetBundle()
        {
            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("TreeSpace.treespace")) //String is MainNamespace.assetbundlename
                using (var tempStream = new MemoryStream((int)stream.Length))
                {
                    stream.CopyTo(tempStream);

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

            TreeSprite            = TreeAssetBundle.LoadAsset_Internal("Assets/Tree.png", Il2CppType.Of <Sprite>()).Cast <Sprite>(); //String is the location/name of the asset in the assetbundle
            TreeSprite.hideFlags |= HideFlags.DontUnloadUnusedAsset;
        }
示例#19
0
        private void LoadAssets()
        {
            using (var assetStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("BTKSASelfPortrait.spasset"))
            {
                Log("Loaded Embedded resource", true);
                using (var tempStream = new MemoryStream((int)assetStream.Length))
                {
                    assetStream.CopyTo(tempStream);

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

            if (_spBundle != null)
            {
                _cameraPrefab            = _spBundle.LoadAsset_Internal("SPCamera", Il2CppType.Of <GameObject>()).Cast <GameObject>();
                _cameraPrefab.hideFlags |= HideFlags.DontUnloadUnusedAsset;
                _uiPrefab            = _spBundle.LoadAsset_Internal("RTOutput", Il2CppType.Of <GameObject>()).Cast <GameObject>();
                _uiPrefab.hideFlags |= HideFlags.DontUnloadUnusedAsset;
            }

            Log("Loaded Assets Successfully!", true);
        }
示例#20
0
 /// <summary>
 /// Loads an asset without triggering the AssetLoader patches
 /// </summary>
 public static UnityEngine.Object LoadAsset(AssetBundle assetBundle, string name, Type type)
 {
     if (assetBundle is null)
     {
         throw new System.NullReferenceException("The asset bundle cannot be null.");
     }
     if (name is null)
     {
         throw new System.NullReferenceException("The input asset name cannot be null.");
     }
     if (name.Length == 0)
     {
         throw new System.ArgumentException("The input asset name cannot be empty.");
     }
     if (type is null)
     {
         throw new System.NullReferenceException("The input type cannot be null.");
     }
     return(assetBundle.LoadAsset_Internal(name, type));
 }
示例#21
0
        private void loadAssets()
        {//https://github.com/ddakebono/BTKSASelfPortrait/blob/master/BTKSASelfPortrait.cs
            using (var assetStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("FLuxMod.flux"))
            {
                using (var tempStream = new MemoryStream((int)assetStream.Length))
                {
                    assetStream.CopyTo(tempStream);
                    assetBundle            = AssetBundle.LoadFromMemory_Internal(tempStream.ToArray(), 0);
                    assetBundle.hideFlags |= HideFlags.DontUnloadUnusedAsset;
                }
            }

            if (assetBundle != null)
            {
                fluxPrefab            = assetBundle.LoadAsset_Internal("FluxSphere", Il2CppType.Of <GameObject>()).Cast <GameObject>();
                fluxPrefab.hideFlags |= HideFlags.DontUnloadUnusedAsset;
            }
            else
            {
                Logger.Error("Bundle was null");
            }
        }
示例#22
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;
        }
示例#23
0
        public static void LoadAssetBundle()
        {
            // Stolen from UIExpansionKit (https://github.com/knah/VRCMods/blob/master/UIExpansionKit) #Imnotaskidiswear
            MelonLogger.Msg("Loading UI...");
            ClassInjector.RegisterTypeInIl2Cpp <AskToPortalPromptPage>();
            ClassInjector.RegisterTypeInIl2Cpp <AskToPortalPageDetailed>();
            ClassInjector.RegisterTypeInIl2Cpp <AskToPortalPageBasic>();
            GameObject screens = GameObject.Find("UserInterface/MenuContent/Screens");

            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("AskToPortal.asktoportalui.assetbundle"))
            {
                using (var memoryStream = new MemoryStream((int)stream.Length))
                {
                    stream.CopyTo(memoryStream);
                    AssetBundle assetBundle = AssetBundle.LoadFromMemory_Internal(memoryStream.ToArray(), 0);
                    detailedMenu = Object.Instantiate(assetBundle.LoadAsset_Internal("Assets/Prefabs/AskToPortalDetailed.prefab", Il2CppType.Of <GameObject>()).Cast <GameObject>(), screens.transform);
                    basicMenu    = Object.Instantiate(assetBundle.LoadAsset_Internal("Assets/Prefabs/AskToPortalBasic.prefab", Il2CppType.Of <GameObject>()).Cast <GameObject>(), screens.transform);
                }
            }

            detailedMenu.SetActive(false);
            detailedMenuComponent = detailedMenu.AddComponent <AskToPortalPageDetailed>();

            basicMenu.SetActive(false);
            basicMenuComponent = basicMenu.AddComponent <AskToPortalPageBasic>();

            dosisRegular  = GameObject.Find("UserInterface/MenuContent/Screens/Settings/VolumePanel/VolumeUi/Label").GetComponent <Text>().font;
            dosisSemiBold = GameObject.Find("UserInterface/MenuContent/Screens/Settings/VolumePanel/TitleText (1)").GetComponent <Text>().font;
            bifrost       = GameObject.Find("UserInterface/MenuContent/Screens/Settings/Footer/Logout").GetComponent <Image>().sprite;

            AddFontAndImages(detailedMenu.transform);
            AddFontAndImages(basicMenu.transform);

            detailedMenuComponent.Init();
            basicMenuComponent.Init();

            vrcUiTabsParent = GameObject.Find("UserInterface/MenuContent/Backdrop/Header/Tabs");
            tabsParent      = Object.Instantiate(vrcUiTabsParent, vrcUiTabsParent.transform.parent);
            Transform tabsContent = tabsParent.transform.GetChild(0).GetChild(0);

            for (int i = tabsContent.childCount - 1; i >= 0; i--)
            {
                Object.DestroyImmediate(tabsContent.GetChild(i).gameObject);
            }
            tabsParent.name = "AskToPortalTabs";
            tabsContent.GetComponent <HorizontalLayoutGroup>().childAlignment = TextAnchor.MiddleCenter;
            UiManager.OnBigMenuClosed += new System.Action(() => { tabsParent.SetActive(false); vrcUiTabsParent.SetActive(true); });

            GameObject basicTabGameObject = Object.Instantiate(GameObject.Find("UserInterface/MenuContent/Backdrop/Header/Tabs/ViewPort/Content/WorldsPageTab"), tabsParent.transform.Find("ViewPort/Content"));

            basicTabGameObject.name = "BasicPageTab";
            basicTabGameObject.transform.Find("Button/Text").GetComponent <Text>().text = "Basic";
            basicMenuTab = basicTabGameObject.GetComponent <VRCUiPageTab>();
            basicMenuTab.field_Public_String_1 = "UserInterface/MenuContent/Screens/AskToPortalBasic(Clone)";

            GameObject detailedTabGameObject = Object.Instantiate(GameObject.Find("UserInterface/MenuContent/Backdrop/Header/Tabs/ViewPort/Content/WorldsPageTab"), tabsParent.transform.Find("ViewPort/Content"));

            detailedTabGameObject.name = "DetailedPageTab";
            detailedTabGameObject.transform.Find("Button/Text").GetComponent <Text>().text = "Detailed";
            detailedMenuTab = detailedTabGameObject.GetComponent <VRCUiPageTab>();
            detailedMenuTab.field_Public_String_1 = "UserInterface/MenuContent/Screens/AskToPortalDetailed(Clone)";

            AskToPortalMod.Instance.HarmonyInstance.Patch(typeof(VRCUiPageTab).GetMethod("ShowPage"), new HarmonyMethod(typeof(MenuManager).GetMethod(nameof(OnTabShowPage), BindingFlags.NonPublic | BindingFlags.Static)));
        }