unity3d , Unity procedural TileMap generation without creating gameobject per tile

Unity procedural TileMap generation without creating gameobject per tile


Tag: unity3d

I've been searching all over the internet to find a efficient way to create procedural tilemap without creating a gameobject per each tile. There is none, or simply i couldn't find it, because i really don't know how to make a search for it. All the TileMap tutorials i found are creating tiles by creating hunderds of gameobjects. Thus the hierarchy in Unity is expanding uncontrollably.

I'm pretty sure this is not the "right" way to do it. Especially after seeing the new Unity 2D tools that supports tilemaps. Unity made it so, you can create tiles in "one" gameobject, not for each tile.

How to do it in the right way?


Given the sole task of "creating an efficient tilemap", your best option is to create a TileMap component that manages a procedural mesh made up of a collection of independent quads with uvs mapped to a tile atlas. This way you will even draw your whole map in one drawcall.

You'd need to know a thing or two about how meshes work, and texturing. It's very simple, and if you don't know but are curious about it, catlikecoding's tutos are a good starting point. In the tuto each quad on the grid shares vertices, but for this you'd want independent quads, so as to texture them properly.


I'm trying to reduce the Length of this Code

I wrote some code today. I can't figure out how to reduce the length of this code, although it seems repetitive, every part is different. try { totalVerts.Add(verts[i]); if (verts[i].x > maxXvert) { maxXvert = verts[i].x; } if (verts[i].x < minXvert) { minXvert = verts[i].x; } if (verts[i].y > maxYvert)...

Integrating Unity3d into iOS UITabbarController / UINavigationController

I've manage to compile my iOS project with Unity in it. Tested and the unity project runs in my iOS project if it's the first view. However I'm trying to initialize it in another subview. Initially my application AppDelegate will handle the self.window.rootViewController It seems like I have to pass...

Converting from Pixel Coordinates to UI Coordinates in Unity

Does anyone know how to convert from Pixel Coordinates to UI Coordinates and vice-versa in Unity? Let's say for example I want to click somewhere on the screen with the mouse, and a UI Image to be at that click position. If I do this won't work: Image img =...

Make two physics objects not collide but do detect collisions in Unity

I have a Unity project in which there is a 2D game world that consists of static colliders to make the geometry solid to the characters that inhabit it. The player is a dynamic collider (with a non-kinematic rigidbody). There's also an enemy character that is also a dynamic collider....

Formatting large numbers in C#

I am using Unity to make an "Incremental Game" also known as an "Idle Game" and I am trying to format large numbers. For example, when gold gets to say 1000 or more, it will display as Gold: 1k instead of Gold: 1000. using UnityEngine; using System.Collections; public class Click...

How to draw each a vertex of a mesh as a circle

How to draw each a vertex of a mesh as a circle?

2D game development with Unity3D

I tried to find some answers to a few questions I have about Unity3D games development. I want to create 2D mobile games. The thing I really want to know is if I can create a mobile game for different platforms at one time (as cordova can build Android /...

How do I Mute The Audio In Unity 3D?

with script this. what is wrong in script this ? audio.mute = ToggleButton.isSpeakerOff; sorry bad english,fast answer please correct my script please...

Csproj file in unity changes everytime i reload the project

I want to change the 'csproj' file of my unity project in order to be able to access a specific library as this answer sugests. I am manually editing the file but every time i reload the project, the 'csproj' file returns to it's initial state. Is this a common...

Our iOS developer has developed a game in Unity3D. How do we export it for Android?

Our iOS developer has developed a game in Unity3D. How do we export it for Android? I did a quick check on the internet and it says there "one click export for Android". Is this really the case? Are there ways it might have been developed that will make it...

In Unity3D, How to make the whole scene in dark, but some Area are not in dark

I wan't make some teaching levels with UGUI, so need the whole to be in dark, but some rectangular area not in dark. I can make the whole scene in dark by adding a gameobject with a image component, and control it's alpha to dark. But I don't know how...

Turning an avatar into a 3rd person character

I just learned how easy it is to simply drag a 3rd person character controller prefab (from Unity's standard assets package) and drop it into the hierarchy. Using the WSAD and Space keys feels pretty natural, so I wondered if I could apply the same character controller to a customized...

Unity setting GUIText of another object

I have (PlanetController): private GameController gameController; ... void OnMouseEnter() { gameController.setClassText("Orbital speed: " + orbitSpeed); } In the GameController script: public class GameController : MonoBehaviour { public GUIText classText; void Start () { this.setClassText (""); } public void setClassText(string text) { classText.text = text; } } But I'm getting: NullReferenceException:...

Convert a large int to a float between 0.0f and 1.0f

I'm working on a project where I have a pane that goes from 0 to 500 on the x and z, but I need to convert that coordinate (from 0 to 500) to a float in the range of 0.0 to 1.0 in because it is required from some of...

How to make the whole scene in dark on unity3D

Likes that when the game is pause, only the Resume button is lighted, other whole scene is in dark, Is there some function can do it?

Controlling a player using touch input on the mobile device

I am new to Unity, and was following the tutorials of roll a ball. I was to create it for both mobile and desktop and it is working but the only problem I have is that I am unable to create touch keys arrows(left,right,up,down) to control the player on the...

Iterating through multiple levels of Child Objects

I have this block of code. And I need to iterate through every child object, but child objects could have more children within them. The Awake() method is called when the program is first ran. So, I'm asking how to build an iterator that will check if there are children...

Unity 3D Text becomes Word Cubes

As the image shows, my 3D Text keeps disappearing from my scene when I click Play, and then when I zoom in, this is what I see. When I exit the Play scene, it stays like that till I Ctrl+S and Save on which is returns to its proper text...

Unity: GameObject.FindGameObjectWithTag isn't working and I don't know why

I have a enemy AI script and a small part of the code isn't working. It's supposed to search for a game object with the Player tag when the target no longer exists. So, when the player collects a power up and a new player prefab spawns in its place...

ant jar error: Execute failed: java.io.IOException: Cannot run program…${aapt}": error=2, No such file or directory

I'm trying to compile a simple Java library for Unity, and after running ant jar, I get the following message: /Applications/adt-bundle-mac-x86_64-20140702/sdk/tools/ant/build.xml:649: The following error occurred while executing this line: /Applications/adt-bundle-mac-x86_64-20140702/sdk/tools/ant/build.xml:694: Execute failed: java.io.IOException: Cannot run program "/Users/****/UnityProjects/****/JavaTestPlugin/${aapt}": error=2, No such file or directory This is strange, because I've compiled this...

Unity3D Play sound from particle

I am trying to play a sound when a particle collides with a wall. Right now, it just plays the sound from the parent object, which is the player. However, I want the sound to play from the particle. Which means when a particle is far to the left, you...

SWF works locally but not loaded from server

Here is the deal. I have SWF build with Unity and embedded into HTML page with swfobject. It works perfectly well when I load page locally (zip), but it always says "Movie not loaded" when I try to load page. from server I have already inspect similar embedded movies (this...

Unity: Prefab parenting in code

Let's say I want multiple prefab object called childTile, it parenting another single prefab object called parentTile. So whenever the parentTile rotates, childTiles will be rotated around parentTile. Basically this is what I wrote: public GameObject childPrefab; public GameObject parentPrefab; void Update() { for(int i = 0; i < 10;...

EditorGUILayout.Popup option is not changing

using this simple code I'm showing a dropdown int selected = 0; ///* string[] options = new string[] { "Start With", "End With", "Contains", }; //criteria = EditorGUILayout.Popup("Search Criteria", 2, options); //*/ criteria = EditorGUILayout.Popup("Awesome Drop down:", selected, options, EditorStyles.popup); it showing dropdown with option perfectly but the problem is...

Create array/list of many objects(initially unknown amount) by tag

I'm currently working on a radar system for my space game, and I am trying to work out how to add gameobjects, by tag, to either a list or array that can then be used in other methods. I can't do this manually because I will be procedurally generating each...

var keyword vs actual type? [duplicate]

This question already has an answer here: Use of var keyword in C# 86 answers I'm using vim + omnisharp/syntastic for some unity3d development in C#. When I declare a variable using the actual type, for instance string[] myArray = new string[5]; I get a warning message telling me...

Unity An object reference is required to access non-static member C#

Im trying to learn C# with Unity engine But a basic script like this: using UnityEngine; using System.Collections; public class scriptBall : MonoBehaviour { // Use this for initialization void Start () { Rigidbody.AddForce(0,1000f,0); } // Update is called once per frame void Update () { } } gives this...

AdColony's OnVideoFinished not call in Android

I have a problem with AdColony-UnitySDK. When AdColony's video is finish playing, OnVideoFinished() method don't be called. In this case, the following sources work well in iOS. And also, the server receive the success callback both device. So, only Android device that is not work. Here is the source code,...

Can an Android (Java not C/C++) plugin alter unity textures?

I'm trying to use an Android plugin to get around the fact that Unity does not support Video Textures on mobile. I do this by getting the texture ID of the texture that will be used for video (supplied by Texture2D.GetNativeTextureID()) which i then pass into the Java Plugin. The...

Unity procedural TileMap generation without creating gameobject per tile

I've been searching all over the internet to find a efficient way to create procedural tilemap without creating a gameobject per each tile. There is none, or simply i couldn't find it, because i really don't know how to make a search for it. All the TileMap tutorials i found...

What is this programming method called? And is it bad?

Lately in my Unity projects, I have discovered that to create a more modular application it helps to have a static List in a class that contains references to all or some of the objects created so that they may be accessed easily from other parts of the program. An...

Unity 5 Audio Volume Slider (Solved)

I am trying to create an slider that I can use for volume control in Unity 5 but the volume will not change. My Game Objects are called MainMusicPlayer for the audio source and Volume Slider for the slider I am going to post the whole script as it would...

Loading MP3 files at runtime in unity

I'm trying to load an mp3 file at runtime using the WWW class that is provided in Unity. I don't get any errors, but I'm unable to play the music after the song has been processed. I have looked everywhere and cannot find anything to help me. Here is the...

how to add Scoring to unity3D 2d top down car game?

I'm making 2D top down car game. as for now car game working with if player car hit enemy car game is over. I used for it adding tag to Enemy car and if player car collision detect enemy car with tag the finish the game. My question is: How...

Instantiate GameObject at Random time is not working

I want the enemy to spawn at random time between 1-5 seconds but when I applied the script inside the game , the game is spammed with enemies and it continuously nonstop spawning enemies ! using UnityEngine; using System.Collections; public class Game_Control : MonoBehaviour { private bool Spawn1=true; public GameObject...

How expensive is creating class instance? (performance considerations) [closed]

In C#, how expensive it is to create new class instance? I'm speaking in context of using C# in unity3d. Meaning that stuff continuously gets called many times per second. In C++, generally speaking (while making games) you may want to reuse anything you created with new/smart pointers, you would...

Scoring scale object

I started working with Unity platform just a few days ago. I want to create and object like this one: (http://www.bankingsense.com/wp-content/uploads/2014/09/credit-score-ratings.png) where the user will choose the appropriate answer. Each option will generate a different score that should be stored for later use. Can anyone give me some tips ad...

When building to mobile the size of fonts reduce and became very small

Like I said in the title when i built to mobile the letter became too small. I think it is because phone has more pixel for his little screen. Well I tried to fix text by simply making text to images in photoshop. But how can I make InputFields text...

Unity3D Bullet Tracers

I'm currently working on implementing the elusive bullet tracer to my FPS. It isn't going so well. a. The tracers align themselves off of the barrel of the Raycast area b. They all aim themselves in the same direction, no matter where I point my cursor This is the formula...

Unity: Android and iOS Push Notifications

I'm working on a mobile game with Unity and going to use push notifications. I found NotificationServices class that for iOS only. But I didn't find any server-side code examples for that class. I'm asking for any nice examples or solutions providing server and client-side code (Android client & backend...

Unity Cardboard on Nexus 6 bug: U.I of previous scene is remained on view when new Cardboard scene is loaded

I develop VR app by using Unity and Cardboard SDK. My first scene is a non-Cardboard-VR scene contains U.I dropdown list and confirm button. When I execute loadLevel() to the Cardboard VR scene, my previous U.I will still be remained on the view, in corrupted form, behind the rectangular VR...

Unity2D C# - Can't destroy an Instantiated object

public class playerAttack : MonoBehaviour { public bool attacking = false; public Transform Player; public Transform swordObject_prefab; Animator anim; GameObject clone = null; // Use this for initialization void Start () { anim = GetComponent<Animator> (); } // Update is called once per frame void Update () { if (!attacking...

Android - Unity3D freeze in splash screen on some phones

I have a problem with Unity3D. I created a game with Unity 4.6.2f1. My problem is, game crashes after splash screen(Like trying to open itself constantly). The weird part is, game works on my phones and my tablets perfectly. I have Nexus 5(With Android 5.1.1) , Iocean X7S(With Android 4.2.2)...

Why i can't see Fixed Angle option in Rigidbody2D in the new Unity5?

That's it, i can't see the option in the inspector. I saw it in the old Unity4 but i can't do it now in unity 5. Also, it is in the 5.10 version. Please help me, i'm newbie haha.

Unity 5.1 and OnGUI()

I had the following simple code working, before upgrading to Unity 5 but now nothing happens when I press the Space key! void OnGUI() { if ( Input.GetKey( KeyCode.Escape ) ) { GUILayout.BeginArea( new Rect(50, 50, 100, 100) ); GUILayout.Button("Exiting!"); GUILayout.EndArea(); } } The script is attached to an empty...

Giving objects unique ids onStart

I have a bunch of gameObjects that I am assigning unique ids to in the Start function. void Start() { UniqueID = String.Format("{0:X}", DateTime.Now.Ticks); } I thought this would work but every now and then I get duplicate ids. How can I make sure that they are always unique?...

How to Create Thumbnails in unity

I am creating a video player app for android. for that i need to create thumbnails for the videos present in the videos folder. After searching web i could able to understand unity's MovieTexture doesn't support for android. This one i could able to solve using a plugin. For creating...

Unity WaitForSeconds stuck

I tried to create a simple splashscreen. at first this waitforseconds working, but suddenly after a few week this code doesn't want to work. I tried using debug.log but I just get the "before wait" and the "after wait" doesn't appear even after 5 minutes. I am using unity 4.5,...

converting string to vector in Unity

I am trying to convert an array of strings in unityscript with values holding values like: "Vector3(5, 3, 8)" into an array of vectors, but Unity will not take these strings as is. Anyone have any ideas?...

Manual slide-in animation using delta time

I'm creating a simple slide-in animation for my game. The box is shown at the bottom with character dialog. The animation is supposed to look as follows: A square slides in from the left, then waits a bit, then expands to its full width. The box is made using Unity's...