Is there a recommendation regarding the 2 compiler warnings below?
warning CS0618: 'UnityEngine.Quaternion.SetEulerAngles(float, float, float)' is obsolete: 'Use Quaternion.Euler instead. This function was deprecated because it uses radians instad of degrees'
warning CS0618: 'UnityEngine.Component.active' is obsolete: '"the active property is deprecated on components. Please use gameObject.active instead. If you meant to enable / disable a single component use enabled instead."'
In C#, there doesn’t seem to be anything called “Euler” as a member of Quaternion. There is a public member called “eulerAngles” but it’s read-only. So how do we get at the recommended “Quaternion.Euler” from C#?
Similarly, there is no property or member called “enabled” exposed from Component (that C# can see). What should we use?
In both cases, we’ve made everything work fine in spite of the warnings, but I never like to live with warnings for any longer than necessary so I would like to find out the right way to do these things.
Yes, I’m very familiar with quaternions and euler angles in general. What I was saying is that from the perspective of C# (which is what is exposed from UnityEngine.dll), there is not a member called “Euler” exposed from the Quaternion class. I assume there is such a thing in Javascript as the docs indicate, but not on the Quaternion .net class that is exposed from UnityEngine.dll.
Ditto for “enabled” on components such as Collider and WheelCollider. There is no public member called “enabled”, only “active”, which is marked as obsolete.
I see that these are in the documentation and assume that they are available from Javascript, but they aren’t from C#. Here is everything that Component exposes:
“Enabled” isn’t there.
Maybe I’m referencing a bad version of UnityEngine.dll? Even so, the obsolete warning refers to it… I think this is the latest from the currently public web player, but I will check…
Everything that is in the Unity API is language-agnostic; nothing is limited to one language or another. It would be kind of absurd for a warning to tell you to use something that you can’t.
Javascript:
var foo = Quaternion.Euler(Vector3.one);
C#:
Quaternion foo = Quaternion.Euler(Vector3.one);
If it’s in the docs, you can use it, so yeah, I expect you do have a bad version of UnityEngine.dll.
WheelCollider collider = component as WheelCollider;
if (collider != null)
collider.enabled = false;
gives:
error CS1061: 'UnityEngine.WheelCollider' does not contain a definition for 'enabled' and no extension method 'enabled' accepting a first argument of type 'UnityEngine.WheelCollider' could be found (are you missing a using directive or an assembly reference?)
However, thanks to your help I did find Euler on the Quaternion class; it’s a static method so that does work exactly as you posted. Thanks for that!
This is not the end of the world because .active seems to do the right thing (at least for this release), but it’s uncomfortable having the warning about using an obsolete property (it might go away on the next release?)