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

@@ -1,6 +1,7 @@
###### Version 1.3.9
* Not save generated meshes in scene
* Fix (At line 908 of file "FTMain.jsfl": ReferenceError: ft is not defined)
* Fix warning on add missing components
###### Version 1.3.8
* Fix shape groups in tweens problems

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;
}
//

View File

@@ -301,7 +301,7 @@ namespace FTRuntime {
/// Update all animation properties (for internal use only)
/// </summary>
public void Internal_UpdateAllProperties() {
ClearCache();
ClearCache(false);
ChangeTint();
ChangeClip();
ChangeSequence();
@@ -309,11 +309,11 @@ namespace FTRuntime {
ChangeSortingProperties();
}
void ClearCache() {
_meshFilter = SwfUtils.GetOrCreateComponent<MeshFilter>(gameObject);
_meshRenderer = SwfUtils.GetOrCreateComponent<MeshRenderer>(gameObject);
void ClearCache(bool allow_to_create_components) {
_meshFilter = SwfUtils.GetComponent<MeshFilter> (gameObject, allow_to_create_components);
_meshRenderer = SwfUtils.GetComponent<MeshRenderer>(gameObject, allow_to_create_components);
#if UNITY_5_6_OR_NEWER
_sortingGroup = SwfUtils.GetOrCreateComponent<SortingGroup>(gameObject);
_sortingGroup = SwfUtils.GetComponent<SortingGroup>(gameObject, allow_to_create_components);
#endif
_dirtyMesh = true;
_curSequence = null;
@@ -432,11 +432,9 @@ namespace FTRuntime {
//
// ---------------------------------------------------------------------
void Awake() {
Internal_UpdateAllProperties();
}
void Start() {
ClearCache(true);
Internal_UpdateAllProperties();
EmitChangeEvents(true, true, true);
}