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 /
  • Help Room /
avatar image
0
Question by deDarxo · Jun 01, 2016 at 02:33 PM · build errornetworkviewhtml5

Exclude Network View from WebGL Build

I want my to build my current project for WebGL. It was originally made for PC, Mac & Linux Standalone and therefore there were many parts of the programm (mainly about networking stuff) that had to be excluded.

For Scripts there are precompiler directives and for Plugins (.dll) there is the option to choose for which platform they should be included.

Now I'm facing the problem that I have the component NetworkView attached to 2 Prefabs and 1 Gameobject in the scene.

NetworkView is needed for the original platform build but the WebGL build won't work while this component is on any gameobject/prefab.

I tried deactivating them in the Editor. This didn't make any difference. I also wrote a Script that was supposed to remove these components at the start.

     void Start () 
     {
 #if UNITY_WEBGL
         Destroy(GetComponent<NetworkView>());
 #endif
     }

This was the resulting error

Assets/WebGLManager.cs(14,9): error CS0246: The type or namespace name `NetworkView' could not be found. Are you missing a using directive or an assembly reference?

Is there a method to exclude a component in general (or NetworkView in this particular case) from a specific build so that I don't have to delete these components manually everytime I want to do a WebGL build?

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by deDarxo · Jun 20, 2016 at 09:03 AM

Right know I'm using this script as a solution. Instead of the component "NetworkView" I just added this script to the respective gameobjects.

But I don't know how reliable it is in the longterm if this component is created at runtime.

 using UnityEngine;
 using System.Collections;
 
 public class CreateNetworkView : MonoBehaviour {
 #if !UNITY_WEBGL
     public NetworkStateSynchronization stateSynchronization;
     public Transform observed;
 
     public void Awake()
     {
         AddNetworkView();
     }
 
     [RPC]
     private void AddNetworkView()
     {
         gameObject.AddComponent<NetworkView>();
         gameObject.GetComponent<NetworkView>().observed = observed;
         gameObject.GetComponent<NetworkView>().stateSynchronization = stateSynchronization;
         gameObject.GetComponent<NetworkView>().viewID = Network.AllocateViewID();
     }
 #endif
 }

Comment
Add comment · 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

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

57 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

Related Questions

Replace NetworkView with NetworkIndentity? URGENT! 0 Answers

How can I get HTML elements on top of Unity WebGL frame? 0 Answers

build settings error 0 Answers

unity can't build games for windows: moving Temp/StagingArea/WindowsPlayer.exe to Temp/StagingArea/testbuild.exe: the sytem cannot find the given file 0 Answers

Touch Controls not working after build,but working in unity remote 5 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