1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using UnityEngine;
- using UnityEngine.UI;
- using UnityEngine.Events;
- using System;
- using System.Linq;
- using System.Collections;
- using System.Collections.Generic;
- using Random = UnityEngine.Random;
- public static class Extension
- {
- #region Regist
- public static T AddScript<T>(this Component comp) where T : Component
- {
- return AddScript<T>(comp.gameObject);
- }
- public static T AddScript<T>(this GameObject go) where T : Component
- {
- Component comp = go.AddComponent(typeof(T));
- if (comp is Regist)
- {
- Regist regist = (Regist) comp;
- regist.enabled = false;
- regist.InitAtOnce();
- Initializer.RegistList.Add(regist);
- return (T) comp;
- }
- else
- {
- throw new Exception();
- }
- }
- #endregion
- }
|