Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Chaosgod_Espér

Pages: [1] 2 3
1
NGUI 3 Support / Get UILabel Y Size?
« on: January 14, 2016, 12:36:46 PM »
Hi there..

I want to change the position of UILabels in my Scrollview, to make them sit directly under each other.
The UILabels can be rewritten by UIInput, and so they can change in height (cause multiline).

So the Question:
How to get the current Height of a Label, to place the next directly under it.

Current approach:
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class UISetup_ReloadTextView : MonoBehaviour {
  5.        
  6.         private int ChildCounts, NewYPosition;
  7.         private Transform CurrentChild;
  8.        
  9.         public void UpdateView(){
  10.                 ChildCounts = transform.childCount;
  11.                 NewYPosition = 0;
  12.                
  13.                 GetComponent<UIScrollView>().ResetPosition();
  14.                 for(int looper1 = 0; looper1 < ChildCounts; looper1 ++){
  15.                         CurrentChild = transform.GetChild(looper1);
  16.                        
  17.                         CurrentChild.position = new Vector3(CurrentChild.position.x, NewYPosition, 0);
  18.                         NewYPosition -= (int)(CurrentChild.GetComponent<UILabel>().relativeSize.y * CurrentChild.localScale.y);
  19.                 }
  20.                 GetComponent<UIScrollView>().ResetPosition();
  21.         }
  22. }
Problem:
if Label1 has a Widget Y size of 48, Label2 is placed far below it (around 200)... instead of 48 :/

2
NGUI 3 Support / How to detect Mouse inside a specific Element?
« on: December 15, 2015, 01:48:25 PM »
Hi there,

after i created half of my Ingame Editor, i struggle with a Problem... See:


You see the Scrollview in the ledt Window, that holds the Tileset.
With the local position of the mouse position to world coordinates, i was able to calculate the clicked tile inside the view and placed the white cursor rect.

The Problem now:
The Editor registrates clicks outside the Scrollview, too.

So the Question is:
How to get a TRUE if the mouse hovers a specific UI Element?
like:
  1. if(mouseposition hovers Scrollview)
  2. {
  3.     //Cursorcode here
  4. }

Hint:
i tried UICamera.IsOverUI, but that returns true over EVERY UI.. like the Scrollview, the Window, each Button, Label..etc..  Bur not specified to one Element only..

3
NGUI 3 Support / Re: Getting Cursor Position to place a Sprite
« on: December 03, 2015, 12:48:38 PM »
Found a solution:

  1.         MouseOnScreen = Input.mousePosition;
  2.         TheCamera = NGUITools.FindCameraForLayer(gameObject.layer);
  3.         worldPos = TheCamera.ScreenToWorldPoint(MouseOnScreen);
  4.         localPos = transform.worldToLocalMatrix.MultiplyPoint3x4(worldPos);
  5.  
  6.         Debug.Log(localPos.ToString());

returns the exact position

4
NGUI 3 Support / Getting Cursor Position to place a Sprite
« on: December 02, 2015, 06:53:13 AM »
hi there..

Soooo..
Now that i managed to create a Scrollview, 2 Scrollbars and a Texture inside the View, i want to add a "Cursor" to the System.

Therefor i created a BoxCollider, that is covering the ScrollView Size exactly ( Size.x = 256, Size.y = 480).
So now, the Scrollview visible Field should be splitted into 32*32 pixel areas (i want to create a tilemapper). The CursorSprite has a Size of 32*32 pixels.
Means, Inside the ScrollView is space for 8*15 Tiles beeing visible.
A Tileset can be as large as wanted (power of 2) - so the ScrollView can be scrolled..

My Question now:
When i move my Mouse over the ScrollView, the CursorSprite should be placed over the current hovered tile on the tileset. I know there is UICamera.lastHit.point..  The BoxCollider Size is written above, but the Resulting Position of the lastHit.point is:
X between -1.8 on the left and -1.1 on the right
Y between 1.2 on Top and -0.3 on Bottom
Z stays 0..

How can i get the Pixel Position on the Collider?

here´s a current Screenshot:
http://fs5.directupload.net/images/151202/85ohvul6.png


The result should be:
if Mouse is covering Position "49,12,0", it should be placed at "(int)((49/32)*32)-16, (int)(((TileSetHeight-12)/32)*32)+16, 0" to cover the current Mouseover tile.

5
NGUI 3 Support / Re: Slider Thumb Placement is wrong - How to fix it?
« on: December 01, 2015, 09:55:16 AM »
The same problem is in the Examples..
It seems like the Thumb is always placed in the center of the Foreground.. 


Isn´t there a way to create a slider or scrollbar, where the thumb is at the outer edge of the bar, instead of this worng placed thing?


Edit: ugly workaround:

• Slider Main (UISlider, Background Sprite, Foreground Sprite, Thumb)
• • Background Sprite
• • Foreground Sprite with alpha 0, offset of Y -248
• • Foreground visible Graphic, with Y offset of -232 and no affect to the slider - just to show the red inner
• • Thumb (with BoxCollider)

It´s a bit stupid to need a transparent graphic as Foreground, to adjust the Thumb position, and a visible Foreground, to show something ._.

6
NGUI 3 Support / Re: Special Characters
« on: December 01, 2015, 05:01:13 AM »
Works like a Charm here..

Is the Font supporting those Characters?

7
NGUI 3 Support / Slider Thumb Placement is wrong - How to fix it?
« on: November 30, 2015, 05:43:26 AM »
Hi there..

I tried to create a Slider with this Sprites:
Background

Foreground

Thumb



I´m using the latest NGUI version, and created the Slider that way:
• create Empty child
• NGUI -> Attach -> Slider Script
• create the UISprites as children of the SliderObject
  (the Foreground and Background are sliced)
• All Widget privots are Center/Center
• The Thumb Sprite has a BoxCollider attached (with auto adjust size)
• Slider Directionis "Bottom To Top"

The Results:


What have i made wrong?

8
NGUI 3 Support / Block Objects in the Background of a PopUp
« on: March 05, 2015, 05:21:29 AM »
hi there..

I created a Root UI Object, that contains ALL the GUI of my game as children. To switch UIs, i use SetActive(true/false) to their WindowBG Object. So my Hierarchy looks like this:

Now, i created a PopUop Infowindow.


This should stay in the foreground when activated. And all Buttons or GUI in the Background should be blocked. Therefor i added a background Blocker. This is just a simple Sprite with a black background made with alpha set to 50 (of 255). So the background gets a little bit darker.
The Sprite has a Box collider attached, to cover the whole area.
To make the Sprite been set on a higher level than all the other UIs, i set its depth to 900. The Infowindow has a depth of 1000.




Now, when i SetActive the InfoWindow, the Window itself activates the Background Blocker.

BUT - all other Buttons can be highlighted and pushed again.. as if the collider isn´t there..


What could be wrong.. As if i remember right, NGUI uses thr depth value for the collider system..

And for testing (as you can see on my inspector Screen), i pushed the Background Blocker´s Z position in front of all others (expect infoWindow)
Means:
  1. Camera > InfoWindow > Blocker > Others


any ideas?

9
NGUI 3 Support / [Editor] How to call the Selectors?
« on: January 29, 2015, 03:10:24 AM »
hi there..

I wanted to know how to call the Atlas Selection window and a Sprite Selector.
I know theres DrawSpriteField, but no documentation about, how to use that, how to write a callback or how to create the atlas selection..

Can someone explain this Editor stuff?

10
NGUI 3 Support / Re: [Need Quick] Change a Labels Size via Script
« on: January 28, 2015, 08:02:49 AM »
AH
Thanks :)

11
NGUI 3 Support / [Need Quick] Change a Labels Size via Script
« on: January 28, 2015, 07:45:43 AM »
hi there..

As you know, in the Scene view, you can change the Labels Widged size by drag&drop the border.

I´m currently creating Playmaker actions for NGUI, supporting nearly every function to manipulate NGUI Elements, Create new at Runtime and search for em in the Scene.


The problem now is, that the localsize of the Widged is read only. So, is there a way to resize a widged at runtime?

12
As said - i DON´T Destroy.. i simply change SetActive

13
Hi there..

I want to SetActive a UI GameObject at Runtime. The Lines for that action are:
  1.         void OnTriggerEnter(){
  2.                 if(InteractSymbol != null){
  3.                         NGUITools.SetActive(InteractSymbol, true);
  4.                         InteractSymbol.transform.FindChild("Label").GetComponent<UILabel>().text = cInput.GetText("Interact");
  5.                 }
  6.         }
  7.         void OnTriggerExit(){
  8.                 if(InteractSymbol != null){
  9.                         NGUITools.SetActive(InteractSymbol, false);
  10.                 }
  11.         }

Now on a Testplay, Unity gives me the following Error:
[spoiler]
  1. Destroying GameObjects immediately is not permitted during physics trigger/contact, animation event callbacks or OnValidate. You must use Destroy instead.
  2. UnityEngine.Object:DestroyImmediate(Object)
  3. NGUITools:DestroyImmediate(Object) (at Assets/NGUI/Scripts/Internal/NGUITools.cs:1085)
  4. UIDrawCall:ReleaseInactive() (at Assets/NGUI/Scripts/Internal/UIDrawCall.cs:839)
  5. UIDrawCall:ReleaseAll() (at Assets/NGUI/Scripts/Internal/UIDrawCall.cs:827)
  6. UIPanel:OnDisable() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1014)
  7. UnityEngine.GameObject:SetActive(Boolean)
  8. NGUITools:SetActiveSelf(GameObject, Boolean) (at Assets/NGUI/Scripts/Internal/NGUITools.cs:1272)
[/spoiler]

The problem, as you can see at the Lines, is: I don´t destroy any object. I instantiated and Destroyed the Object, before i changed to SetActive - yes.. But i Changed it, saved it several times now.. But NGUI still thinks i´m destroying the Objects ._.

What´s wrong here?

14
NGUI 3 Support / Let NGUI Button pass int/string/bool arguments?
« on: November 19, 2014, 04:04:08 AM »
hi there..

Just a quick Question:

What would be the easiest way to let a Button pass ints, strings, bools, floats..etc a s argument to an onClick notifier?
Cause the "Arg 0" position in the inspector only allows Drag&Drop objects into, but not setting such values.

See:

http://fs1.directupload.net/images/141119/rvyr3cpy.png

15
NGUI 3 Support / Panel Soft clipping isn´t doing anything
« on: September 25, 2014, 11:25:23 AM »
Hi there..

I created a simple Chat Hierarchy:

UIRoot
>>Panel
>>>>Grid
>>>>>>Content
>>>>>>Content
...etc

I switched the Panels clipping to "Soft clip", but it isn´t doing anything..

I´m using unity 4.5 Pro, and the latest NGUI...

Any idea why it´s not working?


nevermind.. figured it out..

Seems like i needed to make the panel size smaller than the window size (1/3 of the window height), to make this effect work :/

Pages: [1] 2 3