Created
March 25, 2014 11:37
-
-
Save baba-s/9760002 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| /// <summary> | |
| /// Resourcesクラスに関する汎用クラス | |
| /// </summary> | |
| public static partial class ResourcesCommon | |
| { | |
| /// <summary> | |
| /// リソースを読み込みます | |
| /// </summary> | |
| /// <typeparam name="T">リソースの型</typeparam> | |
| /// <param name="path">リソースのファイルパス</param> | |
| /// <returns>読み込んだリソース</returns> | |
| public static T Load<T>(string path) where T : Object | |
| { | |
| return Resources.Load(path, typeof(T)) as T; | |
| } | |
| /// <summary> | |
| /// テクスチャを読み込みます | |
| /// </summary> | |
| /// <param name="path">テクスチャのファイルパス</param> | |
| /// <returns>読み込んだテクスチャ</returns> | |
| public static Texture LoadTexture(string path) | |
| { | |
| return Load<Texture>(path); | |
| } | |
| /// <summary> | |
| /// プレハブを読み込みます | |
| /// </summary> | |
| /// <param name="path">プレハブのファイルパス</param> | |
| /// <returns>読み込んだプレハブ</returns> | |
| public static GameObject LoadPrefab(string path) | |
| { | |
| return Load<GameObject>(path); | |
| } | |
| /// <summary> | |
| /// マテリアルを読み込みます | |
| /// </summary> | |
| /// <param name="path">マテリアルのファイルパス</param> | |
| /// <returns>読み込んだマテリアル</returns> | |
| public static Material LoadMaterial(string path) | |
| { | |
| return Load<Material>(path); | |
| } | |
| /// <summary> | |
| /// テキストアセットを読み込みます | |
| /// </summary> | |
| /// <param name="path">テキストアセットのファイルパス</param> | |
| /// <returns>読み込んだテキストアセット</returns> | |
| public static TextAsset LoadTextAsset(string path) | |
| { | |
| return Load<TextAsset>(path); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment