2d-extras icon indicating copy to clipboard operation
2d-extras copied to clipboard

CustomRule?

Open superfrantv opened this issue 6 years ago • 19 comments

Hallo, seit dem neuen Update geht bei mir gar nichts mehr.. die Regeln spinnen total rum, es rotiert die Tiles nicht mehr richtig und vieles mehr.

Ich möchte meinen eigenen Script der prüft wenn das aktuelle Tile neben einen speziellen ist, dann soll es anders Aussehen, wie nutze ich RuleMatch ohne ints sondern mit Sprites?

superfrantv avatar Oct 28 '19 17:10 superfrantv

Originally posted by @superfrantv in https://github.com/Unity-Technologies/2d-extras/issues/141#issuecomment-547098268

Continue to follow up on your issue here. Sorry, I don't understand your situation. Can you provide some screenshots or send Tile assets to me?

johnsoncodehk avatar Oct 28 '19 19:10 johnsoncodehk

Screenshot (91)

I want a "RoomTile" with a Wall that is 3 Tiles (High/Big) and in the Middle a Ground (as Basic Sprite from Wall 1). Aditional there should be Doors and Windows (4x4 Tiles or 2x6 tiles) but they can be as they own.

superfrantv avatar Oct 28 '19 19:10 superfrantv

Sorry if I understand what you mean wrong. If you want to merge first, second, third walls into a single tile, you need a rule setting greater than 3x3. This feature is supported in https://github.com/Unity-Technologies/2d-extras/pull/140. Since it has not been merged, you currently need to change git url to my branch to use.

"com.unity.2d.tilemap.extras": "https://github.com/johnsoncodehk/2d-extras.git#rule-tile-5x5",

johnsoncodehk avatar Oct 28 '19 19:10 johnsoncodehk

@johnsoncodehk

i changed my manifest.json under Packages Folder and changed the link but it does nothing? Where can i use the 5x5?

superfrantv avatar Oct 28 '19 19:10 superfrantv

Rule list Is there a Extend Neighbor toggle?

johnsoncodehk avatar Oct 28 '19 20:10 johnsoncodehk

Rule list Is there a Extend Neighbor toggle?

No should i restart my unity project or add both Links?

superfrantv avatar Oct 28 '19 20:10 superfrantv

No you don't need. Please show me your Packages/manifest.json file.

johnsoncodehk avatar Oct 28 '19 20:10 johnsoncodehk

@johnsoncodehk

{ "dependencies": { "com.unity.2d.sprite": "1.0.0", "com.unity.2d.tilemap": "1.0.0", "com.unity.2d.tilemap.extras": "https://github.com/johnsoncodehk/2d-extras.git#rule-tile-5x5", "com.unity.ads": "2.0.8", "com.unity.analytics": "3.3.2", "com.unity.ide.vscode": "1.1.2", "com.unity.package-manager-ui": "2.2.0", "com.unity.postprocessing": "2.1.7", "com.unity.purchasing": "2.0.6", "com.unity.ugui": "1.0.0", "com.unity.modules.ai": "1.0.0", "com.unity.modules.androidjni": "1.0.0", "com.unity.modules.animation": "1.0.0", "com.unity.modules.assetbundle": "1.0.0", "com.unity.modules.audio": "1.0.0", "com.unity.modules.cloth": "1.0.0", "com.unity.modules.director": "1.0.0", "com.unity.modules.imageconversion": "1.0.0", "com.unity.modules.imgui": "1.0.0", "com.unity.modules.jsonserialize": "1.0.0", "com.unity.modules.particlesystem": "1.0.0", "com.unity.modules.physics": "1.0.0", "com.unity.modules.physics2d": "1.0.0", "com.unity.modules.screencapture": "1.0.0", "com.unity.modules.terrain": "1.0.0", "com.unity.modules.terrainphysics": "1.0.0", "com.unity.modules.tilemap": "1.0.0", "com.unity.modules.ui": "1.0.0", "com.unity.modules.uielements": "1.0.0", "com.unity.modules.umbra": "1.0.0", "com.unity.modules.unityanalytics": "1.0.0", "com.unity.modules.unitywebrequest": "1.0.0", "com.unity.modules.unitywebrequestassetbundle": "1.0.0", "com.unity.modules.unitywebrequestaudio": "1.0.0", "com.unity.modules.unitywebrequesttexture": "1.0.0", "com.unity.modules.unitywebrequestwww": "1.0.0", "com.unity.modules.vehicles": "1.0.0", "com.unity.modules.video": "1.0.0", "com.unity.modules.vr": "1.0.0", "com.unity.modules.wind": "1.0.0", "com.unity.modules.xr": "1.0.0" } }

superfrantv avatar Oct 28 '19 20:10 superfrantv

No lock attribute? If there is, you should delete it. Also try to delete your Library folder.

johnsoncodehk avatar Oct 28 '19 20:10 johnsoncodehk

What do you mean with Lock attribute?

if i delete my library folder some settings will be lost?

superfrantv avatar Oct 28 '19 20:10 superfrantv

I tried the above two points without affecting. Try doing this:

  1. Delete the "com.unity.2d.tilemap.extras": /* ... */ line.
  2. Switch to Unity, and the PackageManager will reload.
  3. Make sure the 2d-extras package is removed
  4. Add "com.unity.2d.tilemap.extras": /* ... */ line again.

johnsoncodehk avatar Oct 28 '19 20:10 johnsoncodehk

I may have misunderstood. Do you want to use 3 RuleOverrideTiles instead of merging into one RuleTile? For the SiblingTile, SiblingGroup will appear in RuleOverrideTile. Different SiblingGroup is equivalent to OverrideSelf enable. Same SiblingGroup is equivalent to OverrideSelf disable.

johnsoncodehk avatar Oct 28 '19 21:10 johnsoncodehk

i deleted the library folder, not working, in my packages folder there is a folder named: "com.unity.2d.tilemap.extras" with the master files i downloaded here.

and a manifest.json with the line included, if i delete the line and reload the packagemanager, nothing changed.

So the package things not working right (typical unity things), how can i manual include the 5x5, which scripts i must change?

superfrantv avatar Oct 29 '19 18:10 superfrantv

You need to change these scripts: https://github.com/Unity-Technologies/2d-extras/pull/140/files?file-filters%5B%5D=

And click this button to view the file. image

johnsoncodehk avatar Oct 29 '19 19:10 johnsoncodehk

Screenshot (92)

Updated Manual worked like a charm. but i don't know how i should setup my rules.

in the picture you see the red marked things, this is not rotated right (but why is it only on the left and bottom side) all other works but the rotation works not.

blue sprites are Tile 1 (RuleTile) and green sprites are Tile 2 (RuleOverrideTile from Tile 1 with same rules).

superfrantv avatar Oct 29 '19 19:10 superfrantv

If you want to reproduce it you need 7 sprites And 1 rule Tile with my settings on picture and one ruleoverridetile where the rule Tile is the Base and only other Sprites are assign.

1 ground sprite (middle) 2 differend Wall Sprites and 2 differend inside and outside Sprites.

I dont know about hangouts

superfrantv avatar Oct 29 '19 19:10 superfrantv

The Problem is on the RuleMatch Function:

now: if any other tile is on the side where a green arrow rule is -> true or 1

before the new changes:

if any other tile is on the side where a green arrow rule is -> false or 0

i think this is it, but how to change it?

please reproduce (shown on my picture there are the rule setup with your 5x5 rule tile), simple create 2 rule tiles with the same setup and place the first one in the middle (6x6 fields) and the second one arround the first one.

can this be changed from any project settings?

superfrantv avatar Oct 29 '19 20:10 superfrantv

public class CustomTile : RuleTile<CustomTile.Neighbor>
{

    public class Neighbor : TilingRule.Neighbor
    {
        public const int OtherTile = 3;
        public const int WallOrNoting = 4;
    }

    public bool isWall;

    public override bool RuleMatch(int neighbor, TileBase other)
    {
        if (other is RuleOverrideTile)
            other = (other as RuleOverrideTile).m_InstanceTile;

        switch (neighbor)
        {
            case Neighbor.OtherTile:
                return other != this && other != null;
            case Neighbor.WallOrNoting:
                return !other || ((other is CustomTile) && (other as CustomTile).isWall);
        }

        return base.RuleMatch(neighbor, other);
    }
}

image image image

johnsoncodehk avatar Oct 29 '19 20:10 johnsoncodehk

Thank You very very much, thats Do it :)

superfrantv avatar Oct 30 '19 13:10 superfrantv