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

Pages: [1] 2
1
NGUI 3 Support / Re: Does using TweenScale reset the camera size?
« on: November 14, 2014, 11:59:56 AM »
OK great, thanks - I'm currently looking into this.

The way I'm approaching it is by first calculating the correct size Rect bounding box around the colliders of a set of buttons on the background. I would then like to scale the background up so that when scaled, it fills the screen with what's in the bounding box (I think this should be the same as how pinch-zooming works?).

I have implemented the Rect and it's surrounding the buttons correctly. However, I'm having some trouble calculating the scale that I need to use on the background. I know that I need to do some conversions to different coordinate systems but not sure where. I have tried converting the bounding box from screen to World coords but this doesn't seem to be working.  My scaling function is as follows;

  1. float CalculateMapScale(Rect boundingBox)
  2. //    float CalculateMapScale()
  3.     {
  4.         // Cache the map's size.
  5.         Vector3 mapScale = Map.transform.localScale;
  6.  
  7.         // Find the Map width and height. - In World coords
  8.         float mapWidth = RightAnchor.position.x - LeftAnchor.position.x;
  9.         float mapHeight = TopAnchor.position.y - BottomAnchor.position.y;
  10.  
  11.         // Calculate the Map aspect ratio.
  12.         float mapAspect = mapWidth / mapHeight;
  13.        
  14.         // Work out the Width and Height scales relative to the bounding box.
  15.         float newMapWScale = mapWidth / Mathf.Abs(boundingBox.width);
  16.         float newMapHScale = mapHeight / Mathf.Abs(boundingBox.height);
  17.  
  18. /*
  19.        Vector3 bbBottomLeft = NGUICam.ScreenToWorldPoint(new Vector3(boundingBox.xMin, boundingBox.yMin, 1));
  20.         Debug.Log("bbBottomLeft = " + bbBottomLeft);
  21.  
  22.         Vector3 bbTopRight = NGUICam.ScreenToWorldPoint(new Vector3(boundingBox.xMax, boundingBox.yMax, 1));
  23.         Debug.Log("bbTopRight = " + bbTopRight);
  24.  
  25.         Vector3 bbWidthHeight = bbTopRight - bbBottomLeft;
  26.         Debug.Log("bbWidthHeight = " + bbWidthHeight);
  27. */
  28.  
  29.         float newMapScale = 0;
  30.  
  31.         if (newMapWScale >= newMapHScale)
  32.             newMapScale = newMapWScale;
  33.         else
  34.             newMapScale = newMapHScale;
  35.  
  36.         return newMapScale;
  37.     }

2
NGUI 3 Support / Re: Does using TweenScale reset the camera size?
« on: November 08, 2014, 10:29:07 AM »
Oh I see, OK thanks for letting me know.
Well what I need to be able to is zoom in and out of a background (a map). How would you recommend I approach this?

Thanks

3
NGUI 3 Support / Does using TweenScale reset the camera size?
« on: November 07, 2014, 11:14:08 AM »
Hi

I have a zoomed cam and would like to scale up a sprite at this zoom. However, as soon as the scaling begins, the cam seems to reset back to size 1.

Any Ideas?

4
NGUI 3 Support / Re: Changing size of all buttons
« on: November 07, 2014, 10:25:37 AM »
You'll want to look into Prefabs in order to have any changes to a 'master' object also change its copies: http://docs.unity3d.com/Manual/Prefabs.html

Off the top of my head, if you set the pivot of the UISprite widget of the line prefab to the side you want them to meet at (left, or right, etc., rather than the centre), then when resized they should extend from the pivot. Then you'll need to store all lines in a list and work out where to place them  (now from their new pivot position, not centre) based on the width/height of their previous one.

Not tested this, so let me now how it goes :)

5
I have a camera which zooms into a set of buttons, which when clicked, cause a window to open in the foreground. I would like to know how to make sure that the size of the window on the screen is the same (regardless of the camera's orthographic size). So, for example, if I choose not to zoom into the buttons (so cam size = 1), then the window that opens is the same size on the screen.

Any guidance/tutorials would be great - Thanks.

6
Yes, only called from the OnClick method of the button, nowhere else.

I don't think I've used the Stacktrace before, would this be the overview box in Profiler showing functions?

7
There is no custom code for the UIButton OnClick method, I just dragged in the object (the window with the Enable script on it), into the UIButton delegates area, to be opened when the button is clicked.

Btw, Did you see my edit in previous post about this now being solved?

8
Thanks for the reply.

D'oh! OK have removed the 'gameObject' after thisCalledMe. Now getting a 'NullReferenceException: Object reference not set to an instance of an object' for the line above it:

  1. thisCalledMe = UIButton.current.gameObject;

Edit: This is working now, was an issue with the way the objects were structured.

9
Any ideas?

10
Hi,

I'm trying to set up a type of menu system where an 'Open' button in each window (Panel) will open another window, etc. Each of the windows has an 'Open' and  'Close' button. The Close closes that window and also opens (enables), the previous one again (i.e. the one that called it). I was wondering how I might go about detecting (and getting a handle on) which of the windows (so the GameObject ?) was responsible for opening its 'next' window via its 'Open' button. I have tried something like the following but am getting an error (NullReferenceException). The script containing the  EnableNextWindow() function is called via an Event Delegate on the UIButton's OnClick.

Any help would be great - Thanks!

  1. public GameObject thisCalledMe;
  2.  
  3. public void EnableNextWindow()
  4. {
  5.     thisCalledMe = UIButton.current.gameObject;
  6.  
  7.     Debug.Log(thisCalledMe.gameObject.name); // Gives Error
  8.  
  9.     thisCalledMe.SetActive(true); // etc...
  10. }
  11.  
  12.  
  13.  

11
Hi,

I have a problem that occurs about half the time when I switch platform (from 'PC, Mac & Linux' to iOS). What seems to happen is that the atlas entries in the Inspector disappear (which means that very few of the textures are displayed). I was wondering if there is a workaround to fix this (modifying/swapping the files associated with these connections, etc.) as having to manually re-enter these is becoming a pain.

Thanks

12
NGUI 3 Support / How to find the Root GameObject a clicked UIButton is on
« on: October 16, 2014, 09:14:36 AM »
Hi,

I'm trying to find the root GameObject if a child object that has a UIButton component. When the child object is clicked, I would like to record the root GameObject. I am using the following which brings up an error;

  1. public GameObject RootGameObject;
  2.  
  3.     void OnClick()
  4.     {
  5.         UIButton btn = UIButton.current;
  6.  
  7.         RootGameObject = btn.transform.root.gameObject;
  8.  
  9.       //  Debug.Log(UIButton.current.name);
  10.     }
  11.  

The error is:
  1. NullReferenceException: Object reference not set to an instance of an object
  2. KeepTrackOfOpenWindow.OnClick () (at Assets/Khoda/Scripts/Q&A/KeepTrackOfOpenWindow.cs:12)
  3. UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
  4. UICamera:Notify(GameObject, String, Object) (at Assets/NGUI/Scripts/UI/UICamera.cs:1065)
  5. UICamera:ProcessTouch(Boolean, Boolean) (at Assets/NGUI/Scripts/UI/UICamera.cs:1808)
  6. UICamera:ProcessMouse() (at Assets/NGUI/Scripts/UI/UICamera.cs:1402)
  7. UICamera:ProcessTouches() (at Assets/NGUI/Scripts/UI/UICamera.cs:1474)
  8. UICamera:Update() (at Assets/NGUI/Scripts/UI/UICamera.cs:1221)
  9.  
  10.  

Any help wuld be great - Thanks

13
Oh I see, OK.
Would there then be a way to splice the sprites from a sprite sheet using third party software instead of Unity's editor in that case, or a tool inside NGUI, in order to get them into a workable atlas?

Thanks


14
Hi,

I have sliced up a sprite sheet in Unity's Sprite Editor into individual sprites but they kept as children of the main object once this is applied and cannot be dragged out separately. I was wondering how I can add the individual sprites to an NGUI atlas.

Thanks

15
NGUI 3 Support / Re: UIPanel error
« on: September 04, 2014, 09:32:30 PM »
That works great - Thanks

Would this be the best practice then for creating menus and separate areas in NGUI (apart from having a separate scene)?
I'm pretty new to NGUI and want to make sure I get into the habit of structuring things the way they were designed :)

Cheers

Pages: [1] 2