Comments (3)
Hi @rahb3rt, there are a few things that could be happening here. For now, I'm going to assume that these items are all children of a HoverLayoutArcRow
.
By default, items built with HoverItemBuilder
will use a "ButtonRect" renderer prefab. The rectangular shape is not compatible with the arc layout. So, before calling PerformBuild()
, set the builder's "Button Renderer Prefab" property to a "ButtonArc" renderer prefab.
You're correct to attach the HoverShapeArc
component -- that component allows the parent layout to find and size/position the item.
When setting the transform parent, it might be helpful to do this instead:
radioButton.transform.SetParent(gameObject.transform, false);
The false
parameter here means that radioButton
will keep its local transform values (which would be initialized to zero position/rotation upon creating the new GameObject
) when moving to the new parent. The "arc" layout controls the item's X/Y positions, but does not touch the Z position. The item may be far away from the layout, then, if you don't ensure the Z value is set (or near to) zero.
An alternative approach to consider: Build an "example" radio item in the Unity editor, with all of the colors/settings that you want your radio items to have. Rather than using the HoverItemBuilder
in your script, you could use Instantiate(MyExampleRadioItem)
to build copies of your example item. You may want to deactivate your example item, so that it doesn't appear in your menu.
With this approach, you would likely need to update the label for each duplicated item. You should also take care with the item's events: it may be best to not add any events to your example item, and instead, only set events on the duplicated items (via your script).
I hope that helps! Note: I edited your comment to fix its code formatting. The generic types within the <...>
brackets were not being displayed.
from hover-ui-kit.
Hmm okay, that is a good idea. So I was able to build those buttons but now adding the events via script is what has me thrown off. I cannot seem to be able to grab those. Any ideas on how to do that? Sorry, still trying to adapt to Unity and automate these events so when these buttons get generated they come with the events that I want.
from hover-ui-kit.
What is it that you're trying to do with the events?
Something that has caused me confusion in the past are the UnityEvent.RemoveListener
and UnityEvent.RemoveAllListeners
methods. These only work on non-persistent listeners, which are listeners that have been added at runtime via code.
Events that are added at design-time via the Unity editor are persistent listeners, and these are harder to remove via code. You'll need to use the static methods in UnityEventTools
for doing this. However, because UnityEventTools
is within the UnityEditor
namespace, you can't use that code within an actual build.
So, if you're using the "duplicate an example item" approach, I would recommend not adding any events to the example item, so you don't have to remove them. Instead, add new events to each duplicated item using UnityEvent.AddListener
. Note that events added with this method will not appear anywhere in the Unity "Inspector" view.
from hover-ui-kit.
Related Issues (20)
- How do I add event listeners to an item? HOT 1
- I can't get started HOT 2
- How to attach the UI to gesture HOT 4
- Question about HoverInputSceneLoader HOT 1
- fail to update value from HoverItemDataSlider HOT 2
- Raycast on Finger HOT 2
- Trying example scenes with Vive HOT 2
- The type or namespace name `UnityStandardAssets' could not be found. Are you missing an assembly reference? HOT 2
- Interaction with Unity UI HOT 1
- TreeUpdate is Glitching Out when using a slider HOT 4
- Multiple Depricated Dependencies HOT 22
- Registering hovercast events HOT 2
- Hololens input HOT 1
- How to use OVR Grabber with the module? HOT 1
- "Hover Layout Arc" doesn't spread child GameObjects but keeps them piled on top of each other HOT 2
- Sprite swap by hovering HOT 3
- Add support for Oculus Hand Tracking *Feature request*
- Support for Unity's XR Interaction Toolkit? HOT 1
- error CS0234: The type or namespace name 'ImageEffects' does not exist in the namespace
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hover-ui-kit.