Advertisement
Guest User

Unity5 AddComponent From String

a guest
Mar 6th, 2015
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.32 KB | None | 0 0
  1. using System;
  2. // ReSharper disable once CheckNamespace
  3. namespace UnityEngine
  4. {
  5.     public static class GameObjectExtensions
  6.     {
  7.         public static Component AddComponentFromString(this GameObject obj, string newComponent)
  8.         {
  9.             return obj.AddComponent(Type.GetType(newComponent));
  10.         }
  11.     }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement