Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
0
Question by Devmaster12 · Apr 29 at 11:09 AM · networkingmultiplayermultiplayer-networkingui imagepersistentdatapath

How to reflect an image uploaded to one scene to another scene

I am making a small multiplayer game in which a visitor and an uploader will join at the same time. The uploader will upload an image to their scene(https://stackoverflow.com/questions/35183253/unity3d-upload-a-image-from-pc-memory-to-webgl-app) I want this image to be visible on an image in the main game which the visitor is playing. This game will be running on a headless server and all the networking is done using Mirror.

I don't have any clues as to how to code or implement this. Any help is appreciated.

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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by GetLitGames · Apr 29 at 02:58 PM

You should be able to send the texture sprite as an array of bytes to the server via RPC. You can google for how to convert a texture to byte array, and a byte array into a texture. This is referred to as Serialization, you can serialize it to bytes to send to the server via RPC or to store somewhere on disk. Once you have a reference to the texture in memory all you need to do is assign it to a variable that's either on a static class or a monobehavior class attached to an object where you called Don't Destroy On Load so that when you switch scenes it stays around. If you don't already have Manager/Controller type classes or Singleton pattern classes then you should look into them as well as ScriptableObjects.

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
avatar image
1

Answer by VanToRiaXVII · May 04 at 02:52 PM

If you're looking to upload a picture that doesn't already exist in the game, you're gonna need to set up a web server to make that possible. You could check out upload.io, which has a simple API to upload and then visualize images. Once you have that, you need to find out a way to check when the image has successfully been uploaded so it can be displayed on the other player's screen.

Comment
Add comment · Show 4 · 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 Devmaster12 · May 05 at 10:34 AM 0
Share

I have a web server set up, it is hosted on GCP. But, I am not sure how to upload to the game. upload.io seems like a website solution, I am not sure how that will help with a unity build game? Could you possibly give me a little more insight as to what you are suggesting ??

avatar image VanToRiaXVII Devmaster12 · May 05 at 03:02 PM 0
Share

You only need to upload an image for your game and retrieve it from the other player's client. To do that, you need to make a call from your game to upload the image to the web server. You need to build this web server to receive an image and then send it back, on-demand, to the other player.

upload.io can do that for you without having to set up a web server on your end. Everything works with APIs, so you simply have to make the call to upload it and retrieve it for the other player. It'd save you the time to set up and manage a web server.

avatar image Devmaster12 VanToRiaXVII · May 05 at 10:10 PM 0
Share

I actually am already running a headless server which connect my visitor and uploader at the same time. Will upload.io still help automate the process of uploading and retrieving ??

Show more comments
avatar image
0

Answer by Devmaster12 · Apr 30 at 05:24 PM

Is there any other approach of doing this ??

Comment
Add comment · Show 4 · 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 GetLitGames · May 05 at 10:35 AM 1
Share

Ah I think I see part of your problem. I will add some more info.

avatar image GetLitGames · May 05 at 10:56 AM 0
Share

You should be able to create a Mirror RPC with a byte[] array parameter and just call it, after converting the Texture to a byte array. On the server you convert it back into a texture. If you need to save it on the server, then write it to a file or something - you will need to google that.

avatar image Devmaster12 GetLitGames · May 05 at 11:19 AM 0
Share

Your solution seems perfect for what I am trying to do. Currently, I have a script in place which already converts the texture to byte array. Could you tell me how to create the Mirror RPC and call it, as well as the converting back into texture part ??

Converting into byte array: byte[] pngData = System.Convert.FromBase64String(dataUrl.Substring(s_dataUrlPrefix.Length));

         // Create a new Texture (or use some old one?)
         Texture2D tex = new Texture2D(1, 1); // does the size matter?
         if (tex.LoadImage(pngData))
         {
             Renderer renderer = GetComponent<Renderer>();

             renderer.material.mainTexture = tex;
avatar image GetLitGames Devmaster12 · May 10 at 02:50 PM 0
Share

Below is the reference with example code. I think you may want to use a Command to get it from a client to the server. Once the server has it, use a ClientRPC to send it to all the clients. https://mirror-networking.gitbook.io/docs/guides/communications/remote-actions

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

254 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 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 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 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 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

Unity networking tutorial? 6 Answers

how can i change my scripts to make them multiplayer aware,How can I change my scripts to make them multiplayer aware? 1 Answer

Mirror multiplayer Command issue 0 Answers

UNET Multiplayer Lobby not creating an instance of the lobby player 1 Answer

Setting slow projectile's moving direction in a networked fps style game (on server, owner client and proxy clients) 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