View Full Version : no duplicates in the scene

09 September 2009, 03:55 PM
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

09 September 2009, 04:06 PM
you can try something like that: (didn't test it)

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

09 September 2009, 04: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...

09 September 2009, 07: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 September 2009, 07: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.