public CachedAnimator(IAnimator value) { _value = value; if (value is UnityEngine.Component unityComponent) { var prefab = PrefabEntity.FindPrefabRoot(unityComponent.transform); if (prefab != null) { _serializedId = prefab.Metadata.SerializationId; _transformChild = unityComponent.transform.GetPath(); } else { Debug.LogErrorFormat("{0}: unable to find prefab root on {1}", value.GetType(), unityComponent.gameObject.name); } return; } if (value is IComponent ecsComponent) { _componentType = value.GetType(); _entityId = EntityController.GetComponentArray(_componentType).GetEntity(ecsComponent); return; } Debug.LogErrorFormat("{0} is not a valid type of animator", value.GetType()); }
public void Set(T component) { _value = component; if (_value == null) { Clear(); return; } if (component is UnityEngine.Component unityComponent) { var prefab = PrefabEntity.FindPrefabRoot(unityComponent.transform); if (prefab != null) { _serializedId = prefab.PrefabId; _transformChild = unityComponent.transform.GetPath(); } else { Debug.LogErrorFormat("{0}: unable to find prefab root on {1}", component.GetType(), unityComponent.gameObject.name); } return; } if (component is IComponent ecsComponent) { _componentType = component.GetType(); _entityId = EntityController.GetComponentArray(_componentType).GetEntity(ecsComponent); return; } Debug.LogErrorFormat("{0} is not a valid type of animator", component.GetType()); }
public void Set(T component) { _value = component; if (_value == null) { _serializedId = -1; _transformChild = null; return; } if (_serializedId >= 0) { return; } SetPrefabEntity(PrefabEntity.FindPrefabRoot(_value.transform)); }