Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Touch controls on Android not functioning when built properly #248

Closed
IGJoshua opened this issue Aug 22, 2017 · 3 comments
Closed

Touch controls on Android not functioning when built properly #248

IGJoshua opened this issue Aug 22, 2017 · 3 comments
Milestone

Comments

@IGJoshua
Copy link

Android touch controls don't function seemingly at all when used in a finished apk.

To reproduce:
Single scene in the build settings, containing a camera with an ortho view and a near clipping plane of 0, and a single sprite with the following hook on update:

(defn box-hook
  [this]
  (when (> (count Input/touches) 0)
    (set! (.position (.transform this)) (.ScreenToWorldPoint
                                         Camera/main
                                         (let [pos (.position (first Input/touches))]
                                           (Vector3. (.x pos) (.y pos) 0))))))

Building is done while connected to the device in developer mode after ensuring the android build post-process does not occur in arcadia, and the following code is run in the repl:

(use 'arcadia.compiler)
(aot-namespaces "Assets/Compiled" '[clojure.core game.core])

The resulting .apk should be send to the android device just fine, and run as well, but any touch controls will not function.

NOTE: The above setup works perfectly when using unity remote, touch controls are received properly and can be manipulated any way desired.

@timsgardner timsgardner added this to the Beta Release milestone Oct 1, 2018
@nasser
Copy link
Contributor

nasser commented Dec 7, 2018

Not sure if this is an android specific issue. It might be related to #323 which we have confirmed is happening. Its likely that hooks are being dropped before export as well, resulting in scenes with no clojure code in the exported game.

I tested first on the desktop with

(ns issue-248
  (:import [UnityEngine Input Vector3 Camera])
  (:use arcadia.core))

(defn box-hook-mouse [this k]
  (set!
    (.position (.transform this))
    (.ScreenToWorldPoint Camera/main
                         (let [pos Input/mousePosition]
                           (Vector3. (.x pos) (.y pos) 10)))))

with box-hook-mouse attached to a cube via

(hook+ (object-named "Cube") :update :issue-248 #'box-hook-mouse)

It replicates the posted code above but uses a mouse as input. The game builds, launches and runs without error, and the hooks disappear in the inspector.

On Android I tested with

(ns issue-248
  (:import [UnityEngine Input Vector3 Camera])
  (:use arcadia.core))

(defn box-hook [this k]
  (when (> (count Input/touches) 0)
    (set!
      (.position (.transform this))
      (.ScreenToWorldPoint Camera/main
                           (let [pos (.position (first Input/touches))]
                             (Vector3. (.x pos) (.y pos) 10))))))

with a similar setup as on desktop. Again, everything built and ran without errors, and adb logcat was clean.

@nasser
Copy link
Contributor

nasser commented Dec 8, 2018

This is actually looking like a compiler bug. With #323 fixed, running the above code on Android throws the following in adb logcat

2018-12-07 17:29:26.237 1278-1300/? E/Unity: ArgumentException: The specified path is not of a legal form (empty).
      at System.IO.Path.InsecureGetFullPath (System.String path) [0x00025] in <f2e6809acb14476a81f399aeb800f8f2>:0 
      at System.IO.Path.GetFullPath (System.String path) [0x00000] in <f2e6809acb14476a81f399aeb800f8f2>:0 
      at System.AppDomainSetup.GetAppBase (System.String appBase) [0x00041] in <f2e6809acb14476a81f399aeb800f8f2>:0 
      at System.AppDomainSetup.get_ApplicationBase () [0x00000] in <f2e6809acb14476a81f399aeb800f8f2>:0 
      at System.AppDomain.get_BaseDirectory () [0x00006] in <f2e6809acb14476a81f399aeb800f8f2>:0 
        at (wrapper remoting-invoke-with-check) System.AppDomain.get_BaseDirectory()
      at clojure.lang.RT+<GetFindFilePathsRaw>d__424.MoveNext () [0x00038] in <138b9d0b0b3f4982b42abdb2b77eda11>:0 
      at System.Linq.Enumerable+DistinctIterator`1[TSource].MoveNext () [0x00028] in <10ab7516b28e47f29e5315b70b0be54c>:0 
      at clojure.lang.RT.FindFile (System.String fileName) [0x00021] in <138b9d0b0b3f4982b42abdb2b77eda11>:0 
      at clojure.

The full thing is here

@nasser
Copy link
Contributor

nasser commented Dec 11, 2018

As of 0689ff6 the android code I posted above exports and functions as expected

@nasser nasser closed this as completed Dec 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants