You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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;
}
The text was updated successfully, but these errors were encountered:
Hi, the current behaviour of the RuleTile is valid and correct.
If there is a Rule that matches, it will use the output from the Rule. A user may specifically want a null GameObject or collider type as set up for that Rule, which your changes would override.
If there are no Rules that matches, then it would use the defaults as given.
To reduce any errors from having unwanted null GameObjects in a Rule when there are defaults set, in the RuleTileEditor, we will create Rules with the defaults set. This currently is not happening right now, but will be fixed in a future version of the package.
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;
}
The text was updated successfully, but these errors were encountered: