How to add the new unity uxml(via ui builder) to game screen? - unity3d

I installed the new Unity UI Builder. Everything works just fine...
But how do I add the uxml to my scene or how do I attache it to camera?
I tried to drag and drop the uxml to camera and I searched for a component, but I couldn't find anything... Is there any official documentation?

You must use an gameObject with PanelRenderer.cs attached to it:
For now, I only know you have to set UXML file and USS file. In play mode, by magic (I still don't understand how unity does it), it will render.
In the Github project you can see how things are for now. UIElementsUniteCPH2019RuntimeDemo
EDIT:
The project linked above uses UI Builder 0.8.

Runtime support is still not available using the packet manager.
You can add the preview version to your project by adding the following line to your manifest.json (it's located in the projects Packages-folder)
"com.unity.ui.runtime": "0.0.4-preview"
You may want to check whether a newer version is available.
Keep in mind that the preview version is intended for previews only. The api and workflow might change with newer versions.
Once runtime support is enabled you can use the Panel Renderer as described above.

In Unity 2021.2, when you add a UI Document to the hierarchy, a PanelSettings asset is automatically created and assigned to the that UI Document.
Simply add your uxml file to the UI Document -- there is no Panel Renderer component anymore.

Even though the UI Builder offers a preview of the menu over the actual game scene, there is no way to use that menu in a game using Unity's functionality or packages. To do that we need to use the code that comes with the demo by Damian Campeanu from Unite Copenhagen 2019 that you can find here: https://github.com/Unity-Technologies/UIElementsUniteCPH2019RuntimeDemo.
The demo has following structure.
Structure of the project
The files that we are interested in are located in Assets/UIRuntime folder. Simply copy this folder into Assets folder of your project.
After copying the the folder,create empty game object, and add two components in the inspector. Panel Scaler and Panel Renderer.
Game menu object with panel scaler and panel renderer components
Panel Scaller is responsible for scalling your menu for the display. Choose "Constant Physical Size" and 96 for both Reference and Fallback DPI. Those are the values from the original demo and 96 DPI is a typical pixel density for most computer screens (it is different on mobiles and high density screens).
Panel Renderer is the place where you will set your UXML and USS (Unity Style Sheet) files (Uxml and Unity Style Sheet fields. Leave the last two of fields empty, and tick the "Enable Live Updates" checkbox. This will enable you to show the updates in the game viewport as you make them.
I wanted to comment under existing answer by Pablo but I'm new so I can't.

Related

Hololens 2/Unity Error: A material (Instance)(Instance)... which is already instanced was instanced multiple times

I have instanced a simple scrolling menu prefab in my scene (prefab provided by MRTK2 with just one menu option available). I have a button in the scene that when clicked will either SetActive(true) or SetActive(false) on this menu to show/hide it. When the menu is SetActive(false) and then SetActive(true) it provides the sequence of errors depicted in the picture below. I've found this thread that may be related but ultimately I don't know what this error means or how to fix it.
It seems that all of these errors are w.r.t. components on objects in the menu that existed from the prefab, so I'm confused as to why these errors are happening. I tried to replace the components with their MRTK counterparts as I was reading somewhere that MRTK versions of shaders, etc. are more efficient and was hoping that maybe they would simply solve the issue (they haven't).
For example, it seems that the error regarding MRTK_PressableInteractablesButtonBox (Instance) (Instance) is the shader on the FrontPlate of the button in the menu option.
Similarly, the error regarding sequisb SDF Material (Instance) (Instance) is the FontAsset on the TextMeshPro under the menu option's IconAndText object.
Unfortunately, my solution doesn't provide an explanation as to what caused my original error. However, I was able to get everything working by simply scrapping the old menu and recreating from the same prefab. I guess cross-wiring must have occurred at some point that I was unable to trace down. Ultimately, all I needed was a scrollable menu with a click event listener and buttons with custom meshes...all of which seem to be working fine now.
Thanks to #Zuocheng Wang and #derHugo for pointing me in the right direction (i.e. that things "should" work essentially out-of-box for the desired functionality).

is it okay to use loadOverlay() in a restartless addon?

Firefox addon. I'm porting an existing addon to a restartless one. I have a panel with a lot of UI elements (mostly boxes/description and images) in it, and it is very convenient for me to define the panel elements in an XUL overlay file. I will have lots of bloated js code if I don't.
The panel element (parent) itself is created in code dynamically, and then I use loadOverlay, wait for the 'merged' event and then append the panel element's children from the overlayed document. I also make sure that the elements are cleaned up upon a remove.
However, using overlays will most probably won't pass an AMO review. And some of the reasons I think are :
In most cases overlay elements will cause problems while removing (eg: toolbar buttons remembering their positions etc.)
There are problems with attaching js/css files in an overlay file.
loadOverlay is buggy (496320, 330458)
And here are my inferences :
loadOverlay() API itself is not deprecated - in fact it is 'not frozen and may change later' - which means possibly it will be use-able in future.
The bug that a second overlay load fails, is not applicable in my case, as I don't initialize without an overlay merge.
Using static overlay for preference windows etc. is perfectly acceptable as of now.
The panel in my case behaves a lot like a preference window (which is brought up on demand and cleaned up upon addon removal)
I don't have any js/css attached to the overlay, nor any event listeners for the elements. The overlay is only used to define boxes and description text - nothing more.
So considering these, is it acceptable to use overlays and loadOverlay() for a restartless addon ? If not, is there an alternative ?
About overlays, by checking source code of restartless addon that extend existing addon (like ehh), I see the overlay.xul is auto merged with the existing addon's. So it shouldn't be a problem to use overlay.

What is a CQ5 overlay component?

I've been asked to create a CQ5 "overlay" component by simply copying the out-of-box component from /libs/foundation/components/flash to /apps/myproject/components/flash. My question is: what happens to the original - is it just ignored?
a CQ5 "overlay" leverages sling rules for resource resolving. if /libs/foundation/components/flash needs an overlay, you "overlay" the corresponding file at location /apps/foundation/components/flash/filename This will CHANGE how the foundation component behaves in all instances. And the existing sidekick component remains, but behaves differently.
If you have a NEW component at /apps/myproject/components/flash, it can inherit from the foundation component via sling:resourceSuperType on the new component. In that case, you have a new component in the sidekick. In your new component, you could use the same values for jcr:title, componentGroup, or you could change them to distinguish your component in the sidekick. If the title, componentGroups are the same, the sidekick can distinguish them with parenthesis around the webapp (foundation) vs (myproject). However, I have seen situations where it is impossible as an author to distinguish them.
It is not ignored. Both components can show up in the authors' sidekick -- one will say flash (foundation), the other flash (myproject). When one of these is used by an author CQ will instantiate appropriately. The usual rules apply for what shows up in the sidekick (group name, selected in design mode, etc.)
Just to clarify: overlay and flash are two different things.
Sample of overlay implementation: http://jquerytools.org/documentation/overlay/index.html
So if you were asked to create an Overlay component, copying a Flash one might not be the best idea.

using unityscript to write a popup for unity 3d based app for ios

I am trying to write apopup plugin for my unity 3d ios based app, I want to write a plugin that will create a button that will open a new window, and in the new window put a link to a website. I know how to generate a button, but then I get stuck, help any body ?!, thanks.
In case you understand plug-in as a set of GUI elements, you can use the new ModalWindow (v4.1.2) or make your very own custom via the GUI class.
http://docs.unity3d.com/Documentation/Components/GUIScriptingGuide.html
http://docs.unity3d.com/Documentation/ScriptReference/GUI.html
In case you don't like UnityGUI, you can get some other third-party libraries to get your job done, as NGUI: http://www.tasharen.com/?page_id=140
Take a look at Unity's Asset Store for more packages.

How to make a repeatedly scrolling background cocos2d (iPhone)?

I'm extremely new to cocos2D development and I have hit a problem with my background. I want it to repeat scrolling every 2000px so I have looked around and found this (in this tutorial):
[_backgroundNode incrementOffset:ccp(2000,0) forChild:background];
I have set this up in my program however it doesn't recognise the method 'incrementOffset'. Is there something I'm doing wrong? I have imported "CCParallaxNode.h", however it says I need to import "CCParallaxNode-Extras.h" which doesn't exist?!
To quote the tutorial:
I’ve created a category on CCParallaxNode that you can use to solve
this problem, which you can find in the resources for this project in
the Classes folder. Drag CCParallaxNode-Extras.h and
CCParallaxNode-Extras.m into your project, make sure “Copy items into
destination group’s folder” is checked, and click Finish.