示例#1
0
        public void CreateFlyingIcon(Sprite sprite, Vector3 startPosition, Transform destination, float scale = 1f)
        {
            FlyingIcon flyingIcon = new FlyingIcon();

            flyingIcon.GameObject  = new GameObject("Flying Icon", typeof(SpriteRenderer));
            flyingIcon.Destination = destination;
            Vector3 position = startPosition;

            position.y = 1;
            flyingIcon.GameObject.transform.position = position;
            var euler = flyingIcon.GameObject.transform.eulerAngles;

            euler.x = 90;
            flyingIcon.GameObject.transform.eulerAngles = euler;
            flyingIcon.GameObject.transform.localScale  = Vector3.one * scale;
            var spriteRenderer = flyingIcon.GameObject.GetComponent <SpriteRenderer>();

            spriteRenderer.sprite           = sprite;
            spriteRenderer.sortingLayerName = "Flying Icon";
            FlyingIconAdded.Invoke(flyingIcon);
        }
 private void AddFlyingIconToList(FlyingIcon flyingIcon) => _flyingIcons.Add(flyingIcon);