Giter VIP home page Giter VIP logo

Comments (3)

zachkinstner avatar zachkinstner commented on May 23, 2024

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.

rahb3rt avatar rahb3rt commented on May 23, 2024

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.

zachkinstner avatar zachkinstner commented on May 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.