unity-webgl

Unable to type in input with Unity WebGL background div in React JS

橙三吉。 提交于 2019-12-12 04:43:56
问题 import React from 'react'; import ReactDOM from 'react-dom'; import {Unity} from 'react-unity-webgl'; var timerCount = 0; export default class App extends React.Component { constructor(props) { super(props); this.state = { nPageNum: 0}; } componentDidMount() { this.startTimer(this); } render() { if (timerCount > 5) { return( <div style={{ width: '100%', height: '100%' }}> <div style={{ position: 'absolute', width: '100%', height: '100%', zIndex: 0 }}> <Unity src="Libs/object_unity/Build/WebGL

How to scale A Unity-WebGL game to browser window

人盡茶涼 提交于 2019-12-11 19:35:16
问题 I've built a Unity game for web, setting the default resolution to 1152 x 648 for testing. The output html file had the following code: <!DOCTYPE html> <html lang="en-us"> <head> <meta charset="utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Unity WebGL Player | MyGame</title> <link rel="shortcut icon" href="TemplateData/favicon.ico"> <link rel="stylesheet" href="TemplateData/style.css"> <script src="TemplateData/UnityProgress.js"></script> <script src=

Huge world loading/unloading in unity webgl using asset bundles

南楼画角 提交于 2019-12-11 03:07:55
问题 I have a very large 3D world/Environment which I have divided into 1000 x 1000 m (1km) tiles . Made assetbundles of all tiles and currently there are only 5 asset bundles (Expected to grow significantly maybe around 1000 asset bundles). Loading\unloading these asset bundles , i am calculating the distance of my player/camera with the tile and then calling for load or unload. Please see below simple script (Loading tiles based on distance): public Vector3 tileSize; public int maxDistance;

Return string from UnityWebGL jslib

家住魔仙堡 提交于 2019-12-11 01:59:52
问题 I want use jslib to get url parameter code like this jslib GetUrl: function(){ var s =""; var strUrl = window.location.search; var getSearch = strUrl.split("?"); var getPara = getSearch[1].split("&"); var v1 = getPara[0].split("="); alert(v1[1]); return v1[1]; }, }); c# [DllImport("__Internal")] public static extern string GetUrl(); void Start () { TextShow.text = GetUrl(); } When run alert from jslib , I see right string show in alert but UGUI Text shows nothing. Why did this happen? 回答1: To

Unity WebGL - Prevent <Canvas> From eating up all Mouse / Keyboard Input? (HTML Input Fields)

十年热恋 提交于 2019-12-11 01:27:36
问题 Unity 5.4 Building a Unity WebGL application (not a game) that handles all 3D content on the Unity side of things, and all the UI is built using HTML/CSS/JS. By default, WebGLInput.captureAllKeyboardInput is set to true, which causes any input fields that require keyboard (text) input to be broken, as any keyboard controls are automatically being eaten up by Unity rather than going to the input field. Doing #if !UNITY_EDITOR && UNITY_WEBGL WebGLInput.captureAllKeyboardInput = false; #endif

Calling javascript string function on browser from Unity returns null

♀尐吖头ヾ 提交于 2019-12-10 11:25:29
问题 I have a WebGL unity project which attempts to execute javascript code on the browser and return a value. I have the following .jslib file in my Assets/Plugins/WebGL folder: var BrowserPlugin = { GetEndpointURL: function() { var endpoint = window.itd.getEndpointUrl(); console.log("endpoint: " + endpoint); return endpoint; } }; mergeInto(LibraryManager.library, BrowserPlugin); In my c# code in unity, I import the dll and call my javascript method like so: [DllImport("__Internal")] private

Unity WebGL asset bundle memory is not releasing

核能气质少年 提交于 2019-12-08 17:01:30
问题 I am loading and Caching Asset Bundles using below function in unity webgl : IEnumerator DownloadAndCacheAB(string assetName) { // Wait for the Caching system to be ready while (!Caching.ready) yield return null; // Load the AssetBundle file from Cache if it exists with the same version or download and store it in the cache using (WWW www = WWW.LoadFromCacheOrDownload(finalUrl, 1)) { yield return www; if (www.error != null) { Debug.Log("WWW download had an error:" + www.error); } AssetBundle

How create a angular module to Unity 3D?

為{幸葍}努か 提交于 2019-12-08 05:42:04
问题 I wish made an Angular module using Unity WebGL. Indeed nothing has already done on this topic and no module existed today. However, I am little lost and I need help. It would be good if that module will develop to Angular 2. But I know Angular 1 so far. Unity 3D export gave that: <!doctype html> <html lang="en-us"> <head> <meta charset="utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Unity WebGL Player | Test Unity</title> <style> /* a style sheet needs to

Generic/Unknown HTTP Error with response code 0 using UnityWebRequest

我的梦境 提交于 2019-12-07 05:32:04
问题 I was trying to use some server's API functions, and suddenly came to this error. I will explain it after the code sample: public IEnumerator Post(Dictionary<string, string> data) { var request = UnityWebRequest.Post(Url, data); request.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded"); yield return request.Send(); if (request.isError) UpdateNetworkLog("Network error has occured: " + request.error); else // Some code after success } As you can see, mostly I took it from

Calling javascript string function on browser from Unity returns null

微笑、不失礼 提交于 2019-12-06 09:35:39
I have a WebGL unity project which attempts to execute javascript code on the browser and return a value. I have the following .jslib file in my Assets/Plugins/WebGL folder: var BrowserPlugin = { GetEndpointURL: function() { var endpoint = window.itd.getEndpointUrl(); console.log("endpoint: " + endpoint); return endpoint; } }; mergeInto(LibraryManager.library, BrowserPlugin); In my c# code in unity, I import the dll and call my javascript method like so: [DllImport("__Internal")] private static extern string GetEndpointURL(); string endpointURL = GetEndpointURL(); The problem is, in my c# code