• 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
0
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
Add comment · Show 2
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 hexagonius · Feb 03, 2017 at 10:07 AM 0
Share

is the script checked into the repo?

avatar image kevc45 hexagonius · Feb 03, 2017 at 03:43 PM 0
Share

Yes, it always was: alt text. For some reason, the build succeeds now, however I still get the error.

screenshot378-censored.png (31.7 kB)

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

64 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 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 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

Unity Cloud Build bit-bucket LFS and Textures 0 Answers

Ios cloud build fails, due to compile error before xcode, cannot find a .cs file which although exists 0 Answers

Behaviour is missing when using project on different computer. 1 Answer

Git submodule error in Unity 0 Answers

How can I stop unity from defining source control plugins for my visual studio project? 0 Answers


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