-
Create a new, blank Unity 2D game, using Unity 5.4.0f3.
-
Unity menu: Edit -> Project Settings -> Player
- Resolution & Presentation -> Run in Background* -> CHECK
- Other Settings -> Api Compatibility Level -> .NET 2.0
-
Clone Arcadia Github into
Assetsdirectory and let Unity load it (be patient) -
cd Assets/Arcadia/Infrastructureand run the./replprogram there, then(require '[arcadia.core :refer :all])- Leave the REPL open for later
-
Drag a (random, small) image into your Unity
Assetspane/window -
Drag that image from the
Assetswindow into theScenepane/window, on top of the camera icon.- Confirm that the
Hierarchypane shows your image (it will be aSpritenow)
- Confirm that the
-
Rename that in the
Hierarchywindow toobject-1 -
Create a new Clojure file in pathname
Assets/minimal/core.cljwith the contents below. -
In the REPL, run this:
(require '[minimal.core :refer :all])to load it into the REPL -
Now the magic happens: We're going to have the function
first-callbackget called every frame by linking (hooking) it to theobject-1object in the scene. This can only be done in the REPL for now, but the hook will show up in the Scene in the inspector. This will, for now, just spam the UnityConsolewindow with boring messages. -
We can access game objects by name using the Arcadia function
objects-named. This returns a list. REPL:user=> (objects-named "object-1")->(#unity/GameObject -22008) -
Add the hook for the function in our
minimal/core.cljfile to the sprite we namedobject-1in the REPL:user=> (hook+ (first (objects-named "object-1")) :update #'minimal.core/first-callback)->#unity/GameObject -22008 -
Confirm this by clicking on
object-1in the UnityHierarchywindow and note in theInspectorthat it saysUpdate Hook (Script)with#'minimal.core/first-callback. -
Make sure the
Consolewindow is showing. ClickPlayicon in Unity. Be patient. After a short time, your first Arcadia app will start running and theConsolewindow will start showing a lot of messages like:Hello, ArcadiafromUnityEngine.Debug:Log(Object). -
Save your scene (whatever name you want). Quit Unity. Restart Unity and load your project. Hit Play. Everything should still work.
(ns minimal.core
(:use arcadia.core arcadia.linear))
(defn first-callback [o]
(arcadia.core/log "Hello, Arcadia"))