- Home /
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?
Clarification: The function running in the first script needs to access an array in the second script.
Is AudioClipStuff class in the namespace of CSharpSynth.Synthesis? Also, which script are you trying to make an instance of?
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();
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.