mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2025-12-16 14:11:19 +07:00
fix warning on add missing components
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user