Hi all. What I am basically trying to do is take a bunch of functions out of one of my scripts and put them into their own script, basically turning them into my own little library. For the most part I have gotten this to work. The only thing I can’t seem to get to work is the IEnumerator. I have figured out that I can’t call it with StartCoroutine as that appears to be a non-static member trying to call a static member. I think I have the call right, the problem is the raycast inside of it. Since this script isn’t attached to anything, I’m not 100% sure the raycast I have inside of it is doing anything. Any suggestions on the direction I should head in would be greatly appreciated. Code follows:
public static IEnumerator DisableInput(GameObject[] gos, RaycastHit hitItem)
{
LearningObject snd;
snd = hitItem.collider.gameObject.GetComponent("LearningObject") as LearningObject;
float soundDuration = snd.audio.clip.length;
if(snd.hasSound && snd.audio.isPlaying)
{
for(int i = 0; i < gos.Length; i++)
{
gos*.layer = 2;*
-
print("You are now on the ignore raycast layer");*
-
}*
-
yield return new WaitForSeconds(soundDuration);*
-
for(int j = 0; j < gos.Length; j++)*
-
{*
-
gos[j].layer = 0;*
-
}*
-
print("You are back on the default layer.");*
-
}*
-
}*
-
public static void LoopThroughObjects(GameObject gos, ArrayList myList, RaycastHit hitItem, MonoBehaviour instance)*
-
{*
-
for(int i = 0; i < gos.Length; i++)*
-
{*
-
print("The count of the arraylist is now at: " + myList.Count);*
-
print("The object that was just clicked is: " + hitItem.collider.gameObject.name);*
_ if(hitItem.collider.gameObject == gos*)_
_ {_
_ bool foundit = false;*_
* for(int j = 0; j < myList.Count; j++)*
* {*
* print("i equals " + i + " and j is " + j);*
_ if(gos == myList[j])
* {
foundit = true;
print("Found it is now set to " + foundit );
break;
}
}*_
* if(!foundit)*
* {*
* myList.Add(hitItem.collider.gameObject);*
* print("The items in the array are now " + myList.Count);*
* instance.StartCoroutine(DisableInput(gos, hitItem));*
* }*
* }*