About
Contents
STL
Android
Eigen
enchant.js
Firefox OS
OpenGL
OpenGL ES 2.0
pukiwiki
UE4
Unity
Windows Phone
Xamarin
Materials Link
その他
PR
STL
Android
Eigen
enchant.js
Firefox OS
OpenGL
OpenGL ES 2.0
pukiwiki
UE4
Unity
Windows Phone
Xamarin
以前のリビジョンの文書です
よく使う機能は安全性の為にもラップしておくと良いと思います。
//------------------------------------------------------------- //! コンポーネントの追加(存在チェック版). //------------------------------------------------------------- static public T AddSafeComponent<T>(GameObject _go) where T : Component { T component = _go.GetComponent<T>(); if (component == null) { // 無ければ足す。 return _go.AddComponent<T>(); } // あればそのまま返す。 return component; } //------------------------------------------------------------- //! コンポーネントの取得(存在チェック版). //------------------------------------------------------------- public static T GetSafeComponent<T>(GameObject _go) where T : Component { T component = _go.GetComponent<T>(); if(component == null) { Debug.LogError("Expected to find component of type " + typeof(T) + " but found none.", _go); } return component; }