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

Pages: [1]
1
NGUI 3 Support / Re: How to set NGUI delay property via code
« on: January 01, 2017, 07:59:06 PM »
thank you

2
NGUI 3 Support / How to set NGUI delay property via code
« on: January 01, 2017, 03:45:33 PM »
I'm trying to set the delay property of the TweenScale component in my code.
Just wondering how I can accomplish this?

Here's what I have tried so far:

   float myDelay = 1.0f;

   public void setDelay () {
      gameObject.GetComponent<TweenScale>.delay() = myDelay;
   }

I found this thread where it is mentioned that delay is a property:
http://www.tasharen.com/forum/index.php?topic=2231.0

note: I'm new so exact syntax is always a big help to me :)

3
Hmm.... still trying to figure out how to color sprite randomly from an array of colors

using UnityEngine;
using System.Collections;

public class BtnActionColor : MonoBehaviour {

   public Color[] myRandomSpriteColor;

   public void OnBtnClick () {
      transform.FindChild ("WhiteSquare").GetComponent<UISprite> ().color = myRandomSpriteColor [Random.Range (0, myRandomSpriteColor.Length)];
   }
}

In the Inspector I must create an array of colors

but when I test the project and click the button
the white square sprite which I have placed on top of my button just disappears
Instead I want the white square to change to a random color from the array of colors I have created...

Any other helpful ideas on how to change a white sprite to a random color from array?

4
Thanks, this worked for me.

Here's how I used your code in an on click function to change the color of a sprite

I put the sprite at the same position as my button
and changed sprite depth to 1 (above the button, which has depth 0)

since adding the button script to an object seems to disable ability to change color

   public void OnBlueBtnClicked () {
      print ("blue was clicked");
      transform.FindChild("WhiteSquare").GetComponent<UISprite>().color = Color.green; // change sprite to color red
   }

5
hmm... if I could figure out how to change the title of my original post
I would change it to something like:

How to properly change color of a Sprite with NGUI

6
Hi,

I want to change the color of a sprite on click -- to a random color from array.
When I click the sprite, the console message shows I'm getting a color from the array.
But I can't get the sprite to actually change color on-screen.
Does anyone know how to make this work properly?

Also I'm new to NGUI / coding in general so if there is an elegant solution to this problem please let me know.

Here is my code:

using UnityEngine;
using System.Collections;

public class btnUpdate2 : MonoBehaviour {

   public Color[] squareColor;

   public void onClickTweenColor () {
      
      print ("example color from array: " + squareColor [Random.Range (0, squareColor.Length)]);

      GameObject.Find ("WhiteSquare").GetComponent<UIWidget> ().color = squareColor [Random.Range (0, squareColor.Length)];
   }
}



7
Hello,

Basically I want to be able to code player object animation like Geometry dash:
https://www.youtube.com/watch?v=hI8AoSVkScA

I'm looking for a tutor who can work on Skype / Teamviewer for 1-2 hours per session

Tutor session 1:
please prepare simple Unity/ NGUI project using code for tween position / tween rotation

square player object appears in center screen position.
Note: Object is at rest until user taps / clicks the object.

when user taps square object:
(a) object will tween position (y position up 250 pixels, then return to origin y position)
(b) object will tween rotation (z rotation 90 degrees clockwise)

I will pay $ / hour --
please reply to thread and/or pm me

I have prepared a series of 6 lessons similar to this
to help me learn to code NGUI tween position, tween rotation, tween scale, etc.
thank you

8
NGUI 3 Support / Re: ScrollView increase scale of object in center
« on: October 28, 2016, 09:58:43 AM »
Hi,

I tried implementing this code in my project and I'm getting this error:
"The type or namespace name "UIDraggable Panel" could not be found. Are you missing an assembly reference?"

I've searched for this error online and other projects with this error are nothing to do with Unity / NGUI.

Any tips for how to make this code work?

It would be great if NGUI would include a code example with scroll view that scales center object.

Thanks!

Pages: [1]