Singleton Problem (18811)

Can anybody tell me where can i get a singleton class for an array or any other datatypes or maybe any gameobject or component???If there is any link that would be appreciated...Regarding Unity. Where to write the code and how to implement it?? Thanks in advance

1 Answer

1

Hi,

your best starting point here

Hope that helps,

Jean

Sorry am a newbie here so pardon my stupid questions but still can you tell me where to write the code for singleton class ,i mean is it script specific?

Yes, it's a script like any other script. There is a score tracking example in the link I sent you. Else I am not sure what you actually don't understand by "where to write the code". If you are already thinking about singleton, that means you are pretty advanced and knowledgeable about scripting at least and unity most likely. Else you should already try with normal scripting as a start, and then move into more advance topics

@Jean:I am using the it in javascript where i am a newbie but i have singleton class for cocos-2d without a problem.And i am getting error with the Score Singleton like Assets/Test/MySingleton.js(5,12): BCE0043: Unexpected token: MySingleton. Assets/Test/MySingleton.js(5,24): BCE0044: expecting EOF, found '('. And i am defining this class in a script where i am using singleton's instance to update score..so help me if you can..:(

Hi, can you post your problem as a forum question or a new unity answer question, and contact me straightaway, I'll happily look at it. We can't really keep commenting in this question that would pollute UA. Thanks:)

http://answers.unity3d.com/questions/52243/singleton-error-with-code check out here,i have asked the same question.... Thanks for replying..:)