Last active
August 29, 2015 14:08
-
-
Save timsgardner/ea64001779a2221f26cf to your computer and use it in GitHub Desktop.
set-with!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; funny little macro to make interop bit less painful | |
(set! *warn-on-reflection* true) | |
(defmacro set-with! [obj [sym prop] & body] | |
`(let [obj# ~obj | |
~sym (. obj# ~prop)] | |
(set! (. obj# ~prop) (do ~@body)))) | |
;; use: ---------------------------------------- | |
(use 'arcadia.core) | |
(import '[UnityEngine Transform GameObject Vector3]) | |
(defn v+ ^Vector3 [^Vector3 v1 ^Vector3 v2] | |
(Vector3/op_Addition v1 v2)) | |
(defn travel [^GameObject obj] | |
(doto (get-component obj Transform) | |
(set-with! [pos localPosition] | |
(v+ pos (Vector3. 1 2 3))))) | |
(defn travel-weirdly [^GameObject obj] | |
(let [^Transform trns (get-component obj Transform)] | |
(set-with! trns [pos localPosition] | |
(set-with! trns [eua localEulerAngles] | |
(v+ eua pos)) | |
(v+ pos (Vector3. 1 2 3))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment