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
1
Question by smnerat · May 24, 2014 at 09:28 PM · c#classnamespace

Calling functions from other namespaces and scripts.

So I know a similar question has been asked quite a bit but I'm having some trouble when it comes to calling functions in a script from a certain name space and class. I'm relatively new to C# and can't seem to get this straightened out.

I have a function running in this namespace and class:

 using System;
 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 using CSharpSynth.Banks;
 using CSharpSynth.Synthesis;
 using AOT;
 
 namespace CSharpSynth.Synthesis
 {
 
     public class Voice
     {
         
         //--Variables


I would like to access an array in this script that I have created:

 public class AudioClipStuff : MonoBehaviour
 {
 
     //--Variables


When I attempt to create an instance of the script, I get the following error:

"CSharpSynth.Synthesis.Voice.AudioClipStuff' is a field' but a type' was expected."

What am I doing wrong?

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 smnerat · May 24, 2014 at 09:29 PM 0
Share

Clarification: The function running in the first script needs to access an array in the second script.

avatar image LawSumisu · May 24, 2014 at 09:47 PM 0
Share

Is AudioClipStuff class in the namespace of CSharpSynth.Synthesis? Also, which script are you trying to make an instance of?

avatar image smnerat · May 24, 2014 at 10:18 PM 0
Share

No its not in the same namespace. I was trying to create a instance of AudioClipStuff using:

 public AudioClipStuff AudioClipStuff;

When I try and put the AudioClipStuff script inside of the CSharpSynth.Synthesis namespace I cannot access audio functions from the AudioClipStuff script.

The following part isn't recognized:

             audio.clip = myClip;
             audio.Play();
avatar image LawSumisu · May 25, 2014 at 11:53 AM 0
Share

I'm assu$$anonymous$$g you mean:

 public AudioClipStuff audio;

right?

Also, I'm still confused; why are you trying to put the AudioClipStuff script within the CSharpSynth.Synthesis namespace if they are initially separate?

By the way, you can't instantiate an object that inherits from $$anonymous$$onoBehavior like you do for regular objects. It has to be added as a Component either in the Inspector or programmatically.

0 Replies

· Add your reply
  • Sort: 

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

21 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

Related Questions

Why is Start() from my base class ignored in my sub-class? 4 Answers

The type or namespace name 'StateMachine' could not be found (are you missing a using directive or an assembly reference?) 1 Answer

How to make costume classes Visible in the Inspector 3 Answers

Distribute terrain in zones 3 Answers

Conversion of a static class to struct? 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