Skip to content

Commit

Permalink
Use normal add when generic is same class
Browse files Browse the repository at this point in the history
  • Loading branch information
Ven0maus committed Feb 7, 2019
1 parent c7b0cc7 commit 1ebac1a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Assets/Scripts/Handlers/ObjectPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ public static void Add<T>(Component poolableObj) where T : Component
var originalType = poolableObj.GetType();
if (!originalType.IsSubclassOf(otherType))
{
// Call normal add when its not a subclass but same class as component.
if (originalType.Equals(otherType))
{
Add(poolableObj);
return;
}
throw new Exception("Generic type: " + originalType.Name + " is not a subclass of type: " + otherType.Name);
}

Expand Down

0 comments on commit 1ebac1a

Please sign in to comment.