Esempio n. 1
0
        /// <summary>
        /// Loads AssetBundles and populates the platforms array with CustomPlatform objects
        /// </summary>
        public CustomPlatform[] CreateAllPlatforms(Transform parent)
        {
            string customPlatformsFolderPath = Path.Combine(Environment.CurrentDirectory, customFolder);

            // Create the CustomPlatforms folder if it doesn't already exist
            if (!Directory.Exists(customPlatformsFolderPath))
            {
                Directory.CreateDirectory(customPlatformsFolderPath);
            }

            // Find AssetBundles in our CustomPlatforms directory
            string[] allBundlePaths = Directory.GetFiles(customPlatformsFolderPath, "*.plat");

            platforms   = new List <CustomPlatform>();
            bundlePaths = new List <string>();

            // Create a dummy CustomPlatform for the original platform
            CustomPlatform defaultPlatform = new GameObject("Default Platform").AddComponent <CustomPlatform>();

            defaultPlatform.transform.parent = parent;
            defaultPlatform.platName         = "Default Environment";
            defaultPlatform.platAuthor       = "Beat Saber";
            Texture2D texture = Resources.FindObjectsOfTypeAll <Texture2D>().First(x => x.name == "LvlInsaneCover");

            defaultPlatform.icon = Sprite.Create(texture, new Rect(0f, 0f, texture.width, texture.height), new Vector2(0.5f, 0.5f));
            platforms.Add(defaultPlatform);
            bundlePaths.Add("");
            // Populate the platforms array
            Plugin.Log("[START OF PLATFORM LOADING SPAM]-------------------------------------");
            int j = 0;

            for (int i = 0; i < allBundlePaths.Length; i++)
            {
                j++;
                CustomPlatform newPlatform = LoadPlatformBundle(allBundlePaths[i], parent);
            }
            Plugin.Log("[END OF PLATFORM LOADING SPAM]---------------------------------------");
            // Replace materials for all renderers
            MaterialSwapper.ReplaceAllMaterials();

            return(platforms.ToArray());
        }
Esempio n. 2
0
        internal static IEnumerator <WaitForEndOfFrame> ReplaceAllMaterialsAfterOneFrame()
        {
            yield return(new WaitForEndOfFrame());

            MaterialSwapper.ReplaceAllMaterials();
        }