protected override void OnAddComponent(UTinyEntity entity, UTinyObject component)
        {
            var spriteRenderer = entity.GetComponent(entity.Registry.GetSprite2DRendererType());
            var sprite         = spriteRenderer?.GetProperty <Sprite>("sprite");

            if (null == sprite || !sprite)
            {
                return;
            }

            component.AssignPropertyFrom("width", sprite.bounds.size.x);
            component.AssignPropertyFrom("height", sprite.bounds.size.y);
        }
        protected static void AssignIfDifferent(UTinyObject tiny, string propertyName, AudioClip value)
        {
            var current = tiny.GetProperty <AudioClip>(propertyName);

            if (current != value)
            {
                tiny.AssignPropertyFrom(propertyName, value);
            }
        }
        protected static void AssignIfDifferent <TValue>(UTinyObject tiny, string propertyName, TValue value)
        {
            var current = tiny.GetProperty <TValue>(propertyName);

            if (!current.Equals(value))
            {
                tiny.AssignPropertyFrom(propertyName, value);
            }
        }
示例#4
0
        protected override void OnAddBinding(UTinyEntity entity, UTinyObject component)
        {
            var renderer = GetComponent <SpriteRenderer>(entity);

            renderer.drawMode = Translate(component.GetProperty <TileMode>("mode"));
            if (component.GetProperty <Vector2>("size") == Vector2.zero)
            {
                component.AssignPropertyFrom("size", renderer.size);
            }
        }
        protected override void OnAddComponent(UTinyEntity entity, UTinyObject component)
        {
            var spriteRenderer = entity.GetComponent(entity.Registry.GetSprite2DRendererType());
            var sprite         = spriteRenderer?.GetProperty <Sprite>("sprite");

            if (null == sprite || !sprite)
            {
                return;
            }

            var rect = new Rect
            {
                min = sprite.bounds.min,
                max = sprite.bounds.max
            };

            component.AssignPropertyFrom("box", rect);
        }