- Home /
Question is off-topic or not relevant
Turn on LED Light on iPhone using C#
I attached this method to a button to see if I could turn on the light on an iPhone;
public void LightSwitch()
{
GetComponent<Light>().enabled = true;
}
But it doesn't work. Any ideas?
Answer by tanoshimi · Jul 13, 2015 at 08:27 PM
"Components" in Unity are scripts written in code that determine how (virtual) objects behave in your game world behave. They have nothing to do with the components on your phone.
"Lights" in Unity are one type of component - the (virtual) lights that determine how your (virtual) scene is rendered. They have nothing to do with any (real) bulbs that may light up on your phone. http://docs.unity3d.com/Manual/Lighting.html
However, it is possible to write a component that accesses the (real) light on your phone. You'll have to write an Obj-C plugin and then interface to that from a C# component. Or, you could investigate a pre-written asset such as this: https://www.assetstore.unity3d.com/en/#!/content/4704
Thanks. That explains why I wasn't getting any error messages.
That Torch Plug-in in Unity5 generates build errors: [ARC Restrictions]
Answer by zastrow · Jul 13, 2015 at 10:22 PM
To solve build errors: [ARC Restrictions] //Add Flag -fno-objc-arc in Xcode / Build Phases / Compile Sources / iOSTorch.mm
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to prevent world interaction when using UI elements? 1 Answer
How can I find intersection points between a circle and Colliders 2D ? 0 Answers
Rotate a camera when my flashlight is on the edge of the screen... Video included 2 Answers