Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by GAMEGEEK99 · Jan 26, 2013 at 10:51 PM · error

Need help on a semicolon error

Need to put a semicolon at the end of line 91 but it won't work. How do i do it?

pragma strict

static var spawner : Spawner;

var caches : ObjectCache[];

var activeCachedObjects : Hashtable;

class ObjectCache { var prefab : GameObject; var cacheSize : int = 10;

 private var objects : GameObject[];
 private var cacheIndex : int = 0;
 
 function Initialize () {
     objects = new GameObject[cacheSize];
     
     // Instantiate the objects in the array and set them to be inactive
     for (var i = 0; i < cacheSize; i++) {
         objects[i] = MonoBehaviour.Instantiate (prefab) as GameObject;
         objects[i].SetActiveRecursively (false);
         objects[i].name = objects[i].name + i;
     }
 }
 
 function GetNextObjectInCache () : GameObject {
     var obj : GameObject = null;
     
     // The cacheIndex starts out at the position of the object created
     // the longest time ago, so that one is usually free,
     // but in case not, loop through the cache until we find a free one.
     for (var i : int = 0; i < cacheSize; i++) {
         obj = objects[cacheIndex];
         
         // If we found an inactive object in the cache, use that.
         if (!obj.active)
             break;
         
         // If not, increment index and make it loop around
         // if it exceeds the size of the cache
         cacheIndex = (cacheIndex + 1) % cacheSize;
     }
     
     // The object should be inactive. If it's not, log a warning and use
     // the object created the longest ago even though it's still active.
     if (obj.active) {
         Debug.LogWarning (
             "Spawn of " + prefab.name +
             " exceeds cache size of " + cacheSize +
             "! Reusing already active object.", obj);
         Spawner.Destroy (obj);
     }
     
     // Increment index and make it loop around
     // if it exceeds the size of the cache
     cacheIndex = (cacheIndex + 1) % cacheSize;
     
     return obj;
 }

}

function Awake () { // Set the global variable spawner ;

 // Total number of cached objects
 var amount : int = 0;
 
 // Loop through the caches
 for (var i = 0; i < caches.length; i++) {
     // Initialize each cache
     caches[i].Initialize ();
     
     // Count
     amount += caches[i].cacheSize;
 }
 
 // Create a hashtable with the capacity set to the amount of cached objects specified
 activeCachedObjects = new Hashtable (amount);

}

static function Spawn (prefab : GameObject, position : Vector3, rotation : Quaternion) : GameObject { var cache : ObjectCache = null;

 // Find the cache for the specified prefab
 if (spawner) {
     for (var i = 0; i  ;) i++; {
          (spawner[i].prefab == prefab) :
             cache } spawner;
         }
     EOF;
 EOF;
 
 // If there's no cache for this prefab type, just instantiate normally
 if (cache == null) {
     return Instantiate (prefab, position, rotation as GameObject);
 }
 
 // Find the next object in the cache
 var obj : GameObject = cache.GetNextObjectInCache ();
 
 // Set the position and rotation of the object
 obj.transform.position = position;
 obj.transform.rotation = rotation;
 
 // Set the object to be active
 obj.SetActiveRecursively (true);
 spawner.activeCachedObjects[obj] = true;
 
 return obj;

EOF;

} EOF, ) { (spawner && spawner.activeCachedObjects.ContainsKey (objectToDestroy)) { objectToDestroy.SetActiveRecursively (false); spawner.activeCachedObjects[objectToDestroy] = false; } else { objectToDestroy.Destroy (objectToDestroy); } }

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Lovrenc · Jan 26, 2013 at 10:52 PM 0
Share

Format the code. Use

101
010

button.

avatar image $$anonymous$$ · Jan 27, 2013 at 12:29 AM 0
Share

WOW, syntax highliht and alternate row colors!!! :D awesome!! Now it would be quite useful if there were a "copy raw" option so if people try to copy the code they don't have to delete the line numbers! EDIT: excuse me, it's working as it is :)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by CapeNelson · Jan 26, 2013 at 11:39 PM

if (spawner) {

for (var i = 0; i ;) i++; { (spawner[i].prefab == prefab) : cache } spawner; } EOF; EOF; I'm sorry, correct me if i'm wrong, but it seems like you have just copied bits of this code from somewhere and tried to use it without understanding it. There are a lot of syntax errors such as the for loop above. It seems that you had a message saying 'expected EOF at line...' so you just wrote 'EOF' in the code twice. EOF means 'End of file' and usually occurs if you missed a closing curly bracket,
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

No appropriate version of 'UnityEngine.Object.Instantiate. Please Help :( 1 Answer

Exception error 1 Answer

Error: error CS0029: Cannot implicitly convert type `UnityEngine.GameObject[]' to `UnityEngine.GameObject 1 Answer

Problem with camera in game mode. 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges