Welcome,
Guest
. Please
login
or
register
.
December 11, 2024, 11:47:52 PM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Change UISprite size base on two gameObjects distance
« previous
next »
Print
Pages: [
1
]
Author
Topic: Change UISprite size base on two gameObjects distance (Read 2710 times)
0771
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 3
Change UISprite size base on two gameObjects distance
«
on:
February 08, 2016, 06:06:19 AM »
I have two gameObject in front of the orthographic camera.
And the distance from gameObject1 and gameObject2 for instance
var distance = Vector2.Distance(gameObject1.transform.position, gameObject2.transform.position)
How do i make the sprite width equal to this distance ?
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: Change UISprite size base on two gameObjects distance
«
Reply #1 on:
February 09, 2016, 02:44:06 AM »
Easiest way? Create a widget. Anchoring set to advanced. Left side anchored to one object, right side anchored to another.
Logged
0771
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 3
Re: Change UISprite size base on two gameObjects distance
«
Reply #2 on:
February 15, 2016, 09:57:19 PM »
Thank you for the answer,
But my sprite size is created randomly and i don't know how to get left and right position.
How to get the left position and right position of the sprite, so i can attach anchor base on
that positions.
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: Change UISprite size base on two gameObjects distance
«
Reply #3 on:
February 18, 2016, 06:46:46 PM »
I don't understand the question. Created randomly? Get position to attach anchor base? What?
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
Change UISprite size base on two gameObjects distance