using System.Collections; using System.Collections.Generic; using System.Linq; using UltraCombos; using UnityEngine; using UnityEngine.EventSystems; public class FlakeSpawner : MonoBehaviour { // Start is called before the first frame update public GameObject prefab; public DShowClip[] clips; List raycastResults = new List(); public void TrySpawn(Vector2 position) { PointerEventData data = new PointerEventData(EventSystem.current); data.position = position; raycastResults.Clear(); EventSystem.current.RaycastAll(data, raycastResults); bool found = raycastResults.Select(r => r.gameObject.layer == LayerMask.NameToLayer("Flake")).Any(b => b); if (found) return; GameObject obj = Instantiate(prefab, transform); (obj.transform as RectTransform).anchoredPosition = position; obj.GetComponent().VideoAsset = clips[Random.Range(0, clips.Length)]; obj.SetActive(true); } }