unity3d-ui

Horrors of OnPointerDown versus OnBeginDrag in Unity3D

杀马特。学长 韩版系。学妹 提交于 2019-12-18 01:34:07
问题 I'm concerned over the difference between OnPointerDown versus OnBeginDrag in single-finger movement code. (In the latest Unity paradigm of using a physics raycaster: so, finally, Unity will properly ignore touch on the UI layer. So from 2015 onwards what you must do is this: Forget about the crap traditional Input or Touches system which are pointless crap and don't work Add an empty game object with a usually BoxCollider2D, likely bigger than the screen. Make the layer called say "Draw".

Horrors of OnPointerDown versus OnBeginDrag in Unity3D

牧云@^-^@ 提交于 2019-12-18 01:34:07
问题 I'm concerned over the difference between OnPointerDown versus OnBeginDrag in single-finger movement code. (In the latest Unity paradigm of using a physics raycaster: so, finally, Unity will properly ignore touch on the UI layer. So from 2015 onwards what you must do is this: Forget about the crap traditional Input or Touches system which are pointless crap and don't work Add an empty game object with a usually BoxCollider2D, likely bigger than the screen. Make the layer called say "Draw".

How do I put controls on screen?

送分小仙女□ 提交于 2019-12-17 16:41:42
问题 I am working on a project using Unity/Vuforia to build an Augmented Reality app for Android and need some help. I have a ball appear on screen when the imagetarget is found. I cannot figure out how to get the ball to move around. I can use virtual buttons, but am looking to find a way of having the forward/back/left/right buttons (or a joystick) on the android screen which will control the ball. Can anyone offer any advice or point me in the right direction? I've been searching for hours and

How do I put controls on screen?

一世执手 提交于 2019-12-17 16:41:32
问题 I am working on a project using Unity/Vuforia to build an Augmented Reality app for Android and need some help. I have a ball appear on screen when the imagetarget is found. I cannot figure out how to get the ball to move around. I can use virtual buttons, but am looking to find a way of having the forward/back/left/right buttons (or a joystick) on the android screen which will control the ball. Can anyone offer any advice or point me in the right direction? I've been searching for hours and

How to make custom Unity LayoutGroup expand to fit contents

偶尔善良 提交于 2019-12-13 04:27:44
问题 I am attempting to use a custom FlowLayoutGroup as described in the answers of this question ( also up on GitHub) in a situation where it needs to resize vertically to contain it's children. My setup looks like this: ScrollableRect Panel with VerticalLayoutGroup comp (content of parent scrollrect) that should resize vertically to fit children: Panel with FlowLayoutGroup that should resize vertically to fit children Panel with FlowLayoutGroup (2) also must resize... etc... I have added a

Button `OnSelect` not functioning in Unity.UI Canvas situation

☆樱花仙子☆ 提交于 2019-12-11 04:56:50
问题 I have three buttons, when you tap one button, a panel with a text appear. The problem is when I attached the script, nothing happens. The "click" is registered but the the panel never appears. My script is attached to each of the button and is something like this: public GameObject panel; //i use to put the panel in unity bool selected = false; void Start () { panel.SetActive(false); } void OnSelect() { selected = !selected; panel.SetActive(true); } I probably have to do something else with

Unity3D, build PNG from Panel of a Unity.UI?

本小妞迷上赌 提交于 2019-12-04 01:01:36
问题 Think about any Unity.UI Canvas you might have. Imagine a typical Panel on that Canvas. Say it happens to contain some images, maybe some Text and so on. It would be very handy if you could turn that panel (only the panel) in to a screenshot: a Texture2D or PNG. The only thing I can think of is just using ReadPixels and figuring out the area of the Panel in question on the screen (and actually that is pretty tricky); and that only works if the panel happens to be square and not rotated at an

How to make an invisible transparent button work?

谁说胖子不能爱 提交于 2019-12-03 07:36:23
问题 Looking at some of the answers in the Unity forums and Q&A site, the answers for how to make an invisible button do not work because taking away the image affiliated with the button makes it not work. How do you get around this and keep the invisible property while allowing the button to actually work? 回答1: This is one of those weird things about Unity... 100% of real-world projects need this, but Unity forgot to do it. Short version: You need Touchable.cs in every Unity project: // file

How to make an invisible transparent button work?

 ̄綄美尐妖づ 提交于 2019-12-02 21:07:07
Looking at some of the answers in the Unity forums and Q&A site, the answers for how to make an invisible button do not work because taking away the image affiliated with the button makes it not work. How do you get around this and keep the invisible property while allowing the button to actually work? This is one of those weird things about Unity... 100% of real-world projects need this, but Unity forgot to do it. Short version: You need Touchable.cs in every Unity project: // file Touchable.cs // Correctly backfills the missing Touchable concept in Unity.UI's OO chain. using UnityEngine;

Get correct position of letters using cachedTextGenerator

空扰寡人 提交于 2019-12-02 11:12:43
问题 Consider a Text with many paragraphs of text. It's easy to find where a certain character is , using UICharInfo. Example, find all newlines... TextGenerator tg = text.cachedTextGenerator; int kText = tg.characterCount; for (int i=0; i < kText; ++i) { if ( text.text[i] == '\n' ) Debug.Log("found a newline at " + tg.verts[i * 4].position.y); } This gives the correct ratios but they are all out by some scaling factor . It seems to depend on many things (screen shape, pixels, settings and more).