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 - gaurav.maniar

Pages: [1]
1
NGUI 3 Support / Xray effect with shader
« on: August 27, 2014, 05:09:24 AM »
i want X-ray effect on sprite,

sprite1(background image)
sprite2(foreground image)
(both are with same size)

sprite3(another foreground image, size smaller than sprite2)

so when sprite3 is hovered on sprite2, i want to make that much part of sprite3 visible.

i tried to do it with following shader, but it didn't work,

http://unitycoder.com/blog/2012/02/22/x-ray-cutout-shader-with-mouse/

any idea, how to do this??

-Thanks

2
NGUI 3 Support / Re: Raycast hit and Camera debug last hit
« on: August 21, 2014, 12:37:46 AM »
my vertical scroll view structure,

added the invisible widget to scroll it outside from the objects added to scroll view (according to your video tutorial)

Panel (depth 1)
|>Container (invisible widget) (with box collider and UIDrag scroll view)

UIScroll View (depth 2)
|>Grid
    |>2d sprite (box collider and UIDrag scroll view)
        |>2d sprite
    |>2d sprite (box collider and UIDrag scroll view)
        |>2d sprite

and more 10 sprite elements in same way.

  1. if (Input.GetMouseButtonDown (0))
  2. {
  3.     RaycastHit hit;
  4.     Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
  5.     if (Physics.Raycast (ray, out hit))
  6.     {
  7.         if (hit.collider != null)
  8.         {
  9.             Debug.Log (hit.collider.name);
  10.         }
  11.     }
  12. }

i have enabled Debug option in Camera.

Last Hit showing every component properly if it is sprite or container,
but the problem is, in code by raycast hit, for some sprite objects i'm getting hit but for some sprite objects i'm getting hit on container.

3-4 times created new scroll view, but problem remains as it is, only objects on which i was getting hit are changing.

3
NGUI 3 Support / Raycast hit and Camera debug last hit
« on: August 19, 2014, 08:54:41 AM »
after enabling the "Debug" in camera, we are getting Last Hit object name.

on Mouse Click event object_name we get by Raycast hit, will be same as the object by Last Hit of Camera????

  1. if (Input.GetMouseButtonDown (0))
  2. {
  3.         RaycastHit hit;
  4.         Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
  5.         if (Physics.Raycast (ray, out hit))
  6.         {
  7.                 if (hit.collider != null)
  8.                 {
  9.                         string object_name = hit.collider.name;
  10.                 }
  11.         }
  12. }
  13.  

I think that, it should be same, but i'm not getting same object.

-Thank you.

4
NGUI 3 Support / Best way to optimize
« on: August 19, 2014, 04:20:02 AM »
I'm making an iOS game, it has 5 character and 60 small dress up images for each character, at a time only one character is displayed

how should i optimize image loading??
->load all images in UI2dSprite and put them outside the screen area and bring them to screen as required
->put all images in Resource folder and load the image when required (i have heard that, one should kept nothing inside Resource folder if possible)

5
NGUI 3 Support / Re: UIScrollView offset changing when applied scaling
« on: August 19, 2014, 12:36:34 AM »
wiil u pls elaborate.....!

my scrollview is with vertical movement, and now no problem with changing in offset values.

as u said "scale must be uniform", i have checked with all devices and x, y and z scale values are same according to screen resolution.

the actual problem is with y position of scrollview, its getting changed when scrolled up/down in devices other than screen ration 3:4.

6
NGUI 3 Support / UIScrollView offset changing when applied scaling
« on: August 18, 2014, 09:06:05 AM »
my scroll view is working fine on iPad, but when run my application in iPhone 5/4, i'm applying scaling to the scroll view by following code,

  1. float Scale_Ratio_X = Screen.width / 768.0f;
  2. float Scale_Ratio_Y = Screen.height / 1024.0f;
  3. float Scale_Ratio_XY = Scale_Ratio_X / Scale_Ratio_Y;
  4.  
  5. cap_scroll.transform.localScale = new Vector3(Scale_Ratio_XY, Scale_Ratio_XY, Scale_Ratio_XY);
  6. cap_scroll.transform.localPosition = new Vector3(cap_scroll.transform.localPosition.x*Scale_Ratio_XY,
  7.                                                                        cap_scroll.transform.localPosition.y*Scale_Ratio_XY, 0f);


so when i scrolling it up or down y position or offset of scroll view is getting changed, but it remains constant when testing on iPad.

7
NGUI 3 Support / changing sprite2D image at run time
« on: August 06, 2014, 02:14:35 AM »
i want to change image of button when clicked, so doing it with following code.

it works fine with unity simulator, but when loaded it on iPhone, iPad, image is not getting changed.

1st click image disappear, 2nd click default image gets visible ... and goes on, but it is not changing the image.

  1. public void sound_toggle()
  2.         {
  3.                 Debug.Log ("Sound");
  4.  
  5.                 if (sound_status)
  6.                 {
  7.                         gameObject.GetComponent<UI2DSprite> ().sprite2D = Resources.LoadAssetAtPath<Sprite> ("Assets/Mainscreen/Images/sound_off.png");
  8.                         sound_status = false;
  9.                 }
  10.                 else
  11.                 {
  12.                         gameObject.GetComponent<UI2DSprite> ().sprite2D = Resources.LoadAssetAtPath<Sprite> ("Assets/Mainscreen/Images/sound_on.png");
  13.                         sound_status = true;
  14.                 }
  15.         }

8
Thanks ...

9
can you tell me how to change sprite or image in UI2DSprite???

thanks

Pages: [1]