fix warning on add missing components

This commit is contained in:
2017-08-06 00:34:16 +07:00
parent 2aa7ca4a0a
commit 0d42dd1b12
4 changed files with 14 additions and 14 deletions

View File

@@ -27,11 +27,12 @@ namespace FTRuntime.Internal {
//
//
public static T GetOrCreateComponent<T>(GameObject obj) where T : Component {
public static T GetComponent<T>(GameObject obj, bool allow_create) where T : Component {
var comp = obj.GetComponent<T>();
return comp != null
? comp
: obj.AddComponent<T>();
if ( allow_create && !comp ) {
comp = obj.AddComponent<T>();
}
return comp;
}
//