2using System.Collections;
3using System.Collections.Generic;
17 public static class pb_BuiltinResource
19 const string REQUIRED_PATH =
"Required/";
22 public const string mat_UnlitVertexColor =
"Material/UnlitVertexColor";
24 public const string mat_UnlitVertexColorWavy =
"Material/UnlitVertexColorWavy";
26 public const string mat_Wireframe =
"Material/Wireframe";
28 public const string mat_Highlight =
"Material/Highlight";
30 public const string mat_HandleOpaque =
"Handles/Material/HandleOpaqueMaterial";
32 public const string mat_RotateHandle =
"Handles/Material/HandleRotateMaterial";
34 public const string mat_HandleTransparent =
"Handles/Material/HandleTransparentMaterial";
36 public const string mat_LightGizmo =
"Gizmos/Light";
38 public const string mat_CameraGizmo =
"Gizmos/Camera";
40 public const string mat_WeaponPickupGizmo =
"Gizmos/WeaponPickup";
42 public const string mat_AmmoPickupGizmo =
"Gizmos/AmmoPickup";
44 public const string mat_HealthPickupGizmo =
"Gizmos/HealthPickup";
46 public const string mat_PlayerSpawnGizmo =
"Gizmos/PlayerSpawn";
48 public const string mat_EnemySpawnGizmo =
"Gizmos/EnemySpawn";
51 public const string mesh_Cone =
"Handles/Mesh/ConeMesh.asset";
54 public const string img_WhiteTexture =
"Image/White";
56 static Dictionary<string,
UnityEngine.Object> pool =
null;
58 static pb_BuiltinResource()
60 pool =
new Dictionary<string,
UnityEngine.Object>();
66 public static void EmptyPool()
68 foreach(KeyValuePair<string, UnityEngine.Object> kvp
in pool)
69 pb_ObjectUtility.Destroy(kvp.Value);
79 public static Material GetMaterial(
string materialPath)
81 return LoadResource<Material>(materialPath);
87 public static T LoadResource<T>(
string path) where T :
UnityEngine.Object
91 if(pool.TryGetValue(path, out val))
93 if( val !=
null && val is T )
97 T obj = Resources.Load<T>(REQUIRED_PATH + path);
101 Debug.LogWarning(
"Built-in resource \"" + (REQUIRED_PATH + path) +
"\" not found!");
105 T instance = GameObject.Instantiate(obj);
106 pool.Add(path, instance);
117 public static T GetResource<T>(
string path) where T :
UnityEngine.Object
121 if(pool.TryGetValue(path, out val))
123 if( val !=
null && val is T )
127 T obj = Resources.Load<T>(REQUIRED_PATH + path);
131 Debug.LogWarning(
"Built-in resource \"" + (REQUIRED_PATH + path) +
"\" not found!");