This is a tutorial series made by Mary D. Kidd, she will add whatever she likes, but you can always ask her about a personal request following the link
This Gameplay System consists of a Game Object with the capability of identify wheter the player hovers the mouse pointer over it, it reacts to clicks and an action will be prompted.
The tutorial is special for those above no0b level in Unity 3D, those who know their way around the Unity interface, inspector and other basics aspects of it.
To begin with the tutorial, it is necessary prepare a GameObject made with a Mesh model imported into Unity 3D (an .fbx from Autodesk, Blender, Solid Works, Inventor, Zbrush, etc.).
In this case, I called it Clickeable Object, I put it in front of a camera so it could be visible for the player. In this demo I used a 2D camera system, but the object keep being 3D, the same with its environment and you can even use it with a 3D rotational camera.
Floating over the Clickeable Object I put another Game Object called “Título” (“title”), made out of a 3D Text object, which possess a Text Mesh Component and displays a floating text in a 3D space without having to use a GUI Canvas.
This text will serve as the title that displays the name of the Clickeable Object, it can be switched for an instruction, advice, icono, graphic or whatever you like and/or need.
Next thing I put the content of the text that displays when you click over Clickeable Object. In this case I used a Unity 3D GUI Text, which requires for you to set an EventSystem and a Canvas on the scene.
All the GUI objects that you may want to display In Game should be inside the Canvas, they can even be anchored by their limits to preserve the Aspect Ratio and the proportions even though the displaying screen change. It´s wonderful!
This interface consists of a gameobject with a Viewport Component, which is inside a gameobject with Scroll Rect Component (Clickable Object GUI), which allows the player to scroll across the content from one side to the other (it doesn´t serve any major purpose here, just for fun and education!). In its contents there is the “cerrar” (“close) button (any normal button in Unity 3D GUI), plus a GUI text object with the content to show and a title (the same with the 3D text). Many uses of this system consists of NPC dialogues and names, interaction advices and more.
A final component of this system is the object “Fondo” (“background”), which gives a better visualization of the content displayed with the mouse click, this with the intention of hiding the rest of the universo besides the text, controls, etc. Moreover, it prevents the player from accidentally clicking over other clickable objects in the scene.
However, the same Viewport component can be modified to supply this same function, even adding customized images. You can opt to anchor the background image to the camera, so it will travel accompanying the player wherever it goes.
With all this objects ready in the scene, you can proceed to add the given C# script “Menu Click On Object” to the Game Object Clickable Object (you can consult how does it works inside of it, just open it with monodevelop).
The things to add in the script are as follows:
Advice- “Título” object.
Info spaces- “Contenido” object.
Blockage- “Fondo” object.
And that´s all! Just click Play and enjoy the game!
Aditionally, you could add a GUI element that indicates a given scene object is a Clickable Object, in this tutorial I used a simple signaling arrow with text, but you can implement whatever you like with better graphics!
Don´t forget to check out the Live Demo and the download Itch.Io page!…
Chaozz, ¡Happy codification!
Author´s note: I have begun translating some content from this site so my English speaking friends can enjoy it too! If you have a request for something that is not translated yet, you can ask me here…
Thanks for reading and I hope my translation is not too muddy, but If you spot something off, make me know in the comments, and if you can, help me translate other content, I will credit you and even advertise you if you want! ;D