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

Pages: [1] 2
1
NGUI 3 Support / Sprite does not contain a definition for 'border'
« on: February 09, 2015, 05:12:04 PM »
Hey there.

Imported the latest nGUI Version to my clean new 4.3.X Unity PS Vita Project and got these two errors:

  1. Assets/NGUI/Scripts/Editor/UI2DSpriteEditor.cs(42,46): error CS1061: Type `UnityEngine.Sprite' does not contain a definition for `border' and no extension method `border' of type `UnityEngine.Sprite' could be found (are you missing a using directive or an assembly reference?)

  1. Assets/NGUI/Scripts/Editor/UI2DSpriteEditor.cs(42,46): error CS1061: Type `UnityEngine.Sprite' does not contain a definition for `border' and no extension method `border' of type `UnityEngine.Sprite' could be found (are you missing a using directive or an assembly reference?)

2
NGUI 3 Support / Show UILabel/Sprite above Player?
« on: April 17, 2014, 05:02:33 PM »
We're working on a 2D game, and sometimes our Character talks with others while the Main-Camera is centered.
We want them to have Speech-Bubbles with Text above their heads.
We thought it would be nice to achieve that with NGUI.

Is there a quick way to display an UILabel/Sprite from UIRoot and it's camera over the position of the 2D-Player-Sprite and his MainCamera?

3
NGUI 3 Support / How long was a button pressed?
« on: March 11, 2014, 11:20:48 AM »
Hey there!

Is there a nice way to measure the time while pressing a button?
Meaning: When I press and hold a button a "timer" should go off and if it the button is pressed long enough something happens.

I searched the forums already and only got some older postings where recording the time in OnPress and checking it in Update was suggested. A legit and good idea, but here's the thing:

When the button is pressed long enough there should "popup" another GUI-Window (Widget, Sprite etc.) with a label asking the Player something specific.
I wanted to achieve this with Coroutines and NGUI-Tween-Events. Coroutines don't work properly in Update() and I don't want to add Events every frame in Update() while the "timer" fulfills the condition.


  1. void OnPress(bool pressed)
  2. {
  3. if(pressed)
  4. {
  5. // I know this won't work, but I add it anyways, so you get my idea:
  6.  
  7. timer += Time.deltatime;
  8.  
  9. if(timer >= x)
  10. {
  11. // Start Coroutines
  12. // Do cool Eventstuff
  13. }
  14. }
  15. }


Any suggestions? :)

4
NGUI 3 Support / Problems with Atlas-Creation
« on: March 07, 2014, 08:47:49 AM »
Hey there.

Today some weird stuff is going on with the Atlas-Creation.

1. Completely empty Scene. Imported latest NGUI Version.
2. Added some Sprites (.PSD Files) to my Project
3. Opened up the Atlas Maker, selected all the Sprites and hit "Create"
4. Hit on "View Sprites" and got this:



Clearly this is not what I want.

And another thing. Sometimes this isn't even working, the results above are the "best" I could achieve today. Almost 50% of the time the Atlas isn't created and I get an MissingReferenceException regarding "Texture2D":

"MissingReferenceException: The object of type 'Texture2D' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Texture.get_width ()
UIAtlasMaker.PackTextures (UnityEngine.Texture2D tex, System.Collections.Generic.List`1 sprites) (at Assets/NGUI/Scripts/Editor/UIAtlasMaker.cs:144)
UIAtlasMaker.UpdateTexture (.UIAtlas atlas, System.Collections.Generic.List`1 sprites) (at Assets/NGUI/Scripts/Editor/UIAtlasMaker.cs:531)
UIAtlasMaker.UpdateAtlas (.UIAtlas atlas, System.Collections.Generic.List`1 sprites) (at Assets/NGUI/Scripts/Editor/UIAtlasMaker.cs:646)
UIAtlasMaker.UpdateAtlas (System.Collections.Generic.List`1 textures, Boolean keepSprites) (at Assets/NGUI/Scripts/Editor/UIAtlasMaker.cs:629)
UIAtlasMaker.OnGUI () (at Assets/NGUI/Scripts/Editor/UIAtlasMaker.cs:976)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
"

I also tried to delete and reimport NGUI, but it didn't help at all :/


EDIT_01:

Just tried this on a completely new and empty Project. Same stuff. It's working with weird results or it doesn't and gives me this error.

5
NGUI 3 Support / Label in "Default"-Layer looks weird
« on: February 18, 2014, 11:41:25 AM »
Hey there.

So I wanted to use some Labels outside my UI because nGUI has that neat "ShrinkContent" option I like to use when the language of the game changes. Of course there is text outside the UI like speech bubbles or signs and so on.

1. I made an empty GameObject (Default-Layer) and attached the UIPanel to it
2. Created a Label-Object which immediately was set as child of the Panel, good so far.
3. Writing the text
4. Weird behaviour started when I try to change Dimensions

This is what it looks like when I create it and write something down


And this is what it looks liek when I change the dimensions to something like 8x4



What am I doing wrong?

6
NGUI 3 Support / Using NGUI-Components in a different layer?
« on: January 27, 2014, 01:52:19 PM »
Hey there,

(Using the latest NGUI Version)

In older Versions, like NGUI 2.X, it was possible to use the components on empty GameObjects in different layers and not the specific created Layer for the UI.

Now, when I create an empty GameObject and attach any NGUI-Component it automatically is made a child of my UIRoot and changes immediately the Layer from Default to my GUI-Layer.
I would like to use some Components from NGUI IN my Default-Layer like the Label-Component to write some Text in the Level.

A nice solution to this?

7
NGUI 3 Support / Huge Framerate-Drop when Menu Shows up
« on: January 25, 2014, 09:37:24 AM »
Hey there.

(Using latest NGUI Version)

Currently I'm working on optimizing the UI (refering to this topic here: http://www.tasharen.com/forum/index.php?topic=7763.0)
I experienced something else: when the Menu shows up (using HOTween to Tween the Menu down from above), I get for some frames a significant FPS-Drop from 60FPS to around 45FPS, then when the Tween is over (1 sec), it goes to 55FPS and stays at 55FPS
I already tried the NGUI-Tweens, same results.
This only happens on my iPhone 4. Tried same stuff (HOTween and NGUI Tweens) on my iPad mini. That thing doesn't give a damn and stays at 60 FPS.


I recreated the GUI in a whole new blank Project with only NGUI and HOTween imported. Only a blank scene, just the UI. Same results on both devices.

Here are some informations about the Atlas:

- it's a 2048x2048 Texture and holds all Sprites (Buttons, the Font, normal Sprites)
-> the smallest sprite is around 80x81 and the biggest one is 848x631
- Of course I only get two Drawcalls (Main Camera and UI Camera with the NGUI Atlas)

Here's a video in action in the Unity-Editor (don't mind the messy display of Sprites, only for testing purposes):

https://www.dropbox.com/s/xucsxffuc43m3lz/NGUI.mp4

In the Editor it works fine, of course.

Is there something I can do to optimize it on iPhone 4?


8
NGUI 3 Support / Scrollview makes FPS drop
« on: January 23, 2014, 12:54:26 PM »
Hey there.

Using the latest NGUI Version.

So I have a ScrollView (set to Alpha Clip, I read that's faster than Soft Clip, so I used this instead) with a Childobject: A UIGrid.
This UIGrid holds Labels like this:



So when I fill this grid with Labels on my mobile device (iPhone 4) at first the framerate is fine, but when I fill the ScrollView/Grid with a lot of Labels (let's say around 40++) the FPS drops to 30fps, when I get more then it drops again.
The fun thing is, as long as I don't scroll with my fingers, the FPS stays at 50~FPS, as soon as the finger touches the display and moves the View the fps drops.

Is there a way to prevent that? Did I miss something in the settings?

9
NGUI 3 Support / UISprite Offscreen - Tris Count still goes up
« on: January 22, 2014, 01:26:36 PM »
Hey there.

So, I noticed something. I don't know if I just set things up the wrong way or this is just the "NGUI way".

Have a look at these stats. As you see I have some UI-Elements. The MenuBook is enabled but offscreen.
The Triscount is 244


Now, when I TriggerEnter the left blue cube I get some Items into my Inventory:


4 new Items = 8 Tris

The TrisCount goes up to 252. Why is that? I mean the Book isn't even "displayed" by the UI-Camera. Shouldn't it only go up to 252 Tris when Camera renders the whole book, meaning when the Book is in the middle of the screen?

So if hit my BookButton which tweens the Book down, the count stays the same.

10
NGUI 3 Support / TweenAlpha doesn't tween all children / Nullreference
« on: January 13, 2014, 09:54:03 AM »
Hey there.

So do I miss something or why does TweenAlpha not tween all of my GameObjects Children?

Here's my setup.

This is my Hierarchy:



So my "01INVENTORYMENU" is an empty GameObject.
The Objects: "ITEMGRID", "Sticker", "Textbox" are simple Sprites:



The Objects "SLOT1" to "SLOT4" are empty UI-Widgets. "Itemlabel" is a simple label:



All the Sprite- and Label-Components are disabled by default.

So, what do I want to achieve:

I have an InventoryButton, when clicked this button and other buttons are disabled for a moment, an Animation is played and other stuff happens. This other stuff includes setting the Alpha-Value of the Children of "01INVENTORYMENU" to 0.0f and enabling the Sprite/Label-Components. This is how I do it:

  1.  
  2. public GameObject pageFlipper;
  3.         public tk2dSpriteAnimator flipperAnimator;
  4.  
  5.         public GameObject inventoryMenu;
  6.  
  7.         private UISprite[] spriteComp;
  8.         private UILabel[] labelComp;
  9.  
  10. // Start-Function just adds the EventDelegates...
  11.  
  12. IEnumerator ShowInventory()
  13.         {
  14.                 inventoryBtn.isEnabled = false;
  15.                 questmenuyBtn.isEnabled = false;
  16.                 diarymenuBtn.isEnabled = false;
  17.                 pageFlipper.renderer.enabled = true;
  18.  
  19.                 if(!flipperAnimator.IsPlaying("PageForward"))
  20.                 {
  21.                         flipperAnimator.Play("PageForward");
  22.                         flipperAnimator.AnimationCompleted = HitCompleteDelegate;
  23.                 }
  24.  
  25.                 foreach(UISprite s in spriteComp)
  26.                 {
  27.                         s.alpha = 0.0f;
  28.                         s.enabled = true;
  29.                 }
  30.                 foreach(UILabel l in labelComp)
  31.                 {
  32.                         l.alpha = 0.0f;
  33.                         l.enabled = true;
  34.                 }
  35.                 foreach(Transform child in inventoryMenu.transform)
  36.                 {
  37.                         TweenAlpha.Begin(child.gameObject, 1.0f, 1.0f);
  38.                 }
  39.  
  40.                 yield return new WaitForSeconds(2.0f);
  41.  
  42.                 inventoryBtn.isEnabled = true;
  43.                 questmenuyBtn.isEnabled = true;
  44.                 diarymenuBtn.isEnabled = true;
  45.  
  46.         }

I dragged and drop "01INVENTORYMENU" into the "inventoryMenu"-variable from the script.

And it works, but only the GameObject "ITEMGRID" is faded in. The UISprite/-Label-Components are enabled and the Alpha-Value is set to 0.0f, but they won't fade in. Just for testing I dragged "Sticker" in there, and only the child "Textbox" did fade in, but not the "Itemlabel".

Is there something wrong with my code?







11
NGUI 3 Support / TweenPosition and OnFinished sending same event?
« on: January 11, 2014, 01:38:58 PM »
Hey there,

so I spent the last hours trying to get to know the scripting side of NGUI (working with the latest version), especially the new way handling Events. I looked up the Upgrade-Tutorials and used the Searchfunction and got things to work.
Now I have a little problem. I don't know if it's my own stupidity or maybe a bug, so please enlighten me :D

I want to achieve this:

I have a Button at the Bottom of the Screen and a Sprite which is positioned by default offscreen at the top of the screen.
When the Button is hit the first time, the Sprite should come down (using TweenPosition) and stay at the middle of the screen.
Then, when the Button is hit again that certain sprites goes back to its initial position offscreen.

This is what I'm doing right now:

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class BookButton : MonoBehaviour
  5. {
  6.  
  7.                 public bool firstTap;
  8.                 private GameObject gameBook;
  9.                 private UIButton btn;
  10.  
  11.                 // Use this for initialization
  12.                 void Start ()
  13.                 {
  14.  
  15.                                 firstTap = false;
  16.                                 gameBook = GameObject.FindGameObjectWithTag ("GAMEBOOK");
  17.                                 btn = GetComponent<UIButton> ();
  18.        
  19.                 }
  20.  
  21.                 public void BookClick ()
  22.                 {
  23.  
  24.                                 if(firstTap)
  25.                                 {
  26.                                 TweenPosition tp = TweenPosition.Begin(gameBook, 1.0f, new Vector3(gameBook.transform.localPosition.x,
  27.                                                                                              350.0f,
  28.                                                                                              gameBook.transform.localPosition.z));
  29.                                 EventDelegate.Add(tp.onFinished, Fin1);
  30.                                 }
  31.  
  32.                         else
  33.                         {
  34.                         TweenPosition tp2 = TweenPosition.Begin(gameBook, 1.0f, new Vector3(gameBook.transform.localPosition.x,
  35.                                                                                            -350.0f,
  36.                                                                                            gameBook.transform.localPosition.z));
  37.                         EventDelegate.Add(tp2.onFinished, Fin2);
  38.                         }
  39.  
  40.  
  41.  
  42.                 }
  43.  
  44.  
  45.         void Fin1()
  46.         {
  47.                 firstTap = false;
  48.                 Debug.Log("FIN1");
  49.         }
  50.  
  51.         void Fin2()
  52.         {
  53.                 firstTap = true;
  54.                 Debug.Log("FIN2");
  55.  
  56.         }
  57. }
  58.  

When I hit PLAY in Unity and start clicking the Button the first time the Sprite comes down, when I hit it again it goes back up, hitting it again it comes back down. Hitting it again, nothing happens. It doesn't move back up.
What is interesting though is the change of my firstTap-bool:

First Time hitting the Button: sprites comes down -> true
Second Time hitting the Button: sprites comes down -> false
Third Time hitting the Button: sprites comes down -> false

Another more interesting thing is:
When I hit the Button the first time, Debug.Log prints "FIN2", which is right, but when I hit it again in order to move the sprite back Debug.Log prints "FIN1" but also "FIN2" again! That shouldn't be the case, because TweenPosition tp is played and finished, why is the EventDelegate sending both Events? Did I miss something?

12
NGUI 3 Support / Label being a Button
« on: January 11, 2014, 09:30:10 AM »
Hey there!

So this is what I want to achieve:

I have a Bookmenu for the Quests. And everytime a quest is accepted a Label (the name of the quest) will be added to a Grid. This grid has also a custom script attached and has an ArrayList which adds every new Quest/Label to this list.

So, when I open the Questmenu (clicking on a normal UIButton) ALL these ListItems (the labels) shall:

- set active to true
- play a Tween (fade in)
- stay in their state (meaning, the alpha value should stay at 1.0f)

That's not the "hard" part. So now we're in the Questmenu and see the names (the labels) of the accepted Quests. NOW when we hit ONE of these labels, ALL of them should:

- play a Tween (fade out to 0.0f)
- set active to false

and then the particular QuestPage should be shown.

In order to get this working I attached a BoxCollider to my labels. What I can't manage to find is the way to access the information that any of the label in the list has been clicked.

I already tried something like this after some research: http://www.tasharen.com/forum/index.php?topic=6987.msg32984#msg32984

Quote
void Update ()
   {

      foreach(GameObject q in questList)
      {
         UIEventListener.Get(q).onClick += Clicked;

      }
   }


   void Clicked()
   {
      Debug.Log ("Any was clicked");
   }

But it just gives me errors.

13
NGUI 3 Support / Label does not appear in Scrollview until touched
« on: January 07, 2014, 10:32:45 AM »
Hey there,

First of all: I'm using the latest NGUI Version.

The problem:

So, I'm controlling my UI via PlayMaker and HOTween which works fine. There is only one thing which doesn't work well.
I have a Booksystem with Buttons, when I hit these Buttons the Items on the displayed "Pages" fade out (I'm tweening the Alpha-Values of the Sprite-Objects, be default all the Alpha-Values are set to 0 and are faded in when the Menus are shown)
This works well, but not with my Quest-Scrollview.

Here's a video a made, so you can see what I mean:

https://www.dropbox.com/s/kspgtrymmdh0ex8/ScrollviewProb.mp4

As said, the default Alpha-Value is 0. When I hit "QUESTS" the "Overview"-Label is faded in, as intended, but the "Quest 1"-Label is not, though in the Inspector you can see how the Alpha-Value is slowly rising to 255 (from black to white). As soon as I actually TOUCH the Scrollview the Label appears. And then if I switch between the Menupages it works like it should.
I also tried to use the Reposition()-Function of the Grid but it didn't work.

Here's the Hierarchy of the UI.



Any suggestions?

14
NGUI 3 Support / [SOLVED]Error with 3.0.3g - UIInput and validator
« on: November 02, 2013, 03:52:43 AM »
So I just upgraded from 3.0.2 to 3.0.3g and got this error:

Quote
Assets/NGUI/Scripts/Interaction/UIInputValidator.cs(31,49): error CS1061: Type `UIInput' does not contain a definition for `validator' and no extension method `validator' of type `UIInput' could be found (are you missing a using directive or an assembly reference?)

15
NGUI 3 Support / How to update to the latest 3.0.3 Version?
« on: October 31, 2013, 10:17:27 AM »
Hey there. So I have this link which leads me to the latest Version of the NGUI Package. That way I was able to update to 3.X, but everytime I download it again the last couple of days I only get the 3.0.2 version and not the 3.0.3 Version.

Pages: [1] 2