IEnumerator FadeToOblivion(Transform obj) { float time = 0; Vector3 initPos = obj.position; Quaternion initRot = obj.rotation; Vector3 initScale = obj.localScale; SortingOrderManager som = obj.GetComponent <SortingOrderManager>(); if (som != null) { som.enabled = false; SpriteRenderer rend = obj.GetComponent <SpriteRenderer>(); if (rend != null) { rend.sortingOrder = sr.sortingOrder + 1; } } while (time < destroyTime) { float progress = time / destroyTime; obj.position = Vector3.Lerp(initPos, spot.position, progress); obj.rotation = Quaternion.Lerp(initRot, spot.rotation, progress); obj.localScale = Vector3.Lerp(initScale, Vector3.zero, progress); yield return(null); time += Time.deltaTime; } Destroy(obj.gameObject); }
void Start() { sushis = new List <Transform>(); som = GetComponent <SortingOrderManager>(); som.OnFinalizeSortingOrder += FixSortingOrders; g = GetComponent <Grabbable>(); g.OnGrab += SpawnNewPlate; }
void Start() { sr = spriteTransform.GetComponent <SpriteRenderer>(); rb = GetComponent <Rigidbody2D>(); som = GetComponent <SortingOrderManager>(); spriteCount = spritesFront.Length; spritesCurrent = spritesFront; }
void UpdateHeldItemLayer(int sortingOrder) { if (heldItem == null) { som.OnFinalizeSortingOrder -= UpdateHeldItemLayer; return; } SpriteRenderer rend = heldItem.GetComponent <SpriteRenderer>(); if (rend == null) { som.OnFinalizeSortingOrder -= UpdateHeldItemLayer; return; } rend.sortingOrder = sortingOrder + (facingForward ? 1 : -1); SortingOrderManager heldSOM = heldItem.GetComponent <SortingOrderManager>(); heldSOM?.OnFinalizeSortingOrder?.Invoke(facingForward ? rend.sortingOrder : rend.sortingOrder - 4); }
void Start() { rb = GetComponent <Rigidbody2D>(); col = GetComponent <Collider2D>(); som = GetComponent <SortingOrderManager>(); }