Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 TheShadyColombian · Apr 30, 2016 at 02:16 AM · buildwebgladvertisingcompile-error

WebGL doesn't work when using UnityEngine.Advertisements

Whenever I try to build to WebGL, I receive the following error:

 Assets/Scripts/SettingsButtons.cs(98,17): error CS0246: The type or namespace name `ShowOptions' could not be found. Are you missing a using directive or an assembly reference?


Does this mean that it won't work because of the advertisements? If so, how can I have them automatically be disabled when I build to WebGL?

Here's the full script for context (It's a kind of swiss-army knife script so there's a bunch of useless stuff in there. I'll remove what I can)

 using UnityEngine;
 using UnityEngine.UI;
 using UnityEngine.Analytics;
 using UnityEngine.Advertisements;
 using System;
 using System.Collections;
 using System.Collections.Generic;
 
 public class SettingsButtons : MonoBehaviour {
 
     public bool Value;
     public Image Img;
     public Sprite EnabledSprite;
     public Sprite DisabledSprite;
 
     //Ads Stuff 
 
     public string zoneId;
 
     // Use this for initialization
     void Start () {
 
         GameObject.Find("MainMenu").GetComponent<Animator>().SetBool("Visible", true);
         GameObject.Find("ExtraMenu").GetComponent<Animator>().SetBool("Visible", false);
 
 
     }
     
     // Update is called once per frame
     void Update () {
 
 
     
     }
 
     public void ShowAd () {
         
         if (string.IsNullOrEmpty (zoneId)) zoneId = null;
 
         ShowOptions options = new ShowOptions();
         options.resultCallback = HandleShowResult;
 
         Advertisement.Show (zoneId, options);
 
     }
 
     public void ExpressAppreciation () {
         GameObject.Find("Thanks").GetComponent<Animator>().SetTrigger("Show");
     }
     public void ExpressRegret () {
         GameObject.Find("YouSuck").GetComponent<Animator>().SetTrigger("Show");
     }
     public void ExpressERROR () {
         GameObject.Find("Error").GetComponent<Animator>().SetTrigger("Show");
     }
 
     private void HandleShowResult (ShowResult result)
     {
         switch (result)
         {
         case ShowResult.Finished:
             ExpressAppreciation();
             break;
         case ShowResult.Skipped:
             ExpressRegret();
             break;
         case ShowResult.Failed:
             ExpressERROR();
             break;
         }
     }
 
 }


Thanks in advance if someone can help.

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 webspawn · May 16, 2016 at 01:47 PM 0
Share

I've the same issue, any solution?

avatar image TheShadyColombian webspawn · May 16, 2016 at 02:10 PM 0
Share

Nothing yet. I don't wanna have to remove all the related code every time I make a build. :\

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by roojerry · May 16, 2016 at 02:18 PM

Wrap your advertise code with preprocessor directives for WebGL. This will keep the code from being compiled for that platform, rather than having to manually remove it yourself.

Comment
Add comment · Show 1 · Share
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 TheShadyColombian · May 16, 2016 at 03:47 PM 0
Share

Excellent! Thank you very much.

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

48 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

Related Questions

Failed build WebGL in Unity5.0.1 2 Answers

Distribute terrain in zones 3 Answers

video-audio not playing in build (i tried webgl and android) 0 Answers

building WebGL app hangs 0 Answers

SetCursor WebGL doesn't work 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