Load file/folder: file, Initial path: default (Documents), Title: "Load File", submit button text: "Load" Show a load file dialog and wait for a response from user StartCoroutine(ShowLoadDialogCoroutine()) false, null, "Roast Party: Select Image", "Select") This was quite simple when submitting the photo from a form within a PHP page.Īnyone have any advice on how to store the image to the server?Īdditional Code (Grabbing Photo Data in C# Unity): public void DirectImageFolder()įileBrowser.SetFilters(true, new FileBrowser.Filter("Images", ".jpg", ".png")) įileBrowser.SetExcludedExtensions(".lnk", ".tmp", ".zip", ".rar", ".exe") įileBrowser.AddQuickLink("Users", "C:\\Users", null) I've also experimented with using base64 but I'm having issues sending the photo using base64 from within the C# script in Unity. I've played around with copy and move_uploaded_file. If (move_uploaded_file($_FILES, $target)) echo 'MOVED FILE!' If (copy($_FILES), $target) echo 'MOVED FILE!' file_put_contents($target, file_get_contents($_FILES)) $base64decodedString = base64_decode(urldecode($_FILES)) The code above works as expected, and anything I echo from PHP is logged within the Unity game using "Debug.Log(in the code above. Using (UnityWebRequest www = UnityWebRequest.Post("", form)) String filepathname = Data_Manager.steamID "-" Data_Manager.steamName "-" filename įorm.AddBinaryData("userImage", imageData, filepathname, "image/png") įorm.AddField("steamID", Data_Manager.steamID) įorm.AddField("steamName", Data_Manager.steamName) String filename = Path.GetFileName(path) However, I'm failing to actually store the photo on the server.Ĭ# Unity Code IEnumerator SendFile(byte imageData, string path) I can successfully send the photo from Unity, and the PHP script is getting information about the photo (filename, size, tmp_name). My goal is to store the file path within a database and store the actual image on the server within a subdirectory. Most people go for the manual approach and maintain their own list of objects and perform the instantiating manually on new clients.I'm currently working on a Unity Game Engine project in which I send a photo from the user's local computer within the game to a web server using PHP. There are ways to implement a cleanup system using network groups, but it can get very complicated as well. When the game runs for one or two hours there are thousands of bufferd RPCs stored. Just imagine a game where you instantiate / destroy several objects per minute. If all buffered RPCs remain, a new client would have to execute ALL THOSE when he joins the game. Network.Instantiate does everything for you, but since you can't remove single buffered RPC calls it makes deleting objects way more complicated. ![]() Unity tried to make the whole Networking very easy, however because of that they sacrificed flexibility. When you don't use buffered RPCs you have to "remember" each object yourself on the server machine and if a new client connects, send him the required RPCs to create all objects which are currently there. You have to allocate the ViewIDs manually with Network.AllocateViewID and pass those as parameters of an RPC call to the other players. You can use this link to send RPCs to other players and invoke the instantiation of certain objects. If you want to avoid Network.Instantiate (which can cause a lot of trouble when it comes to removing objects due to the buffered RPC call) the usual way is to have one communication object in the first scene which establish a basic link between all peers so they can communicate. Either the scene, which has to be the exact same scene otherwise the networkViewIDs don't match up, or the prefab which also is the same on both sides. ![]() In both cases both peers have something in common. Network.Instantiate will allocate a new ViewID for each NetworkView on the prefab you instantiate and it transfers those IDs automatically to all other players by sending an internal buffered RPC call which will instantiate the object on the client machines and assign the ViewIDs. The difference to NetworkViewIDs created / allocated at runtime is that those are predefined and therefore both sides will use the same. The NetworkViewIDs on scene objects are special. The NetworkView is placed in a scene and both, the server and the client, load the same scene. There are actually only two basic ways how two NetworkView can be connected: That wouldn't make much sense, but it's possible without any problems. The objects don't actually have to be the same. If two NetworkViews (on different machines) have the same NetworkViewID (which are unique across the network), they are "connected". ![]() The only thing that actually makes a connection between two objects on different machines is the NetworkView. Every player / peer has it's own set of objects. There is nothing like a "network instance".
0 Comments
Leave a Reply. |