简体   繁体   English

Unity 2D 我可以从游戏中上传图片吗?

[英]Unity 2D Can i upload a picture from in game?

I have a problem.我有个问题。 I'm trying to use unity to help make an AI interface to match children and their parents using a Model i already trained.我正在尝试使用统一来帮助使用我已经训练过的 Model 来匹配孩子及其父母的 AI 界面。 Now all i need to do is make an interface for that.现在我需要做的就是为此创建一个接口。 I'm relativity new to Unity, and C#.我是 Unity 和 C# 的相对论新手。 All i want to do is to upload files from in game and display them.我想做的就是从游戏中上传文件并显示它们。 Is there anyway i can do that?反正我能做到吗? I think it would be like uploading a new material and switching the sprite's material to that, but I'm not sure how to do that in C#.我认为这就像上传新材料并将精灵的材料切换到该材料,但我不确定如何在 C# 中执行此操作。 I tried looking around on the web, but all things i found weren't for in-game stuff.我试着在 web 上环顾四周,但我发现的所有东西都不是游戏中的东西。 Essentially, all i need is a "Choose file" thing similar to HTML.本质上,我需要的只是一个类似于 HTML 的“选择文件”。 Thanks for your help!谢谢你的帮助!

You can do this with the EditorUtility.OpenFilePanel which returns a string that is the path of the file the user selected.您可以使用EditorUtility.OpenFilePanel执行此操作,它返回一个字符串,该字符串是用户选择的文件的路径。 Then you can load the image as a texture, just look at the example in the documentation I linked.然后您可以将图像加载为纹理,只需查看我链接的文档中的示例即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM