private void OnEnable() { door = (DoorScript)target; if (door.AutuAssingIfEmpty) { if (door.transform.parent == null) { Debug.Log("No parent"); } else if (door.GetComponentInParent <WorldMap>() is WorldMap world) { int doorIndex = door.transform.GetSiblingIndex(); if (door.FronTilemap == null) { if (world.transform.GetChild(doorIndex - 1).gameObject.GetComponent <Map>() is Map map) { if (map.GetComponent <Tilemap>() is Tilemap tilemap) { door.FronTilemap = tilemap; EditorUtility.SetDirty(door); AssetDatabase.SaveAssets(); } } } if (door.ToTilemap == null) { if (world.transform.GetChild(doorIndex + 1).GetComponent <Map>() is Map map) { if (map.GetComponent <Tilemap>() is Tilemap tilemap) { door.ToTilemap = tilemap; EditorUtility.SetDirty(door); AssetDatabase.SaveAssets(); } } } } } }