Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - subliminalman

Pages: [1]
1
Support / Re: Random Paint Tiles don't flip on TileMap
« on: October 22, 2013, 08:04:44 am »
Perfect! Exactly the solution that I was needing! This will help speed up our level creation process so much!

Thank you.

I can understand the difficulty on the implementation on whether or not the user wants each tile randomly flipped or all selected tiles in the same direction. The only thing I can think of would be a toggle button that only comes up with the random mode selected but that may not be the best solution.


Thank you again!

2
Support / Random Paint Tiles don't flip on TileMap
« on: October 20, 2013, 11:18:24 pm »
Whenever I use the random brush the horizontal flip and/or vertical flip flags don't actually flip any of the sprites.

I am currently on version 2.2.3

If this could be added then it would speed up my process sooo much!


Thank you!

3
Support / Re: TileMap: weirdness when using it as a Prefab
« on: October 20, 2013, 02:34:40 am »
Was this fixed? I am getting this KeyNotFoundException as well.

When I instantiate the prefab with the tilemap via code it draws the prefabs in the tilemap correctly but not the sprites that do not have a prefab connected to them. I am on version 2.2.3 and I am instantiating via Resources.Load


Thanks

4
Support / Re: Prefab in Tilemap graphic override
« on: October 18, 2013, 08:26:46 am »
The only other way I could think of is read the sprite image off the tilemap at the prefabs position. Is there a way for the prefab to know its position or do I have to go through the entire tilemap at the beginning to set everything up? Thank you.

No there isn't. You will have to set up the prefabs manually / write a script to do it. We could probably add support for it if there is enough interest.

Could you please? I am currently using the script below to make the changes I need for the sprites and I feel like there could be an easier way within your system.

This code grabs the name of the sprite from the tile and calls SetSprite(spriteName) on the prefab.
Make sure to set the string value in the data tab for each tile to the sprite name from your collection, it won't work otherwise.

Select your tilemap before pressing the button.


edit: updated code to flip tiles appropriately. It won't rotate 90 yet.
edit2: updated so it goes through layers as well
edit3: did the flags wrong the first time, fixed now.


Code: [Select]
using UnityEngine;
using UnityEditor;
using System.Collections;

public class UpdateTilemap : EditorWindow {
string buttonText = "Update TileMap Prefabs";
[MenuItem ("Window/Update TileMap Prefabs")]
static void Init () {
// Get existing open window or if none, make a new one:
UpdateTilemap window = (UpdateTilemap)EditorWindow.GetWindow (typeof (UpdateTilemap));
}

void OnGUI () {
if(GUILayout.Button(buttonText)) {
            //add everthing the button would do.
buttonText = UpdateTileMapPrefabs();
        }
}

string UpdateTileMapPrefabs(){
try{
if (Selection.activeGameObject == null || Selection.activeGameObject.GetComponent<tk2dTileMap>() == null){
Debug.Log("Select a tile map before running this");
return "Select a tile map before running";
}
tk2dTileMap tilemap = Selection.activeGameObject.GetComponent<tk2dTileMap>();

for(int z = 0; z < tilemap.data.NumLayers; z++){
for (int x = 0; x < tilemap.width; ++x) {
for (int y = 0; y < tilemap.height; ++y) {
//Go through each tile and get it's spriteName
tk2dRuntime.TileMap.TileInfo tempInfo = tilemap.GetTileInfoForTileId(tilemap.GetTile(x, y, z));
if(tempInfo != null){
string spriteName = tempInfo.stringVal;

if(spriteName != null && !spriteName.Equals("")){

//Check every prefab in the tilemap to get matching spriteNames
for(int i = 0; i < tilemap.GetTilePrefabsListCount(); i++){
int tempX = 0, tempY = 0 , tempLayer = 0;
GameObject prefabObject;
//get the prefab
tilemap.GetTilePrefabsListItem(i, out tempX, out tempY, out tempLayer, out prefabObject);

if(tempX == x && tempY == y && tempLayer == z){
if(prefabObject != null){
//Update the sprite

tk2dSprite tempSprite = prefabObject.GetComponent<tk2dSprite>();

if(tempSprite.SetSprite(spriteName)){
//a hack to keep the change

tk2dTileFlags tileFlag = tilemap.GetTileFlags(x, y, z);

if(tileFlag == tk2dTileFlags.None){
tempSprite.FlipX = tempSprite.FlipY = false;
}else{
if((tileFlag & tk2dTileFlags.FlipX) == tk2dTileFlags.FlipX){
tempSprite.FlipX = true;
}
if((tileFlag & tk2dTileFlags.FlipY) == tk2dTileFlags.FlipY){
tempSprite.FlipY = true;
}
}
Debug.Log (tileFlag.ToString());

tempSprite.enabled = false;
tempSprite.enabled = true;
Debug.Log ("Success");
}else{
Debug.Log ("Failure");
}

break;
}
}//Wow that's a brace
}//There's another one
}//They keep going
}//...
}//grrrr
}//*flips table*
}

return "finished";
}catch(System.Exception e){
return "failed: " + e;
}
}
}

5
Support / Re: How can I repeat texture on sprite several times?
« on: February 07, 2013, 05:18:00 am »
Hi all,

I know this is old but is there any word on tiling? We're looking to do tiling for our game since we don't follow the grid like nature of the TileMap but would like to place our object and scale it without stretching.

Also I wasn't able to get to the link provided above so I was not able to try that out.

Pages: [1]