Welcome,
Guest
. Please
login
or
register
.
May 01, 2026, 07:50:47 AM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
[Problem] Cloning object takes units instead in pixels. Greater Object.
« previous
next »
Print
Pages: [
1
]
Author
Topic: [Problem] Cloning object takes units instead in pixels. Greater Object. (Read 1895 times)
godik
Guest
[Problem] Cloning object takes units instead in pixels. Greater Object.
«
on:
July 26, 2013, 12:32:46 PM »
I have done 2 UIgrids, one with the items and another one empty. When i doubleclick on one item of the source grid i want it to clone in the destination grid.
The problem i found is that the transform of the clone object is in units and not in pixels. The effect is that the object is a lot greater than the original.
I clone with:
GameObject clone
=
(
GameObject
)
Instantiate
(
collider
.
gameObject
)
;
destino
.
addElement
(
clone
)
;
The method addElement from destination UIgrid:
public
void
addElement
(
GameObject element
)
{
element
.
transform
.
parent
=
transform
;
Reposition
(
)
;
}
«
Last Edit: July 26, 2013, 05:02:07 PM by godik
»
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: [Problem] Cloning object takes units instead in pixels. Greater Object.
«
Reply #1 on:
July 27, 2013, 01:23:15 PM »
1. Never use Instantiate. NGUITools.AddChild should be used instead. Instantiate doesn't set the parent, object layer, and doesn't clear the transform correctly.
2. Don't set the parent. NGUITools.AddChild does it for you.
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
[Problem] Cloning object takes units instead in pixels. Greater Object.