| | 1 | | using UnityEngine; |
| | 2 | |
|
| | 3 | | namespace DCL |
| | 4 | | { |
| | 5 | | public class StickersController : MonoBehaviour |
| | 6 | | { |
| | 7 | | private StickersFactory stickersFactory; |
| | 8 | |
|
| 2566 | 9 | | private void Awake() { stickersFactory = Resources.Load<StickersFactory>("StickersFactory"); } |
| | 10 | |
|
| | 11 | | public void PlaySticker(string id) |
| | 12 | | { |
| 0 | 13 | | PlaySticker(id, transform.position, Vector3.zero, true); |
| 0 | 14 | | } |
| | 15 | |
|
| | 16 | | public void PlaySticker(string id, Vector3 position, Vector3 direction, bool followTransform) |
| | 17 | | { |
| 54 | 18 | | if (stickersFactory == null || !stickersFactory.TryGet(id, out GameObject prefab)) |
| 0 | 19 | | return; |
| | 20 | |
|
| | 21 | | // TODO(Brian): Mock this system properly through our service locators or plugin system |
| 54 | 22 | | if (DCL.Configuration.EnvironmentSettings.RUNNING_TESTS) |
| 54 | 23 | | return; |
| | 24 | |
|
| 0 | 25 | | GameObject emoteGameObject = Instantiate(prefab); |
| 0 | 26 | | emoteGameObject.transform.position += position; |
| 0 | 27 | | emoteGameObject.transform.rotation = Quaternion.Euler(prefab.transform.rotation.eulerAngles + direction); |
| | 28 | |
|
| 0 | 29 | | if (followTransform) |
| | 30 | | { |
| 0 | 31 | | FollowObject emoteFollow = emoteGameObject.AddComponent<FollowObject>(); |
| 0 | 32 | | emoteFollow.target = transform; |
| 0 | 33 | | emoteFollow.offset = prefab.transform.position; |
| | 34 | | } |
| 0 | 35 | | } |
| | 36 | | } |
| | 37 | | } |