-
Notifications
You must be signed in to change notification settings - Fork 108
Arcadia Hello World
NOTE Until our documentation settles down, USAGE.md is a better source of up to date information
-
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
Assets
directory and let Unity load it (be patient) -
cd Assets/Arcadia/Infrastructure
and run the./repl
program there, then(require '[arcadia.core :refer :all])
- Leave the REPL open for later
-
Drag a (random, small) image into your Unity
Assets
pane/window -
Drag that image from the
Assets
window into theScene
pane/window, on top of the camera icon.- Confirm that the
Hierarchy
pane shows your image (it will be aSprite
now)
- Confirm that the
-
Rename that in the
Hierarchy
window toobject-1
-
Create a new Clojure file in pathname
Assets/minimal/core.clj
with 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-callback
get called every frame by linking (hooking) it to theobject-1
object 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 UnityConsole
window 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.clj
file to the sprite we namedobject-1
in the REPL:user=> (hook+ (first (objects-named "object-1")) :update #'minimal.core/first-callback)
->#unity/GameObject -22008
-
Confirm this by clicking on
object-1
in the UnityHierarchy
window and note in theInspector
that it saysUpdate Hook (Script)
with#'minimal.core/first-callback
. -
Make sure the
Console
window is showing. ClickPlay
icon in Unity. Be patient. After a short time, your first Arcadia app will start running and theConsole
window will start showing a lot of messages like:Hello, Arcadia
fromUnityEngine.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"))