I am using Unity with Bolt visual scripting and having some issues. I have a 2d Mobile App and basically what I want to do is when the user touches a sprite it starts spinning on every axis. Although I am able to achieve it without the user touching the sprite from the update function.
I want to achieve this through the touch in mobile. How can I do this? There is no on-button click.
Well, I solved this by making a button and changing its image from the source image to a particular shape .png and then I was able to perform on Click Function.
Related
I have been trying for several hours to fix a button for a group project with no luck. I have the basics such as the object being a child of the canvas, graphics raycaster, button script, event system, etc.
There is no code going into this at the moment. Everything is done strictly with Unity's canvas and buttons. Upon clicking, the image should disappear, but it doesn't. The event handler does not register anything when the mouse hovers over the image.
I have looked through several posts on the Unity forum to try and find an answer that would work and none have helped.
The problem was I needed to attach a camera that would be looking at the canvas to the "event camera" of the canvas component. This can be seen in the below image.
In my case, I had rotated the image (on Canvas) to 180 degree and was trying to perform click which did not work. But as soon as I set the rotation to 0 degree the mouse click detection started working.
I had a similar issue. In my case, I had a canvas all setup, but I did not have an EventSystem in the scene graph.
Create -> UI -> EventSystem
This was the solution for me.
I used NGUI (free edition) in unity 4.x for GUI design. Now unity has its own GUI in 5.x. Is there any easy way to implement GUI animation with unity GUI?
For example, in NGUI,
I can easily move, rotate or scale a GUI element or make some fade-in and fade-out effects.
I can trigger the animation with buttons or hotkeys.
I can easily set the function to run when the animation finish.
How can I implement these with unity GUI?
You can animate GUI objects like every other object in Unity. Just attach an Animator and a Controller, add a parameter, and make an animation in the Animation window in unity. On button press can be done in a script, if you want keyboard input. Or with a function call - to a script - if you mean a GUI button.
Animation window can be found in Windows -> Animation
Ill add an example if needed.
An example of the controller:
Keypoints: The Trigger parameter, as the condition in the transistion into the animation state.
This makes it possible to add this line into the code:
anim.SetTrigger("Fire");
To play the animation.
Animation window:
Last but not least, ill add a video guide: https://www.youtube.com/watch?v=JeZkctmoBPw If that one wasnt good enough, one can always click around.
Unity GUI works in a different way to most GUIs. Instead of setting up a button which then remains there until ether you tear it down or user interacts with it, on every frame it asks you to draw the GUI objects.
So animation is inherent. If you want a button to flash, simply draw it in a different colour every ten frames or so. If you want it to move, update it's x, y co-ordinates.
I'm developing a toy object visualizer with Unity 3D and Google VR (specifically Cardboard). I'm using the default, Google-provided, GazeInputModule to allow the player to interact with the app UI. When the reticle is not over a UI element or a clickable 3D object, and the trigger is held pressed, I'd like it to cause the camera to rotate around the center of the object that's being looked at when the user moves his head (instead of rotating around its own center).
So what I basically need is a way to catch trigger events that happen over empty space or unclickable objects. How would one go about doing that?
I've tried looking at the Unity EventSystem docs and the Google GrazeInput docs but I'm not sure how to make it work in my case. (I don't need detailed code, I'm mostly not sure where to start).
I'm working with the Google VR Unity SDK and I'm trying to create a VR application where users can switch between multiple ambients(places). I want them to switch to a different ambient just by pushing down the magnetic sensor of the cardboard, pointing anywhere. My problem is that every link (like this one) I've found, works with objects selection. I've tried adding an Event Trigger to my Main Camera and adding a Mesh collider to my building but none of them worked.
So, ¿is it possible to listen for the magnetic sensor pushdown in the full scene without having to select an object?
Turns out it's simpler than I thought.
if(Input.GetButtonDown("Fire1")){
//some code
}
Thing is googleVR removed magnetic button support since version 0.9.0 and I was using 1.0.3. So if you want to implement a trigger for cardboard's magnetic button you need to use v0.8.5.
You could put up a Canvas that's attached to the camera in World Space, so that it always stays in the line of sight. Add a Button to the canvas at the location where the gaze input cursor is, and you should always hit that when triggering.
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.