Author Topic: how attach script to UITexture by script  (Read 3368 times)

VamppiV

  • Newbie
  • *
  • Thank You
  • -Given: 5
  • -Receive: 1
  • Posts: 15
    • View Profile
how attach script to UITexture by script
« on: October 07, 2014, 06:42:24 AM »
How can I attach script to UITexture I've made by script?

I have something like this:

UITexture newTexture;
newTexture = NGUITools.AddWidget<UITexture>(scrollViewObject);
newTexture.SetRect(x,y,texWidth,texHeight);

newTexture.mainTexture=texTmp;

It makes me newTexture in ScrollViewGrid. Now I want to do something like this:
newTexture.AddComponent<UIDragScrollView>();
Of course it doesn't work. So how can I do it better?

VamppiV

  • Newbie
  • *
  • Thank You
  • -Given: 5
  • -Receive: 1
  • Posts: 15
    • View Profile
Re: how attach script to UITexture by script
« Reply #1 on: October 07, 2014, 06:46:36 AM »
Okey, I'm idiot. newTexture.gameObject.AddComponent<UIDragScrollView>(); works