• 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 zak666 · Jun 30, 2015 at 12:49 PM · scripting problem

"Unexpect symbol public"

Hi, Really gearing up here. everything coming together. I'm trying to build a script that loads prefabs form a Folder on my website, on connection calls from a www. class and then instantiates prefabs as child as "User" Game Object. and trying to unserstand Unity Online coding in more depth. // yess i have my own site and have it to replace "your

 using UnityEngine;
 using System.Collections;
 
 public class UserShips : MonoBehaviour 
 {
     [System.Serializable]    
 
 
 void Connect (){ 
         PhotonView pv = PhotonView.Get(this);
         
         if (pv.isMine)
          // If this belongs to the owner of this User.
         public string path = "http://www.yourwebsitehere.com/Assets/Figheters";  //get assets / fighters folder.
         IEnumerator Start()
         {
             WWW www = new WWW(url);
             yield return www;  // Returns the folder "Fighters" and all the prefabs of fighters.
             Debug("has got Folder Fighters from Online Fighters Hanger Awaiting command."); 
             UnityEditor.AssetDatabase.CreateAsset(Fighters, path);
             UnityEditor.AssetDatabase.ImportAsset(path);
             
                      // Instantiate Prefabs from folder from path as child of User 
                     // All fighters are automaticly Inactive.
                 SpawnedObject Fighters = PhotonNetwork.Instantiate ("Fighters", transform.position, transform.rotation,0);
                 
             }
 
     } // End of Start Void.
 } // end of public class
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Landern · Jun 30, 2015 at 12:51 PM

Your local variable in the Connect method is scoped to that method, you do not need to set the access modifiers, remove the word public on line 14.

Although you may have wanted to put the string variable as a field in the class, for some reason you have a lingering System.Serializable.

Comment
Add comment · Show 5 · 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
avatar image zak666 · Jun 30, 2015 at 02:08 PM 0
Share

Hi, That Solved Alot of my Issues. I have made the following changes and has become alot simpler however is feeking out over "IEnumerator Start()" Epecting (). I've Removed the "public and set the url to website folder directory in the WWW class then the assets are loaded fromulr into a database Fighters and network instatiated into the game. I hope I'm on the right track with this.

 using UnityEngine;
 using System.Collections;
 
 public class UserShips : $$anonymous$$onoBehaviour 
 {
     void Connect ()
     { 
         PhotonView pv = PhotonView.Get(this);
         
         if (pv.is$$anonymous$$ine)
             // If this belongs to the owner of this User.
     
             IEnumerator Start()
 
         {
         url = "http://www.yourwebsitehere.com/Assets/Figheters";  //get assets / fighters folder.
             WWW www = new WWW(url); // get the Declaired URL.
             yield return www;  // Returns the folder "Fighters" and all the prefabs of fighters.
             Debug("has got Folder Fighters from Online Fighters Hanger Awaiting command."); 
             UnityEditor.AssetDatabase.CreateAsset(Fighters, url); // creat and load folder as Fighters.
             UnityEditor.AssetDatabase.ImportAsset(url); //import Fighters Assets.
 
         FightersLoad = PhotonNetwork.Instantiate (Fighters, transform.position, transform.rotation,0);
             // All fighters are now in game and available to the User If it is Unlocked.
         }
     }
 }

avatar image Landern · Jun 30, 2015 at 02:12 PM 0
Share

Hrm, didn't notice that last night, IEnumerator Start() is the beginning of a method, just like void Connect(). Your script is kinda out of wack. You're missing variables and all sorts of stuff.

You need to clean this up as it's not functional and i can only guess:

  using UnityEngine;
  using System.Collections;
  
  public class UserShips : $$anonymous$$onoBehaviour 
  {
      
      // WHEN DOES THIS GET CALLED?
      void Connect ()
      { 
          PhotonView pv = PhotonView.Get(this);
          
          if (pv.is$$anonymous$$ine)
              // If this belongs to the owner of this User.
      }     
      
      IEnumerator Start()
      {
          string url = "http://www.yourwebsitehere.com/Assets/Figheters";  //get assets / fighters folder. // THIS WAS NOT TYPED OUT AS A STRING
          WWW www = new WWW(url); // get the Declaired URL.
          yield return www;  // Returns the folder "Fighters" and all the prefabs of fighters.
          Debug("has got Folder Fighters from Online Fighters Hanger Awaiting command."); 
          UnityEditor.AssetDatabase.CreateAsset(Fighters, url); // creat and load folder as Fighters.
          UnityEditor.AssetDatabase.ImportAsset(url); //import Fighters Assets.
          GameObject FightersLoad = PhotonNetwork.Instantiate (Fighters, transform.position, transform.rotation,0); // WHAT IS FightersLoad? Should it be local or part of the class?
          // All fighters are now in game and available to the User If it is Unlocked.
      }
  }
 

If this the original answer worked, mark as solved and work out your script issues and come back and post a new question if you need help.

avatar image Hrungdak · Jun 30, 2015 at 02:18 PM 0
Share

void Start() is a Unity-$$anonymous$$ethod. Don't use the name for your own methods.

avatar image tanoshimi · Jun 30, 2015 at 04:21 PM 0
Share

@Hrungdak I think the whole point is that that is the Start() method they OP wants Unity to call. So it has to be called Start...

avatar image LaneFox · Jun 30, 2015 at 04:50 PM 0
Share

then use void Start() { StartCoroutine(Begin()); }

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

help with animation 1 Answer

Why my editor vs code opens a few windows when i try to open a script from unity,My VS Code open a few tables when i double click a script in Unity? 0 Answers

[Unity5] Performance and functions 3 Answers

How to make script affect only one this game object 2 Answers

Characterdoesn't run on Aiming 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