How To Create A Space For Your Unity Environment

#1
by cm107 - opened

Procedure

For anyone else that is trying to do the same thing as me:

  1. Clone
    Unity-WebGL-template-for-Hugging-Face-Spaces
    .
  2. In your Unity Editor, drag 'Hugging Face WebGL Template.unitypackage' into your Assets folder any import everything.
  3. Open your player settings (Edit> Project Settings > Player), and under the WebGL tab, under Resolution and Presentation, select the "Hugging Face" template.
  4. Open your Build Settings, change your platform to WebGL, check Development Build (this might be optional), and then click Build And Run.
  5. If the build went well, your game should open up in your default browser.
  6. Create a new huggingface space using the Static SDK.
  7. Clone your new space to your computer.
  8. cp -r /path/to/build/directory/* /path/to/space/repo/
  9. Since the *.data files in your Build folder are likely too big, you will need to track them with git lfs. git lfs install && git lfs track "*.data"
  10. Commit and push. You might be asked to enter your username and password multiple times for each file that needs to be tracked with lfs.
  11. Go to your space on huggingface and confirm that the app is working.

Notes

  • This should work regardless of whether or not your scene uses ML-Agents.
  • If you do happen to use ML-Agents, (I think) the trained weights that you referenced inside of your scene is included in your build's binary.
  • If you want to switch between models, you would need to implement that logic in your C# code.
  • As for how to use models that were uploaded to huggingface, I have no idea. ThomasSimonini seems to know how to do that, but as far as I know he hasn't published the code that he used to do it.

Sign up or log in to comment