Skip to content

Folcon/arcadia-example-project

Repository files navigation

arcadia-example-project

An example project to help someone kickstart their exploration into Arcadia.

Uses some small adjustments to make it work, these will hopefully be merged in to the main repos of their respected projects:

Getting Started

  1. Clone the project using git clone --recursive https://github.com/Folcon/arcadia-example-project.git your-game-name
    1. Use Unity Hub to add your game folder and open it in Unity.
    2. In Intellij with Cursive, go to File->Open and then open the game folder.
    3. File->Project Structure, select Modules. You might want to rename arcadia-example-project to your game name.
    4. Remove tools.cursive-arcadia-repl from modules then add it and select import, then select the tools.cursive-arcadia-repl folder. Import it as a leiningen project.
    5. Create a new run configuration based on leiningen and name it Start Arcadia REPL. Select tools.cursive-arcadia-repl as the module and then put run into parameters and +dev into profiles.
    6. Create a new run configuration based on the clojure remote repl and name it RREPL. Select tools.cursive-arcadia-repl as the module, nrepl as the connection type and host is localhost with port 7888.
  2. Start Unity and Play the scene.
  3. Boot run configuration Start Arcadia REPL
  4. Boot run configuration RREPL
    1. If you're on windows and are using wsl2 then make sure you have your ports open. A script if you need some help =)... Just add the appropriate ports you want open into it.
  5. Navigate to Assets/game_src/game/core.clj
  6. Use SHIFT-ALT-L or Load File in REPL, accessible from the repl menu by right-clicking and looking for the REPL option. This should display Loading Assets/game_src/game/core.clj...
  7. Bring your cursor to (create-main) within the comment block, specifically it should be where the pipe is:
    (comment
      ;; Make sure you run this while unity is already running.
      ;; For programmatic stuff like this you might not want to modify your scene.
      ;; To be honest it depends on your coding style =)...
      (create-main)|
    
      (hook-main))
  8. Use SHIFT-ALT-P or Send '(create-main)' to REPL, accessible from the repl menu by right-clicking and looking for the REPL option. This should display in your REPL:
    (create-main)
    => #<Main (UnityEngine.GameObject)>
    In Unity you should see a new GameObject called Main in your hierarchy. Selecting it will show it's a simple GameObject.
  9. Do it again with (hook-main) which should display in your REPL:
    (hook-main)
    => #'game-src.game.core/log-name
    In Unity you should see the Main GameObject now has two new components: Arcadia State (Script) and Start Hook (Script), with the Start Hook (Script) containing a reference to :log-name pointing to #'game-src.game.core/log-name, which is indicating which clojure function within what namespace it's pointing to.
  10. Stopping Play within Unity should make the Main GameObject disappear, so you'll need to reload and invoke your code in the repl to create it again.
  11. Setup your project to be exported by adding into Arcadia/configuration.edn. You'll find :export-namespaces commented out, so uncomment it and change it to look like below:
    :export-namespaces [game-src.game.core]
    You can now build your project. I would advise testing this to ensure that it builds, there's nothing worse than making a lot of changes and then realising you can't share your game! Look at the Build Your Game segment for instructions.
  12. Happy Hacking!

Build Your Game

  1. Eval the code below within the game-src.game.core ns while not in play mode! This will hook the main function which is the entry point of your code to the Main Camera:
    (arc/hook+ (arc/object-named "Main Camera") :start :main #'main)
  2. Make sure your :export-namespaces is up-to-date, containing at least game-src.game.core.
  3. Delete the Arcadia/Compiled and Arcadia/Export in your project.
  4. From the Unity menu, select Arcadia -> AOT Compile
  5. From the Unity menu, select Arcadia -> Prepare for Export
  6. From the Unity menu, select File -> Build And Run
  7. You should now see at least a cube, if not your game in all of its glory!

About

An example project to help someone kickstart their exploration into Arcadia

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published