Closed nasser closed 5 years ago
but this works
(lookup (instantiate (Resources/Load "testo")) :test) ;; <== not nil
(state (instantiate (Resources/Load "testo"))) ;; <== not nil
with this setup:
(ns arcadia-issues.issue-355
(:require [arcadia.core :as ac])
(:import [UnityEngine GameObject Resources]))
(ac/defmutable TubePosition [^float x ^float y])
(comment
(let [go (GameObject. "issue-355")]
(ac/state+ go :test (->TubePosition 0 0))))
;; then you have to save it as a prefab called "issue-355". subsequently, from the repl:
(defn run-issue []
{:test-lookup (ac/lookup (ac/instantiate (Resources/Load "issue-355")) :test)
:test-state (ac/state (ac/instantiate (Resources/Load "issue-355")) :test)})
It works for me:
arcadia-issues.issue-355=> (run-issue)
nil
arcadia-issues.issue-355=> arcadia-issues.issue-355=> {:test-lookup #arcadia.data/data{:arcadia.data/type arcadia_issues.issue_355.TubePosition, :x 0.0, :y 0.0}, :test-state {:x 0.0, :y 0.0, :arcadia.core/mutable-type arcadia_issues.issue_355.TubePosition}}
nm, I'm an idiot, bad reproduction. Here's the corrected code, which does reproduce the issue:
(ns arcadia-issues.issue-355
(:require [arcadia.core :as ac])
(:import [UnityEngine GameObject Resources]))
(ac/defmutable-once TubePosition [^float x ^float y])
(comment
(let [go (GameObject. "issue-355")]
(ac/state+ go :test (->TubePosition 0 0))))
;; then you have to save it as a prefab called "issue-355". subsequently, from the repl:
(defn run-issue-without-instantiate []
{:test-lookup (ac/lookup (Resources/Load "issue-355") :test)
:test-state (ac/state (Resources/Load "issue-355") :test)})
(defn run-issue-with-instantiate []
{:test-lookup (ac/lookup (ac/instantiate (Resources/Load "issue-355")) :test)
:test-state (ac/state (ac/instantiate (Resources/Load "issue-355")) :test)})
Correct Unity usage is to instantiate prefabs before using them. Closing.