- Home /
Question by
kevc45 · Feb 02, 2017 at 10:58 PM ·
gitunity cloud buildextension-methods
Unity Cloud Build can't find extension method, however local build can
I seem to have an issue with Unity Cloud Build where it can't find an extension method. However, when I do a local build, it works just find. Is Util like reserved? I don't believe it's my .gitignore.
Cloud Build Error:
651: [Unity] -----CompilerOutput:-stdout--exitcode: 1--compilationhadfailure: True--outfile: Temp/Assembly-CSharp.dll
652: [Unity] Compilation failed: 2 error(s), 0 warnings
653: [Unity] Assets/Scripts/Player.cs(212,43): error CS1061: Type `UnityEngine.AudioClip[]' does not contain a definition for `RandomElement' and no extension method `RandomElement' of type `UnityEngine.AudioClip[]' could be found. Are you missing an assembly reference?
654: [Unity] /UNITY_PATH/Unity/Unity-5_5_1f1/Unity.app/Contents/Managed/UnityEngine.dll (Location of the symbol related to previous error)
655: [Unity] Assets/Scripts/Player.cs(218,41): error CS1061: Type `UnityEngine.AudioClip[]' does not contain a definition for `RandomElement' and no extension method `RandomElement' of type `UnityEngine.AudioClip[]' could be found. Are you missing an assembly reference?
656: [Unity] /UNITY_PATH/Unity/Unity-5_5_1f1/Unity.app/Contents/Managed/UnityEngine.dll (Location of the symbol related to previous error)
657: [Unity] - Finished compile Library/ScriptAssemblies/Assembly-CSharp.dll
658: [Unity] Assets/Scripts/Player.cs(212,43): error CS1061: Type `UnityEngine.AudioClip[]' does not contain a definition for `RandomElement' and no extension method `RandomElement' of type `UnityEngine.AudioClip[]' could be found. Are you missing an assembly reference?
659: [Unity] (Filename: Assets/Scripts/Player.cs Line: 212)
660: [Unity] Assets/Scripts/Player.cs(218,41): error CS1061: Type `UnityEngine.AudioClip[]' does not contain a definition for `RandomElement' and no extension method `RandomElement' of type `UnityEngine.AudioClip[]' could be found. Are you missing an assembly reference?
Player:
namespace MyNamespace
{
public class Player : MonoBehaviour
{
[Header("Audio")]
public AudioClip[] footstepClips;
public AudioClip[] attackClips;
private AudioSource audioSource;
protected void Awake()
{
audioSource = GetComponent<AudioSource>();
}
public void PlayFootstep()
{
if(footstepClips.Length > 0)
audioSource.PlayOneShot(footstepClips.RandomElement(), 0.5F);
}
public void PlayAttack()
{
if(attackClips.Length > 0)
audioSource.PlayOneShot(attackClips.RandomElement(), 0.5F);
}
}
}
Extension method:
using UnityEngine;
namespace MyNamespace
{
public static class Util
{
public static T RandomElement<T>(this T[] values)
{
return values[Random.Range(0, values.Length)];
}
}
}
Comment
Yes, it always was: . For some reason, the build succeeds now, however I still get the error.
screenshot378-censored.png
(31.7 kB)