-
Notifications
You must be signed in to change notification settings - Fork 339
Description
In the GetTileData method of the RuleTile script the gameObject is initially set to the default object (line: 206) in the RuleMatches if statement the "defaults" for the gameObject and collider type are always overwritten even if null. Lines 233/234.
Here is a solution i used:
if (RuleMatches(rule, position, tilemap, ref transform))
{
switch (rule.m_Output)
{
case TilingRuleOutput.OutputSprite.Single:
case TilingRuleOutput.OutputSprite.Animation:
tileData.sprite = rule.m_Sprites[0];
break;
case TilingRuleOutput.OutputSprite.Random:
var index = Mathf.Clamp(
Mathf.FloorToInt(GetPerlinValue(position, rule.m_PerlinScale, 100000f) *
rule.m_Sprites.Length), 0, rule.m_Sprites.Length - 1);
tileData.sprite = rule.m_Sprites[index];
if (rule.m_RandomTransform != TilingRuleOutput.Transform.Fixed)
transform = ApplyRandomTransform(rule.m_RandomTransform, transform, rule.m_PerlinScale,
position);
break;
}
tileData.transform = transform;
tileData.gameObject ??= rule.m_GameObject;
if (rule.m_ColliderType != m_DefaultColliderType)
tileData.colliderType = rule.m_ColliderType;
break;
}