Revisado con versión: 2017.4
In this section, we cover very quickly a few fundamental concepts of the Playground. If you are new to it, you can use them to create more complex games. Before you read through these, we suggest you go through the step-by-step tutorial.
Info and Warnings
All of the custom scripts in the Playground feature a small info box at the top, which explains in a few words what the script does.
Info and a warning in the Camera Follow script
Similarly, many scripts have several warning messages (the ones with the yellow danger sign) which appears when something is not right with the setup. Keep an eye out for these, they might give you a good pointer on why a script is not working.
Collisions and Triggers
Almost all of the logic scripts in the Playground use collisions to create gameplay. This means that things happen when 2 objects with Colliders touch each other, or when an object with a Collider enters another object (which also has a Collider, but marked as Trigger).
So for instance you can have damage that happens on collisions with an enemy, win a level when touching an object, collecting coins and powerups by walking into them, or open a door by smashing the character into it - provided you have the right key!
Similarly, you can trigger a line of dialogue when your character enters an area in front of another character (like in the Roguelike example scene).
When something doesn’t work as it should, ask yourself: did I add the appropriate colliders?
Tags allow us to divide object into categories, so that scripts can perform actions only if they touch the right objects. Without tags, there wouldn’t be a way to differentiate between objects.
As with collisions, many scripts depend on the object to be tagged with the right tag to work. If you are in doubt and your script is not doing what it should, read the Reference Guide to check if you are missing a crucial tag.
Importing Custom Graphics
The Playground contains a lot of great sprites to play with, located under the Images folder. However, you are free to use any 2D graphics you can find, or make your own!
To use an image in the Playground, you just need to drag it somewhere into the Assets folder. The image will be imported as a Sprite, and then will be ready to be used. Simply dragging it to the Scene or the Hierarchy will create a new GameObject, and then you will be able to use it in the game.
Just remember that to look good, images that are not square need to have transparency, otherwise they will display a white background. Good formats that allow transparency are .png or .gif, while .jpg won’t include transparency. Also remember, Unity doesn’t play animated Gifs.