How can i make an image to randomly appear while in-game in Unity3D ? It will serve as my popup advertisements for my game. I want to have ads without using AdMobs or any other plugins.
Depending on how you plan to display your images. You could write a script to randomly Enable a GUI Image, then have the GUI Image become disables after a specified time is over or by a button click (like a "X" symbol or close button).
My recommendation would be some mix of the following:
Create an UI Image GameObject. Use this as the main Advertisement GameObject.
Create a script to set this gameobject active/inactive randomly throughout the game. Place this script on an object in the hierarchy that will exist throughout the game.
Create a script that will be your advertisement handler. Attach this to your UI GameObject. In this you can create some sort of structure to hold different ads or however you plan to populate the ads. Then you can customize the way the ads will be displayed. Will it be random? Will it happen sequentially? Are there different types of ads?
Create logic to disable the gameobject based on a timer or by way of a close button.
If you get around to coding and have trouble, then please feel free to ask about the coding. Also, check out the Unity Forums for questions specific to Unity.
Related
I'm making a Unity2D mobile game but I'm stuck on making a menu. I want the in-game menu and if the player touches the screen or clicks the screen, the game will start and the menu will be have store, options but I don't know how to do it. I tried to do the same scene but this time when it goes to the next level, the menu disappears. I searched on the internet but couldn't find it. Thanks.
You should first create a UIManager script for yourself.
In this script, you must define 2D elements such as Text, Canvas, Panel and provide their functionality.
Then you can control these functions in your main manager (GameManager).
To put it simply, it takes almost a video tutorial to explain it.
Because this is not a simple code error question, man.
I just have a question and I don't know exactly what to type on google.
I am making a game which is always instantiating scenes now on my login process I am trying to login wrong account so there should be something that needs to pop up like an error message
Now my question is . Is there going to be a problem when I build this up because there's a tons of them or it is just normal?
But basically when i try to input the correct id and password this scenes will be deleted.
There shouldn't be a problem but this looks like an abuse of scene to me. You have too many unnecessary scenes.
Here is when you need to create or use a new scene:
1.Main Menu
This is the first scene that loads. By separating it with your game scene, you will increase loading time.
2.Game Levels
The levels in your game requires scene for each one. This makes loading them faster. You can also separate one scene into multiple ones if it's really a big scene. This also increases the speed of loading time.
You do not need scene for other things you have in your question. Those should be a UI Panels. You can create a panel by going to the GameObject ---> UI --> Panel menu. It's really easy to show/hide a panel.
For example, you have login and emergency panels:
public GameObject loginPanel;
public GameObject emergencyPanel;
to show the login panel, you disable or deactivate the emergency panel first then activate the login panel:
emergencyPanel.SetActive(false);
loginPanel.SetActive(true);
That's all you have to do.
I am currently working on a project that requires creating virtual buttons while the app is running and naturally assign an event handler to it to detect it being pressed/released.
I have tried all the solutions i found on Vuforia's forums and stackoverflow but the virtual buttons never worked. They get instantiated and a clone is made like I want but apparently the event handler is not assigned properly.
So my question is, is it even possible to create a virtual button after the app starts and assign a handler to it?
Either the button is a GUI button then, it would be a basic UI button from the uGUI framework from Unity:
https://unity3d.com/learn/tutorials/modules/beginner/ui/ui-button
The second is a button that is position in the scene, most likely along the model that you show on tracker found.
In this case, either use a world canvas button, similar to the previous one but with a world canvas or use a quad/box object and use a basic raycast as you would do in a normal game.
If you need them to show on track found, set them on and off just like you do with the model by listening to the OnTrackFound/Lost.
To register listener, it is explained in the video.
After too much research, I found out that creating custom virtual buttons after the beginning of tracking is not possible using the current Vuforia version.
The alternative I found is creating a unity gameObject (Cube in my case) with a box collider and a tag that could be pressed through the mobile screen of the app and using raycasting.
Would welcome answering any questions you have.
I am developing an app with vuforia Cloud Recos. I want to add the feature of allowing the user to pause the page so she does not have to keep pointing the device on the target to view the trackable. This is pretty useful when I want to show texts. Is there anyway to achieve that on Unity3D ? A good example is Microsoft's Here City Lens app which includes a button to pause the page as the screenshot shows;
You could take a screenshot of the screen and apply it to an Image UI object. That is if you do not need the camera feed anymore.
If you need interaction with the elements, I would only take a screenshot of the camera feed without items. Get AR camera transform, apply it to a new camera, disable AR camera.Then apply the screenshot to a background plane covering the whole screen. Keep items on as well and they do not listen to Vuforia anymore. You are pretty much recreating a basic Unity scene. The items should not be moving with Vuforia, the camera is. So they are still in the middle and you need to know where was the camera when you took the shot. Your scene is complete
I just created a very simple 3D game, and I used Unity UI for the first time.
Inside the game editor I can click the buttons and move the sliders.
I build the game for my android,and I can see all UI elements on my device but however, for some reason, I just can't use them.
Can you please help me and explain what am I doing wrong? Is it a bug?
I found the problem.
The Canvas element comes with "EventSystem" object. All I had to do is to check the CheckBox called "Allow Activation on Mobile device"...