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.


Topics - Chaosgod_Espér

Pages: [1] 2
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 / 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.

4
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?

5
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?

6
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?

7
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?

8
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?

9
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

10
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 :/

11
NGUI 3 Support / NGUI + German umlauts via WWW.text
« on: April 11, 2014, 04:07:04 PM »
hi there..

Today i tried to create a Textviewer. This Window loads a *.txt file via WWW, and sets a Label.text to the loaded one.
The code works.. but the text is shown up with the black diamond "?", instead of ßÄäÖöÜü

So i saved the file as UTF-8 TXT.. it worked..

Question now - is there a way to auto-convert those signs?

12
NGUI 3 Support / Updating the ScrollView gives Errors..
« on: March 13, 2014, 05:16:08 PM »
Hi..

Today i tried to add Components to my UIGrid at runtime.
The grid is child of a scrollview (to clip away on scrolling). And the Contents are childrens of the grid.
See:


Now i add content to the grid via Instantiate, set the Grid.transform as Parent, and update the grid via Reposition().
The instantiated contend is scaled up to 240*240*240. But that was solvable with resetting the localScales.

But at runtime, i get this Error:
Quote
NullReferenceException: Object reference not set to an instance of an object
UIScrollView.UpdateScrollbars (.UIScrollBar sb, Single contentMin, Single contentMax, Single contentSize, Single viewSize, Boolean inverted) (at Assets/NGUI/Scripts/Interaction/UIScrollView.cs:488)
UIScrollView.UpdateScrollbars (Boolean recalculateBounds) (at Assets/NGUI/Scripts/Interaction/UIScrollView.cs:459)
MainScript+<GetContent>c__Iterator4.MoveNext () (at Assets/Scripts/MainScript.cs:216)

Did i miss something in order to create a dynamic list of objects in a scrollable grid?

13
NGUI 3 Support / Can´t get the "fit screen resolution" to work
« on: May 27, 2013, 12:55:26 PM »
hi there...

i´ve created a simple Loading screen with the latest version of NGUI.
It contains
• background image (1920*1080)
• a small Loading Image (shown in a frame on top of the background)
• 3 labels to show text
• a slider as loading bar

All together looks like this on maximum resolution:

http://www.imagesload.net/img/Loading_Screen1.jpg

and this is the hierarchy:

http://www.imagesload.net/img/Unity_intern.jpg

My problem now - i worked myself through 5 tutorials. One sais i should deactivate something like an "automatic" option and setup anchors..etc (i´ve no "automatic" shown in any GUI object - dunno where to find this..), others are just.. annyoing short..  not good for beginners..
So..
How can i scale my whole GUI to fit the whole screen on any resolution from 1024*768 to 1920*1080?
UIStretch is just working for each widget itself - when i scale down the resolution - the whole positioning is going crazy... don´t let us speak about scaling :(

i really need help..

14
NGUI 3 Support / Layout Errors with NGUI and Unity Layout
« on: April 04, 2013, 03:02:17 PM »
hi there..

I imported several Assets. The list:

NGUI, Liquid particles, PlayMaker, Toon Explosions

Every Asset is updatet to the latest version. I´m using Unity 4.1.0f4 (free).

Today i started Unity.. And all my saved Layouts are corrupted. Each one is set back to the default Unity Layout, with "failed to destroy view" and more errors in the console.

So i reimported all assets - works now. But i´ve still this Error in the Console:
  1.         Layer index out of bounds
  2.         UnityEditorInternal.InternalEditorUtility:GetLayerName(Int32)
  3.         UnityEditor.EditorGUILayout:LayerField(String, Int32, GUILayoutOption[])
  4.         UICreateNewUIWizard:OnGUI() (at Assets/NGUI/Scripts/Editor/UICreateNewUIWizard.cs:43)
  5.         UnityEditor.DockArea:OnGUI()

The Error stacks in the console everytime i switch the windows. So.. I´ve the same error 20-30..etc times inside the console - and i´m able to clear it. But it appears again when i change window or do a testplay ._.

Does Someone know why this happens - and how to solve this?

15
NGUI 3 Support / Make 3D Object inside a Button (orthographic)
« on: December 10, 2012, 06:19:08 PM »
hi there..

i managed to create Buttons at runtime. Now i´ve a new problem..

I want to show a 3D model (rotating) inside a Button. AND, the objects mesh should only be visible inside the Button (no overlapping).
Means, i need a Window, where the object is placed in. and the window needs to be child of the button.

I tried it with a second, orthographic, camera. But it seems like it´s not possible to change the cameras size to have square form (instead of the aspect ratio rectangle).

I can´t use Render textures - cause i´m using the Free version of Unity.

Any idea how this could work?

Pages: [1] 2