Hello! Please tell me how you can do the following ...
It is necessary that when you press "1" and then click on the character's were replaced by the "1" character?
While there is a suggestion to add the script UIButtonMessage to each of the four buttons. And when you remember the position, then click on a character and is already replacing a button. But I think the code will gramozdkim. Please help, thank you!
#region выбранный слот для замены
void one(){
}
void two(){
}
void three(){
}
void four(){
}
#endregion
#region кнопки в бараках (ТАБЫ)
void BuildsClick()
{
SelectBarrack(selectedTab=1);
}
void UnitsClick()
{
SelectBarrack(selectedTab=0);
}
void SpecClick()
{
SelectBarrack(selectedTab=2);
}
void SelectBarrack(int tab)
{
ClearPanel();
int depth = NGUITools.CalculateNextDepth(_parent);
int x = 0;
foreach(var i in allSkills.getListSlots(tab))
{
var go = NGUITools.AddChild(original);
go.name=i+"_"+tab;
var UIbut = go.AddComponent<UIButton>();
UIbut.enabled=true;
var g = go.AddComponent<UIButtonMessage>();
g.target=gameObject;
//g.functionName="Builds";
UISlicedSprite unit = NGUITools.AddWidget<UISlicedSprite>(go);
unit.name = "Icon";
unit.depth = depth;
unit.pivot = UIWidget.Pivot.Right;
unit.atlas = _atlasIcons;
unit.spriteName = i;
// меняем позицию кнопки
unit.transform.localScale = localsca;
unit.MakePixelPerfect();
//выводим ценник
UILabel prc = NGUITools.AddWidget<UILabel>(go);
prc.text = allSkills.getSlotWithPrice(i,tab).ToString();
prc.font=_font;
prc.MakePixelPerfect();
prc
.transform.localPosition = new Vector3
(-45f
+ 3f
*x,
-50,
0);
go
.transform.localPosition=new Vector3
(-77f
+ (80f
+3f
)*x,
0,
-1f
);
//назначаем таг для удаления дальнейшего
go.tag=tag;
NGUITools.AddWidgetCollider(go);
go.AddComponent<UIDragPanelContents>();// добавляем возможность передвигать
x++;
}
}
#endregion