IEnumerator DoAsyncVersionCheck(float fDelay) { bool bShowUpdateMessage = false; yield return(new WaitForSeconds(fDelay)); UnityWebRequest webRequest = UnityWebRequest.Get("http://www.gradientspace.com/s/simplex_version.txt"); yield return(webRequest.Send()); try { if (webRequest.isNetworkError) { DebugUtil.Warning("AutoUpdate : webRequest failed : " + webRequest.error); } else { byte[] data = webRequest.downloadHandler.data; string xml = Encoding.UTF8.GetString(data); XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); bool bOK = false; XmlNode n1 = doc.SelectSingleNode("SimplexVersion"); if (n1 != null) { XmlNode n2 = n1.SelectSingleNode("Current"); if (n2 != null) { string version = n2.InnerText; int nVersion; if (int.TryParse(version, out nVersion)) { bOK = true; if (nVersion > SimplexConfig.CurrentVersion) { bShowUpdateMessage = true; } } } } if (!bOK) { DebugUtil.Warning("AutoUpdate : error reading/parsing downloaded data"); } } } catch (Exception e) { DebugUtil.Warning("AutoUpdate : exception trying to hande webreqeuest response : " + e.Message); } if (bShowUpdateMessage) { HUDUtil.ShowToastPopupMessage("A new version of Simplex is available! You should update!", parent); } UnityEngine.Component.Destroy(parent.RootGameObject.GetComponent <AutoUpdateBehavior>()); }
void Restore_OnAttribute(string sName, string sValue) { if (eState != RestoreState.InSceneObject && eState != RestoreState.InStruct) { throw new FormatException("[Serializer] not in correct state for OnAttrib"); } char[] delimiterChars = { ' ' }; if (sName == IOStrings.Struct) { } else if (sName[0] == 'i') { int iValue = 0; int.TryParse(sValue, out iValue); CurAttribs.Pairs[sName] = iValue; } else if (sName[0] == 'f') { float fValue = 0; float.TryParse(sValue, out fValue); CurAttribs.Pairs[sName] = fValue; } else if (sName[0] == 'b') { bool bValue = true; if (sValue.Equals("false", StringComparison.InvariantCultureIgnoreCase)) { bValue = false; } CurAttribs.Pairs[sName] = bValue; } else if (sName[0] == 'v') { float x = 0, y = 0, z = 0; string[] values = sValue.Split(delimiterChars); if (values.Length == 3) { float.TryParse(values[0], out x); float.TryParse(values[1], out y); float.TryParse(values[2], out z); } CurAttribs.Pairs[sName] = new Vector3f(x, y, z); } else if (sName[0] == 'u') { float x = 0, y = 0; string[] values = sValue.Split(delimiterChars); if (values.Length == 2) { float.TryParse(values[0], out x); float.TryParse(values[1], out y); } CurAttribs.Pairs[sName] = new Vector2f(x, y); } else if (sName[0] == 'q') { float x = 0, y = 0, z = 0, w = 0; string[] values = sValue.Split(delimiterChars); if (values.Length == 4) { float.TryParse(values[0], out x); float.TryParse(values[1], out y); float.TryParse(values[2], out z); float.TryParse(values[3], out w); } CurAttribs.Pairs[sName] = new Quaternionf(x, y, z, w); } else if (sName[0] == 'c') { float r = 0, g = 0, b = 0, a = 0; string[] values = sValue.Split(delimiterChars); if (values.Length == 4) { float.TryParse(values[0], out r); float.TryParse(values[1], out g); float.TryParse(values[2], out b); float.TryParse(values[3], out a); } CurAttribs.Pairs[sName] = new Colorf(r, g, b, a); } else if (sName[0] == 'z') { if (sName[1] == 'd' && sName[2] == '3') { CurAttribs.Pairs[sName] = restore_list3d(sValue); } else if (sName[1] == 'f' && sName[2] == '3') { CurAttribs.Pairs[sName] = restore_list3f(sValue); } else if (sName[1] == 'i' && sName[2] == '3') { CurAttribs.Pairs[sName] = restore_list3i(sValue); } else if (sName[1] == 'd' && sName[2] == '2') { CurAttribs.Pairs[sName] = restore_list2d(sValue); } else if (sName[1] == 'f' && sName[2] == '2') { CurAttribs.Pairs[sName] = restore_list2f(sValue); } else { DebugUtil.Warning("[SceneSerializer.Restore_OnAttribute] - unknown array format {0}", sName); } } else if (sName[0] == 'x') { if (sName[1] == 'd' && sName[2] == '3') { CurAttribs.Pairs[sName] = restore_list3d_binary(sValue); } else if (sName[1] == 'f' && sName[2] == '3') { CurAttribs.Pairs[sName] = restore_list3f_binary(sValue); } else if (sName[1] == 'i' && sName[2] == '3') { CurAttribs.Pairs[sName] = restore_list3i_binary(sValue); } //else if (sName[1] == 'd' && sName[2] == '2') // CurAttribs.Pairs[sName] = restore_list2d_binary(sValue); else if (sName[1] == 'f' && sName[2] == '2') { CurAttribs.Pairs[sName] = restore_list2f_binary(sValue); } else { DebugUtil.Warning("[SceneSerializer.Restore_OnAttribute] - unknown binary format {0}", sName); } } else { CurAttribs.Pairs[sName] = sValue; } }
void HandleInput_SpaceControllers() { // update cursors SpatialController.Update(); MouseController.HideCursor(); // have to do this after cursor update in case hotkey uses mouse position HandleKeyboardInput(); // create our super-input object (wraps all supported input types) InputState input = new InputState(); input.Initialize_SpatialController(this); lastInputState = input; // run override behaviors overrideBehaviors.SendOverrideInputs(input); input.LeftCaptureActive = (captureLeft != null); input.RightCaptureActive = (captureRight != null); // update left-capture if (captureLeft != null) { Capture cap = captureLeft.element.UpdateCapture(input, captureLeft.data); if (cap.state == CaptureState.Continue) { // (carry on) } else if (cap.state == CaptureState.End) { DebugUtil.Log(10, "[SceneController] released left capture " + captureLeft.element.CaptureIdentifier); if (captureRight == captureLeft) { captureRight = null; // if we are doing a dual-capture, we only want to end once!! } captureLeft = null; } } // update right-capture // if we are doing a both-capture, we only want to send update once if (captureRight != null && captureRight != captureLeft) { Capture cap = captureRight.element.UpdateCapture(input, captureRight.data); if (cap.state == CaptureState.Continue) { // (carry on) } else if (cap.state == CaptureState.End) { DebugUtil.Log(10, "[SceneController] released right capture " + captureRight.element.CaptureIdentifier); captureRight = null; } } // if we have a free device, check for capture. bool bCanCapture = (bInCameraControl == false); if (bCanCapture && (captureLeft == null || captureRight == null)) { // collect up capture requests List <CaptureRequest> vRequests = new List <CaptureRequest>(); inputBehaviors.CollectWantsCapture(input, vRequests); if (vRequests.Count > 0) { // end outstanding hovers TerminateHovers(input); // select one of the capture requests. technically we could end // up with none successfully Begin'ing, but behaviors should be // doing those checks in WantCapture, not BeginCapture !! vRequests.OrderBy(x => x.element.Priority); Capture capReq = null; for (int i = 0; i < vRequests.Count && capReq == null; ++i) { // filter out invalid requests CaptureSide eUseSide = vRequests[i].side; if (eUseSide == CaptureSide.Any) // replace Any with Both. Does that make sense?? { eUseSide = CaptureSide.Both; } if ((eUseSide == CaptureSide.Left || eUseSide == CaptureSide.Both) && captureLeft != null) { continue; } if ((eUseSide == CaptureSide.Right || eUseSide == CaptureSide.Both) && captureRight != null) { continue; } Capture c = vRequests[i].element.BeginCapture(input, eUseSide); if (c.state == CaptureState.Begin) { capReq = c; } } if (capReq != null) { // technically we only should terminate hover on capture controller, // but that seems really hard. This will clear hovers but they will // come back next frame. Perhaps revisit if this is causing flicker... TerminateHovers(input); // [RMS] most of this checking is redundant now, but leaving because of debug logging if (capReq.data.which == CaptureSide.Left) { if (captureLeft != null) { DebugUtil.Warning("[SceneController.HandleInput_SpaceControllers] received Capture request for Left side from {0}, but already capturing! Ignoring.", capReq.element.CaptureIdentifier); } else { captureLeft = capReq; DebugUtil.Log(10, "[SceneController] began left-capture" + captureLeft.element.CaptureIdentifier); } } else if (capReq.data.which == CaptureSide.Right) { if (captureRight != null) { DebugUtil.Warning("[SceneController.HandleInput_SpaceControllers] received Capture request for Right side from {0}, but already capturing! Ignoring.", capReq.element.CaptureIdentifier); } else { captureRight = capReq; DebugUtil.Log(10, "[SceneController] began right-capture" + captureRight.element.CaptureIdentifier); } } else if (capReq.data.which == CaptureSide.Both || capReq.data.which == CaptureSide.Any) { if (captureLeft != null || captureRight != null) { DebugUtil.Warning("[SceneController.HandleInput_SpaceControllers] received Capture request for both sides from {0}, but already capturing! Ignoring.", capReq.element.CaptureIdentifier); } else { captureLeft = captureRight = capReq; DebugUtil.Log(10, "[SceneController] began both-capture " + captureLeft.element.CaptureIdentifier); } } } } } // update hover if we have a free device if (captureLeft == null || captureRight == null) { inputBehaviors.UpdateHover(input); } }