Skip to content

Commit 5b2990b

Browse files
2 parents 46192ac + 1a46dd8 commit 5b2990b

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public abstract class Controller {
136136
/// Check whether this controller has a service.
137137
public bool HasService<S> () where S : IService, new();
138138
/// Gets an asset from this controller.
139-
public UnityEngine.Object GetAsset (string name);
139+
public AssetType GetAsset<AssetType> (string name);
140140
/// Check whether this controller has an asset.
141141
public bool HasAsset (string name);
142142
}

Runtime/Controller.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ public System.Object GetService (System.Type typeOf) {
216216
}
217217

218218
/// Gets an asset from this controller.
219-
public UnityEngine.Object GetAsset (string name) {
219+
public AssetType GetAsset<AssetType> (string name) where AssetType : UnityEngine.Object {
220220
for (var _i = 0; _i < this.assets.Length; _i++)
221221
if (this.assets[_i].name == name)
222-
return this.assets[_i];
222+
return this.assets[_i] as AssetType;
223223
throw new System.Exception ("Unable to get asset, it was not added to the controller");
224224
}
225225

Runtime/EntityComponent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public UnityEngine.Object AddAsset (UnityEngine.Object asset) =>
5555

5656
/// Loads a asset from the controller and adds it as an asset to the entity.
5757
public UnityEngine.Object AddAsset (string name) =>
58-
this.AddAsset (Controller.Instance.GetAsset (name));
58+
this.AddAsset (Controller.Instance.GetAsset<UnityEngine.Object> (name));
5959

6060
/// Sets the position of an entity.
6161
public void SetPosition (float x, float y, float z = 0) =>

0 commit comments

Comments
 (0)