//------------------------------------------------------------------------- public void executePurchase() { foreach (KeyValuePair <string, int> entry in this.shoppingList) { WbCompRPCWrapper.getInstance().networkView.RPC("addItemToShoppingListExternal", RPCMode.Server, this.currentRetailLocationName.ToString(), entry.Key, entry.Value); } WbCompRPCWrapper.getInstance().networkView.RPC("executeExternalPurchase", RPCMode.Server); }
void Update() { // send render texture data frame rate independent if (NetworkManager.getInstance().isActiveConnection&& !WbCompRPCWrapper.getInstance().getBackViewCameraFrameAsB64String().Equals("empty")) { if (timeSinceLastStart >= 1f / NetworkManager.getInstance().globalRPCSendRate) { this.setBackViewCamera(); this.timeSinceLastStart = 0; } this.timeSinceLastStart += Time.deltaTime; } }
//--------------------------------------------------------------------- // convert b64 string to byte[] // decode byte[] to PNG texture // assign PNG texture to material private void setBackViewCamera() { string texBase64 = WbCompRPCWrapper.getInstance().getBackViewCameraFrameAsB64String(); int imgPart = WbCompRPCWrapper.getInstance().imgPart; int imgWidth = WbCompRPCWrapper.getInstance().imgWidth; int imgHeight = WbCompRPCWrapper.getInstance().imgHeight; int imgSlices = WbCompRPCWrapper.getInstance().imgSlices; try{ byte[] texBin = Convert.FromBase64String(texBase64); Texture2D tex = new Texture2D(128, 128, TextureFormat.RGB24, false); tex.LoadImage(texBin); this.gameObject.GetComponent <Renderer>().material.SetTexture("_MainTex", tex); }catch (Exception e) { print(e); } }