Search Unity

ProximitySensor & LightSensor get value?

Discussion in 'Input System' started by Muckel, Jan 21, 2020.

  1. Muckel

    Muckel

    Joined:
    Mar 26, 2009
    Posts:
    471
    hello,
    i'll try to figure out how to get a value from one of these sensors...

    Code (CSharp):
    1. void OnEnable () {
    2.         InputSystem.EnableDevice (ProximitySensor.current);
    3.         InputSystem.EnableDevice (LightSensor.current);
    4.     }
    5.  
    6.     void OnDisable () {
    7.         InputSystem.DisableDevice (ProximitySensor.current);
    8.         InputSystem.DisableDevice (LightSensor.current);
    9.     }
    10.  
    11.     void Update () {
    12.         var _ProximitySensor = ProximitySensor.current;
    13.         var _dist = _ProximitySensor.distance;
    14.         _myTxt.text = "Proxy: " + _dist;
    15.  
    16.     }
    any help is really appreciated...
    many thx
    M.
     
    Last edited: Jan 21, 2020
  2. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    What's the platform you're on? When you connect to the device in the input debugger (Window >> Analysis >> Input Debugger; Remote Devices), do the sensors show in the list of devices for the player?

    If the devices are present in the player and enabling them has no effect and there's no input on them even though there should be, could be a bug. In that case, please file a ticket through the Unity bug reporter.
     
    Muckel likes this.
  3. Muckel

    Muckel

    Joined:
    Mar 26, 2009
    Posts:
    471
    i'm on Mac and got it figured out....
    well don't understand why the Unity Dev's always support Android more than iOS????
    can someone tell me why the ProximitySensor and many others still don't work on iOS ???
    i really don't like the arrogance of some unity dev's... time again to kick them out!
    we pay you to do your job and not to push the people in some direction you always do...
    like the VR rush... and what's up now with it... not much...
    the problem is not to move on new Technologies...
    but if your base is S***ty like it still is ... why not first fix the base and make it work?
    instead of putting all the work in those features that only 5% uses of the Unity user base...
    since Unity lost some important persons... the ship is struggling...
    i know the company from beginning where it was Mac OS X only ... that where better times as now!
    meanwhile i'll switching to other tools to get my job's done...

    Each sensor Device implements a single Control which represents the data read by the sensor. The following sensors are available:

    Android all YES
    Ios only the first five.... WHAT A JOKE!!!

    Device Android iOS Control Type
    Accelerometer Yes Yes acceleration Vector3Control
    Gyroscope Yes Yes angularVelocity Vector3Control
    GravitySensor Yes Yes gravity Vector3Control
    AttitudeSensor Yes Yes attitude QuaternionControl
    LinearAccelerationSensor Yes Yes acceleration Vector3Control
    MagneticFieldSensor Yes No magneticField Vector3Control
    LightSensor Yes No lightLevel AxisControl
    PressureSensor Yes No atmosphericPressure AxisControl
    ProximitySensor Yes No distance AxisControl
    HumiditySensor Yes No relativeHumidity AxisControl
    AmbientTemperatureSensor Yes No ambientTemperature AxisControl
    StepCounter Yes No stepCounter IntegerControl

    https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Sensors.html

    it's a joke to me... these sensors are easy to access on iOS from unity...
    but ignorance still hold them back to support this :-(

    also the new input system is not working well on mobile....
    if you use this for example on a UI btn...
    it doesn't work after one time use...

    if (Keyboard.current[Space.key].wasPressedThisFrame) in Preview 3... did u fix it now?
    do you also do testing this input system on different devices eg iOS
    or do you still only test on Android???

    will provide soon a sample project with all those things that don't work...
    but i'm not happy to make your work... it takes much time and resources to fill your bug's...
    and you never get feedback... i'll never got... no thx and often no fix for my bug's i've reported...
    you can look in my history what i've reported...

    it's too funny now ... we should pay for Unity3d and than also spend time and money to report bug's and test...
    what are you doing @ Unity ???
    and for what you you get payed for?
    what's up with the new input system...
    it's so long now in testing and still has so many open bug's
    it's time again that Unity concentrates on the people who pay them and not those who cry loudest!

    are there any plans to support all sensors on iOS???
    if not... it's again a argument against Unity...
    why not than Windows and Andoid only???
    it's far away from true cross-platform tool...

    the original spirt and philosophy is long gone @ Unity3d HQ
    it's all about making money now... sad to see but i've told that Joachim and David when they sold Unity
    and also when Unity switched to support Windows...
    now i'll see that i was true and all was coming like i'll said in my email i've sent them...

    sad but true
    M.
     
  4. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    No bigger picture here. Back when this was implemented, the main focus was feature parity with the old system and this happened to be all it had. The Android implementation simply pulled ahead because the API on Android is designed in a way where the same code path can support all kinds of sensors instead of needing specific support for each type of sensor.

    Added a ticket to remedy this (ISX-332) and add the missing code paths for iOS.
     
  5. PayPaull

    PayPaull

    Joined:
    Nov 2, 2016
    Posts:
    2
    Has there been any progress in being able to use these sensors for IOS? I'm working on a project that's quite dependent on the proximity sensor
     
  6. merrythieves

    merrythieves

    Joined:
    Apr 28, 2021
    Posts:
    14
    Unfortunately you can't actually use the ambient light sensor on iOS or your app will be rejected and there is no easy way to access in Unity.

    I wrote a plugin that will give you this functionality, though. It uses the front-facing camera and read each frame to find brightness. It worked for my use case. I made it available on the asset store: iOS Ambient Light Sensor | Utilities Tools | Unity Asset Store