예제 #1
0
        public Material GetMaterial(string spriteName)
        {
            string assetPath = null;

            sprites.TryGetValue(spriteName, out assetPath);
            if (assetPath == null)
            {
                return(null);
            }

            assetPath = assetPath.Replace("Images", "Images_Mask");
            assetPath = "assets/" + assetPath + ".mat";
            assetPath = assetPath.ToLower();
            Material material = null;

#if UNITY_EDITOR
            material = UnityEditor.AssetDatabase.LoadAssetAtPath <Material>(assetPath);
#else
            string bundlePath = null;

            materials.TryGetValue(assetPath, out bundlePath);

            if (bundlePath != null)
            {
                var assetBundle = BundleHelper.Load(bundlePath, -1);
                if (assetBundle != null)
                {
                    material = assetBundle.LoadAsset <Material>(assetPath);
                }
            }
#endif


            return(material);
        }
예제 #2
0
        public Cubemap GetWaterCubemap(string cubemapPath)
        {
            string bundlePath = null;

            water_cubemaps.TryGetValue(cubemapPath, out bundlePath);
            Cubemap cubemap = null;

            if (bundlePath != null)
            {
                var assetBundle = BundleHelper.Load(bundlePath, -1);
                if (assetBundle != null)
                {
                    cubemap = assetBundle.LoadAsset <Cubemap>(cubemapPath);
                }
            }
            return(cubemap);
        }
예제 #3
0
        public Sprite GetSprite(string spriteName)
        {
            string assetPath = null;

            sprites.TryGetValue(spriteName, out assetPath);
            if (assetPath == null)
            {
                return(null);
            }

            assetPath = "assets/" + assetPath + ".asset";
            assetPath = assetPath.ToLower();
            SpriteAsset spriteAsset = null;

#if UNITY_EDITOR
            spriteAsset = UnityEditor.AssetDatabase.LoadAssetAtPath <SpriteAsset>(assetPath);
#else
            string bundlePath = null;

            images.TryGetValue(assetPath, out bundlePath);

            if (bundlePath != null)
            {
                var assetBundle = BundleHelper.Load(bundlePath, -1);
                if (assetBundle != null)
                {
                    spriteAsset = assetBundle.LoadAsset <SpriteAsset>(assetPath);
                }
            }
#endif
            if (spriteAsset != null)
            {
                return(spriteAsset.GetSprite(spriteName));
            }

            return(null);
        }