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 /
This question was closed Mar 08, 2014 at 09:39 PM by NutellaDaddy for the following reason:

People

avatar image
0
Question by NutellaDaddy · Mar 08, 2014 at 04:24 AM · c#script errorinherit

Why can't I pass in void when trying to connect scripts?

On line 11 I try to call the script PlayerCustomizationMenu ,but it won't take the return value of void. The error goes as so: Assets/Scripts/mainMenuOptions.cs(11,46): error CS1525: Unexpected symbol )', expecting .'

and here's the script

 public class mainMenuOptions : MonoBehaviour
 {
     public bool mMOOn = false;
 
     public GUIStyle optionsButton;
     void Start ()
     {
         PlayerCustomizationMenu (void);
     }
     
     void Update ()
     {
     
     }
 
     void OnGUI()
     {
         if(GUI.Button(new Rect(100,100,250, 50),"Options", optionsButton))
         {
             if(mMOOn == false)
             {
                 mMOOn = true;
                 pCMOn = false;
                 sBroOn = false;
             }
         }
     }
 }
 
 
Comment
Add comment · Show 4
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 fifthknotch · Mar 08, 2014 at 04:34 AM 0
Share

Are you trying to call another script or another function within this script?

avatar image VioKyma · Mar 08, 2014 at 04:41 AM 0
Share

Part of the problem is the object oriented nature of using Unity. Unless the object is a Singleton, or static, you will need to reference an instance of the object before you call any functions. Also, if I take your comments literally you cannot directly call a script, only the methods of said object can be called.

avatar image fifthknotch · Mar 08, 2014 at 04:58 AM 1
Share

Yes that is what I was referring to.

avatar image NutellaDaddy · Mar 08, 2014 at 04:59 AM 0
Share

I'm trying to call a class.

2 Replies

  • Sort: 
avatar image
0
Best Answer

Answer by mattyman174 · Mar 08, 2014 at 04:28 AM

You cant pass void as a function parameter.

If the function is ment to accept a parameter but you want that value to be nothing, just pass a default or unaccepted value and check for it in the function.

If it accepts no parameters then what your trying to do in theory is the same as the following.

 PlayerCustomizationMenu ();
Comment
Add comment · Show 12 · 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 NutellaDaddy · Mar 08, 2014 at 04:44 AM 0
Share

Even when i just pass in int or string or something of the sorts it still just says error CS1525: Unexpected symbol )', expecting .'. And if I leave it empty it says Assets/Scripts/main$$anonymous$$enuOptions.cs(11,45): error CS1525: Unexpected symbol )', expecting .'

avatar image VioKyma · Mar 08, 2014 at 04:46 AM 0
Share

See my comment on your answer as to why it's not working. Can you post the script you are trying to call?

avatar image mattyman174 · Mar 08, 2014 at 05:08 AM 1
Share

Your trying to call a Class. You cant do that.

I assume you have little to no $$anonymous$$nowledge on c# program$$anonymous$$g.

I recommend you follow some basic Tutorials on c# program$$anonymous$$g on the Internet. You can find many helpful tutorials by googling.

If your trying to access the Static $$anonymous$$ember of that Class do it the following way.

 PlayerCustomization$$anonymous$$enu.pC$$anonymous$$On;
avatar image Hoeloe · Mar 08, 2014 at 11:02 AM 1
Share

Look, it's quite clear you don't have a clue how object orientation works. You claim to not be new to C#, but that doesn't mean you're good at it, or understand it. The suggestion of looking at some basic tutorials has been the best one so far. Pretty much everything you've said so far is nonsense.

avatar image VioKyma · Mar 08, 2014 at 11:19 PM 1
Share

I'm sure nobody here is out to insult you. They are not complaining about what you don't know, but the fact you are arguing with them about what you don't know. Here's some free advice on asking for help:

  1. Be realistic about what you know and what you need to learn (Don't say you know something when you clearly don't).

  2. When someone corrects you, don't get defensive. You will stop yourself from learning something new.

  3. When someone is trying to help you, don't reject their advice.

I have always found the community to be helpful and kind. I'm not sure why you have been so resistant to the answers that have been provided, when they clearly solve your problem. Please don't take this in an aggressive tone, we're all just trying to help you.

Show more comments
avatar image
0

Answer by fifthknotch · Mar 08, 2014 at 04:36 AM

You may check out:

http://answers.unity3d.com/questions/7555/how-do-i-call-a-function-in-another-gameobjects-sc.html

I believe it expands upon what your question is about.

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

Follow this Question

Answers Answers and Comments

24 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Having trouble moving item from one list to another! 1 Answer

Is there a way to shorten these? 1 Answer

How to create building system like KSP? 1 Answer

Question about GetComponent 1 Answer


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