예제 #1
0
        //同期ロード処理(Resourcesから)
        void LoadResource(string loadPath, Action onComplete, Action onFailed)
        {
            loadPath = FilePathUtil.GetPathWithoutExtension(loadPath);

            UnityEngine.Object asset = Resources.Load(loadPath, GetResourceType());
            LoadAsset(asset, onComplete, onFailed);
        }
예제 #2
0
        //以下、自作のファイルマネージャーから、オブジェクトの参照を行う
        void InitFromCustomFileManager()
        {
            //Resources.Loadの部分を、自作のファイルマネージャーからのオブジェクト参照に切り替える
            string path = FilePathUtil.GetPathWithoutExtension(FileInfo.FileName);

            switch (FileType)
            {
            case AssetFileType.Text:                            //テキスト
                Text = Resources.Load <TextAsset>(path);
                break;

            case AssetFileType.Texture:                         //テクスチャ
                Texture = Resources.Load <Texture2D>(path);
                break;

            case AssetFileType.Sound:                           //サウンド
                Sound = Resources.Load <AudioClip>(path);
                break;

            case AssetFileType.UnityObject:                         //Unityオブジェクト(プレハブとか)
                this.UnityObject = Resources.Load(path);
                break;

            default:
                break;
            }
        }
예제 #3
0
        //非同期ロード(Resourcesから)
        IEnumerator LoadResourceAsync(string loadPath, Action onComplete, Action onFailed)
        {
            loadPath = FilePathUtil.GetPathWithoutExtension(loadPath);
            ResourceRequest request = Resources.LoadAsync(loadPath, GetResourceType());

            while (!request.isDone)
            {
                yield return(null);
            }
            LoadAsset(request.asset, onComplete, onFailed);
        }
예제 #4
0
        IEnumerator CoPlayMovieFromResources(string path, bool isLoop)
        {
            path = FilePathUtil.GetPathWithoutExtension(path);
            MovieTexture movieTexture = Resources.Load <MovieTexture>(path);

            if (movieTexture == null)
            {
                Debug.LogError("Movie canot load from " + path);
                yield break;
            }
            yield return(StartCoroutine(CoPlayMovieTexture(movieTexture, isLoop)));
        }
예제 #5
0
 internal TextureInfo(Texture2D texture, DicingTextures target)
 {
     if (target.OverrideTextureImporter)
     {
         string path = AssetDatabase.GetAssetPath(texture);
         OverrideTextureImportSetting(path, target);
     }
     this.texture = texture;
     this.name    = FilePathUtil.RemoveDirectory(AssetDatabase.GetAssetPath(texture), AssetDatabase.GetAssetPath(target.InputDir));
     this.name    = FilePathUtil.GetPathWithoutExtension(this.name);
     MakeCells(target);
 }
예제 #6
0
        //ロード処理(Resourcesから)
        void LoadResource(string loadPath)
        {
            loadPath = FilePathUtil.GetPathWithoutExtension(loadPath);
            TextAsset textAsset;

            switch (FileType)
            {
            case AssetFileType.Text:                                    //テキスト
                textAsset = Resources.Load(loadPath, typeof(TextAsset)) as TextAsset;
                if (null != textAsset)
                {
                    text = textAsset.text;
                    Resources.UnloadAsset(textAsset);
                }
                else
                {
                    SetLoadError("LoadResource Error");
                }
                break;

            case AssetFileType.Bytes:                                   //バイナリ
                textAsset = Resources.Load(loadPath, typeof(TextAsset)) as TextAsset;
                if (null != textAsset)
                {
                    bytes = textAsset.bytes;
                    Resources.UnloadAsset(textAsset);
                }
                else
                {
                    SetLoadError("LoadResource Error");
                }
                break;

            case AssetFileType.Texture:                                 //テクスチャ
                texture = Resources.Load(loadPath, typeof(Texture2D)) as Texture2D;
                if (null == texture)
                {
                    SetLoadError("LoadResource Error");
                }
                break;

            case AssetFileType.Sound:                                   //サウンド
                sound = Resources.Load(loadPath, typeof(AudioClip)) as AudioClip;
                if (null == sound)
                {
                    SetLoadError("LoadResource Error");
                }
                break;

            case AssetFileType.Csv:                                     //CSV
                textAsset = Resources.Load(loadPath, typeof(TextAsset)) as TextAsset;
                if (null != textAsset)
                {
                    csv = new StringGrid(loadPath, FileInfo.IsTsv ? CsvType.Tsv : CsvType.Csv, textAsset.text);
                    Resources.UnloadAsset(textAsset);
                }
                else
                {
                    SetLoadError("LoadResource Error");
                }
                break;

            case AssetFileType.UnityObject:                             //Unityオブジェクト(プレハブとか)
                unityObject = Resources.Load(loadPath);
                if (null == unityObject)
                {
                    SetLoadError("LoadResource Error");
                }
                break;

            default:
                break;
            }
        }