PDA

View Full Version : no duplicates in the scene


loran
09-07-2009, 04:55 PM
Hey,
I want to create a SphereGizmo by script,but if SphereGizmo already exist, I want to cancel the new creation... got it? only one SphereGizmo in the scene.
on btn_gizmo pressed do

SphereGizmo radius:20 name: "BombGizmo"

any help?
thank you

MatanH
09-07-2009, 05:06 PM
you can try something like that: (didn't test it)

if (getClassInstances SphereGizmo).count == 0 then
SphereGizmo radius:20 name:"BombGizmo"

loran
09-07-2009, 05:26 PM
thank you! that works fine.
By the way, I want to test if there is a SphereGizmo with a specific name in the scene...

MatanH
09-07-2009, 08:39 PM
you could use this test instead then:

if not isValidNode $'gizmo_name_here' then
...


or use the getNodeByName method and compare it to undefined

CGTalk Moderation
09-07-2009, 08:39 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.