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

Pages: [1]
1
NGUI 3 Support / Re: Reference Font Switching Btw Dynamic and BitMap Font
« on: January 21, 2015, 01:49:38 AM »
Oh my my ..i was doing it right from the start just needed to change the resources.Load parameter.

  1. font.replacement = Resources.Load("Fonts/English Font", typeof(UIFont)) as UIFont;
  2. or Resources.Load<T>(path);


its Done .. Thanks anyways :)
Working fine still if you think there can be anyimprovements do let me know

2
NGUI 3 Support / Re: Reference Font Switching Btw Dynamic and BitMap Font
« on: January 21, 2015, 01:21:12 AM »
Aren yeah i know all the labels have it ..
  1. if (font == null)
  2.                 {
  3.                         UILabel label = FindObjectOfType<UILabel>();
  4.                         if(label)
  5.                                 font = label.bitmapFont;
  6.                 }
I got the font from a lable using this  code and it says RefFont wihch is pointing to EnglishFont.
Now how to change the font inside RefFont. if i use
  1. font.replacement = Resources.Load("Fonts/English Font") as UIFont;
The replacement propperty which was previously pinting to EnglishFont becomes NULL and the lables starting Showing Blank.

Im using Reference Atlas at its working fine using the same code
  1. referenceAtlas[0].replacement = Resources.Load("Atlases/" + DAY_ATLAS_NAME, typeof(UIAtlas)) as UIAtlas;

3
NGUI 3 Support / Re: Reference Font Switching Btw Dynamic and BitMap Font
« on: January 20, 2015, 03:55:55 AM »
One more thing I cant Keep RefFont In the Scene . Beacause I have many Prefabs That I load. And their link to  Reference font is broken.  The link to  Ref Font is stable for those gameobjts which are already present in the scene.

Scenarios
Ref Font is placed in Scene which is a Reference Font
Objects alreayd in scene are working fine.
Objects which i load at runtime have to connection to the Reference Font.

4
NGUI 3 Support / Re: Reference Font Switching Btw Dynamic and BitMap Font
« on: January 20, 2015, 12:25:12 AM »
Yeah im exactly doing the same thing. I wrote im doing it two ways .
int he second approach i treid the same thing .

  1. void SwitchFont(int lang)
  2.     {
  3.         if(!font)
  4. //                      font = (Resources.Load("Fonts/RefFont") as GameObject).GetComponent<UIFont>();
  5.             font = GameObject.FindGameObjectWithTag ("RefFont").GetComponent<UIFont> ();
  6.         switch (lang)
  7.         {
  8.         case gLocale.LANG_ENGLISH:
  9.             font.replacement = Resources.Load("Fonts/English Font") as UIFont;
  10.             break;
  11.         case gLocale.LANG_CHINESE:
  12.             font.replacement = Resources.Load("Fonts/Chinese Font") as UIFont;
  13.             break;
  14.         case gLocale.LANG_FRENCH:
  15.             break;
  16.         }
  17.     }

Heres the code you can clearly see. Ref font is already in the scene and IM trying to Load other Fonts from Resources and assigning it . using the replacement property.
How to change the prefab value that you are saying ?



P.S. All my labels are pinting to Reference Font. So it should work.

Here are the two screen shots in first you can see what is REF Font.
and in the second you can see the REf Font totaly changes. And all the lables go blank. I just run the above code on clicking the chiense/english button .

5
NGUI 3 Support / Reference Font Switching Btw Dynamic and BitMap Font
« on: January 19, 2015, 09:25:16 AM »
HI,
Im facing a problem in doing Localicazion. I have different fonts.
1) English
2) Chiense
3) etc
For the time beign they are two but can increase.
Im using English Bitmap Font for English and other languages and dynamic font for Chinese.
I want to switch between these two fonts. I have done this many times with atlas but With fonts it creating a problem.

I have tried two methods
1) Load RefFont From resources and change it
2) Place RefFont In scene Get it and do action.

Problem with 1 is All the Lables pointing to the RefFont (placed in resources folder)dont get affected. What i mean is what ever i do from code nothing happens. but when in change the font in RefFont i.e drag drop chiense or english font they change in the game.
2) Now All the lables are pointing to the refFont Placed in the scene. Reffont(Embedded) WHen i switch the font all my lables show blank.

What actually Happens is When ever i execute my following code. The Font(GameObject) type is changed from Reference to Bitmap dont know why this happens. And i couldnt find any way to change font type.
IF i manually Change the fonts type to reference (in the hiererchy while game is running) and Assign it chinese or english it works not through code.
Heres the code

  1. void SwitchFont(int lang)
  2.         {
  3.                 if(!font)
  4. //                      font = (Resources.Load("Fonts/RefFont") as GameObject).GetComponent<UIFont>();
  5.                         font = GameObject.FindGameObjectWithTag ("RefFont").GetComponent<UIFont> ();
  6.                 switch (lang)
  7.                 {
  8.                 case gLocale.LANG_ENGLISH:
  9.                         font.replacement = Resources.Load("Fonts/English Font") as UIFont;
  10.                         break;
  11.                 case gLocale.LANG_CHINESE:
  12.                         font.replacement = Resources.Load("Fonts/Chinese Font") as UIFont;
  13.                         break;
  14.                 case gLocale.LANG_FRENCH:
  15.                         break;
  16.                 }
  17.         }

Any Idea where im going wrong ? and how to tackle this problem ?

6
NGUI 3 Support / Re: How to detect if mouse is clicking on NGUI area?
« on: December 09, 2014, 05:41:27 AM »
Ok i did this. moved the UI towrds the screen -z
  1. if (Physics.Raycast(ray, out hit, Mathf.Infinity,1<<LayerMask.NameToLayer( "UI" )))
  2. MyFunction();
  3.  

I already tried this but The UI was behind other objects thats why it didnt worked earlier.
Too damn basic  :P

7
NGUI 3 Support / Re: How to detect if mouse is clicking on NGUI area?
« on: December 09, 2014, 12:58:18 AM »
OK will try this .. Is this isOverUI property in the latest version im on 3.68 but  cant find it. I can update to the newer version though.
Hope this works. and if isOverUI is triggered when the the cursor is overUI it think it can work for the editor but how would it work on touch devices ? 

8
NGUI 3 Support / Re: How to detect if mouse is clicking on NGUI area?
« on: December 05, 2014, 05:55:56 AM »
Hey aren,
Problem Click/Touch going through.  My game is a touch device game. But obviously i want to make it work on editor too.
WHat i want is when i click any UI the other code should run.
PS. all UI is in UI layer.

UICamera.touch count isnt working.  Well partially
I have the same code.
  1. if(Input.touchCount==1)
  2.         {
  3.             Debug.Log("SingleTouchAction");
  4.             SingleTouchAction();
  5.         }
UICamera.touchCount gives 1 when a ui is pressed but the above code runs (OnClick fucntionality) means when we relese the mouse button or lift the finger.
HOw can i detect any UI is clicked. so I would be able to stop the above code from executing.

9
NGUI 3 Support / Re: How to detect if mouse is clicking on NGUI area?
« on: November 12, 2014, 02:09:29 AM »
I achieved what i wanted to do .. no need of anything. Didnt acutally replace the Input with NGUI touch.. I added Ngui touch.
like i was doing before .
  1. if(Input.touchCount==1)
  2.         {
  3.             Debug.Log("SingleTouchAction");
  4.             SingleTouchAction();
  5.         }
  6. Now i did
  7. if(UICamera.touchCount==0 &&  Input.touchCount==1)
  8.         {
  9.             Debug.Log("SingleTouchAction");
  10.             SingleTouchAction();
  11.         }
  12.  

I tried the fall through method .. I tells other objets when UI objects are hit or some event is triggered.
My problem was. When i touched any button the touch went through the button and other ISO world functionalities started performing which it shouldnt in the fisrt place. So  I added this ..
Is this the corrent way ??

10
NGUI 3 Support / Re: about mouse(touch) events
« on: November 12, 2014, 12:56:14 AM »
Isnt there any NGUI listener or bool member.  That way we can just check that if any action on any NGUI UI item is performed.

Im facing the same problem. Im making an isometric game. When i press a button on HUD and drag(even within the bounds of that button) or any BG/button on a UI and drag the ray goes through and ISO functionalites are performed like drag or click.

Isnt there any Trigger/listener/dataMember liken when i press a button and drag the mouse/finger out the state remains pressed.
and Dragging is another case but simple click also goes through.

here is a code snippet of what im doing. If goes into this first code block but it also goes forward meaning skips this.

  1. if(iPhoneInput.touchCount > 0)
  2.         {
  3.             iPhoneTouch touch = iPhoneInput.touches[0];
  4.             ray = gState.world.nGUICamera.ScreenPointToRay(touch.position);                
  5.             if (Physics.Raycast(ray, out hit, Mathf.Infinity, LayerMask.NameToLayer("UI")) && (
  6.                 touch.phase == iPhoneTouchPhase.Ended || touch.phase == iPhoneTouchPhase.Canceled
  7.                 || touch.phase == iPhoneTouchPhase.Began))
  8.             {
  9.                 Debug.Log("IN CANCLE MODE");
  10.                 CancelTouchMode();
  11.                 return;
  12.             }
  13.         }
  14.  
  15.  
  16. and down some where in update i  do
  17. if(iPhoneInput.touchCount==1 )
  18.       {        
  19.          SingleTouchAction();
  20.       }


HOw to block this touch.

11
NGUI 3 Support / Re: How to detect if mouse is clicking on NGUI area?
« on: November 12, 2014, 12:42:27 AM »
Im facing the same problem. Im making an isometric game. When i press a button on HUD and drag or any BG/button on a UI and drag the ray goes through and ISO functionalites are performed like drag or click.

Isnt there any Trigger/listener/dataMember liken when i press a button and drag the mouse/finger out the state remains pressed.
and Dragging is another case but simple click also goes through.

here is a code snippet of what im doing. If goes into this first code block but it also goes forward meaning skips this.

  1. if(iPhoneInput.touchCount > 0)
  2.         {
  3.             iPhoneTouch touch = iPhoneInput.touches[0];
  4.             ray = gState.world.nGUICamera.ScreenPointToRay(touch.position);                
  5.             if (Physics.Raycast(ray, out hit, Mathf.Infinity, LayerMask.NameToLayer("UI")) && (
  6.                 touch.phase == iPhoneTouchPhase.Ended || touch.phase == iPhoneTouchPhase.Canceled
  7.                 || touch.phase == iPhoneTouchPhase.Began))
  8.             {
  9.                 Debug.Log("IN CANCLE MODE");
  10.                 CancelTouchMode(); // MyFUcntion
  11.                 return;
  12.             }
  13.         }
  14.  
  15.  
  16. and down some where in update i  do
  17. if(iPhoneInput.touchCount==1 )
  18.                 {        
  19.                         SingleTouchAction();
  20.                 }


HOw to block this touch.

12
NGUI 3 Support / Re: Noob Question Problem with anchors.
« on: June 04, 2014, 07:37:16 AM »
Yes making them sliced sprite worked. I have also made other spirites to sliced as well now.
The anchoring issue is there. Now i have set all the achors to advanced
In frist Screen as you can see (opponents right is laps left) and (opponents left is Roots Center)
In Second Screen as you can see (opponents right is laps left) and (opponents left is Roots Left)
In third Screen as you can see (opponents right is laps left) and (opponents left is Roots Left) and now (laps left is set to Roots Left which was previously Roots Center or opponents Right same effect)
I dont want anyone to stretch I want all of them to strech equally.
Sound Opponents and Laps.

13
NGUI 3 Support / Noob Question Problem with anchors.
« on: June 03, 2014, 02:47:52 PM »
HI everybody,
I have this UI.
I want to make it modular. I have set the anchors to unified. and set the Aspect Ratio to free.
In UI root i have set the scaling to fixedsizeonmobile and set the manual hieght to 768 The screen which I designed the UI for and made slices . but i want i to work on multiple screens like i have a device Xperia U its res is 854 * 480. the UI is totally scattered.
The ref screens are attached.
As you can see the opponent button is out of shape. I want it to be like the first attachment all the time no matter which screen.
I have tried advanced anchoring and set the achors left right to each other still didnt worked   :(.
Any idea where im going wrong or whats the solution. would be very thankfull if you reply quickly. Need to fix this asap. I know it can be fixed im doing something wrong maybe.

BTW im using
UNity 4.3 and NGUI 3.5.7

Thanks
Sam

14
NGUI 3 Documentation / Re: UIButton
« on: April 04, 2014, 12:50:46 AM »
Hi ,
I can't find the UIEventTrigger script anywhere in the project. Neither in the interaction folder nor anywhere else.
I have NGUI 3.07 f3.
I need to perform some action on button press. OnPress
can you help in this regard ?

15
NGUI 3 Documentation / Re: UIStretch
« on: April 01, 2014, 07:30:14 AM »
Hi Aren,
Whats the alternative of doing the same functionality in NGUI 3.0.7. ??
Although UIStretch is still searchable in the project window I haven't tried it after reading this.
I want to scale up/down a BG.
if i'm not wrong i think the type drop down in the anchor part has something to do with it. "unified and advanced"

Thanks


Pages: [1]