Пример #1
0
        /// <summary>
        /// Adds a new resource and its location to the manifest.
        /// </summary>
        /// <param name="resource"></param>
        /// <param name="path"></param>
        public bool AddResource(UnityEngine.Object resource, string path)
        {
            if (Application.isPlaying)
            {
                throw new UnityException("ResourceManifest should only have new resourceses added to it during edit-time.");
            }

            if (resource == null || path == null)
            {
                return(false);
            }
            Type resType = resource.GetType();

            if (resType == null)
            {
                return(false);
            }

            InitMaps();
            bool flag = false;

            //APPEND NEW TYPES HERE
            if (resType == typeof(AnimationClip))
            {
                flag = AnimationClips.Add(resource, path);
            }
            else if (resType == typeof(AudioClip))
            {
                flag = AudioClips.Add(resource, path);
            }
            else if (resType == typeof(RuntimeAnimatorController))
            {
                flag = AnimatorControllers.Add(resource, path);
            }
            else if (resType.IsSubclassOf(typeof(RuntimeAnimatorController)))
            {
                flag = AnimatorControllers.Add(resource, path);
            }
            else if (resType == typeof(Font))
            {
                flag = Fonts.Add(resource, path);
            }
            else if (resType == typeof(GameObject))
            {
                flag = GameObjects.Add(resource, path);
            }
            else if (resType == typeof(Material))
            {
                flag = Materials.Add(resource, path);
            }
            else if (resType == typeof(Mesh))
            {
                flag = Meshes.Add(resource, path);
            }
            else if (resType == typeof(PhysicMaterial))
            {
                flag = PhysicMaterials.Add(resource, path);
            }
            else if (resType == typeof(PhysicsMaterial2D))
            {
                flag = PhysicsMaterial2Ds.Add(resource, path);
            }
            else if (resType == typeof(Shader))
            {
                flag = Shaders.Add(resource, path);
            }
            else if (resType == typeof(Sprite))
            {
                flag = Sprites.Add(resource, path);
            }
            else if (resType == typeof(Texture2D))
            {
                flag = Texture2Ds.Add(resource, path);
            }
            else if (resType == typeof(Texture3D))
            {
                flag = Texture3Ds.Add(resource, path);
            }
            else
            {
                return(false);
            }

            return(flag);
        }