| | 1 | | using UnityEngine; |
| | 2 | |
|
| | 3 | | public class StickersController : MonoBehaviour |
| | 4 | | { |
| | 5 | | private StickersFactory stickersFactory; |
| | 6 | |
|
| 1612 | 7 | | private void Awake() { stickersFactory = Resources.Load<StickersFactory>("StickersFactory"); } |
| | 8 | |
|
| | 9 | | public void PlaySticker(string id) |
| | 10 | | { |
| 0 | 11 | | PlaySticker(id, transform.position, Vector3.zero, true); |
| 0 | 12 | | } |
| | 13 | |
|
| | 14 | | public void PlaySticker(string id, Vector3 position, Vector3 direction, bool followTransform) |
| | 15 | | { |
| 113 | 16 | | if (stickersFactory == null || !stickersFactory.TryGet(id, out GameObject prefab)) |
| 0 | 17 | | return; |
| | 18 | |
|
| 113 | 19 | | GameObject emoteGameObject = Instantiate(prefab); |
| 113 | 20 | | emoteGameObject.transform.position += position; |
| 113 | 21 | | emoteGameObject.transform.rotation = Quaternion.Euler(prefab.transform.rotation.eulerAngles + direction); |
| | 22 | |
|
| 113 | 23 | | if (followTransform) |
| | 24 | | { |
| 0 | 25 | | FollowObject emoteFollow = emoteGameObject.AddComponent<FollowObject>(); |
| 0 | 26 | | emoteFollow.target = transform; |
| 0 | 27 | | emoteFollow.offset = prefab.transform.position; |
| | 28 | | } |
| 113 | 29 | | } |
| | 30 | | } |