Unity 代码 学习
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
A:
B:
using System; using System.Runtime.CompilerServices; using UnityEngine.Scripting; namespace UnityEngine { /// <summary> /// <para>Behaviours are Components that can be enabled or disabled.</para> /// </summary> [UsedByNativeCode] public class Behaviour : Component { /// <summary> /// <para>Enabled Behaviours are Updated, disabled Behaviours are not.</para> /// </summary> public extern bool enabled { [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] get; [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] set; } /// <summary> /// <para>Has the Behaviour had enabled called.</para> /// </summary> public extern bool isActiveAndEnabled { [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] get; } } }
Behaviour
C:
using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Security; using UnityEngine.Internal; using UnityEngine.Scripting; using UnityEngineInternal; namespace UnityEngine { /// <summary> /// <para>Base class for everything attached to GameObjects.</para> /// </summary> [RequiredByNativeCode] public class Component : Object { /// <summary> /// <para>The Transform attached to this GameObject.</para> /// </summary> public extern Transform transform { [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] get; } /// <summary> /// <para>The game object this component is attached to. A component is always attached to a game object.</para> /// </summary> public extern GameObject gameObject { [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] get; } /// <summary> /// <para>The tag of this game object.</para> /// </summary> public string tag { get { return this.gameObject.tag; } set { this.gameObject.tag = value; } } /// <summary> /// <para>The Rigidbody attached to this GameObject. (Null if there is none attached).</para> /// </summary> [Obsolete("Property rigidbody has been deprecated. Use GetComponent<Rigidbody>() instead. (UnityUpgradable)", true)] public Component rigidbody { get { throw new NotSupportedException("rigidbody property has been deprecated"); } } /// <summary> /// <para>The Rigidbody2D that is attached to the Component's GameObject.</para> /// </summary> [Obsolete("Property rigidbody2D has been deprecated. Use GetComponent<Rigidbody2D>() instead. (UnityUpgradable)", true)] public Component rigidbody2D { get { throw new NotSupportedException("rigidbody2D property has been deprecated"); } } /// <summary> /// <para>The Camera attached to this GameObject. (Null if there is none attached).</para> /// </summary> [Obsolete("Property camera has been deprecated. Use GetComponent<Camera>() instead. (UnityUpgradable)", true)] public Component camera { get { throw new NotSupportedException("camera property has been deprecated"); } } /// <summary> /// <para>The Light attached to this GameObject. (Null if there is none attached).</para> /// </summary> [Obsolete("Property light has been deprecated. Use GetComponent<Light>() instead. (UnityUpgradable)", true)] public Component light { get { throw new NotSupportedException("light property has been deprecated"); } } /// <summary> /// <para>The Animation attached to this GameObject. (Null if there is none attached).</para> /// </summary> [Obsolete("Property animation has been deprecated. Use GetComponent<Animation>() instead. (UnityUpgradable)", true)] public Component animation { get { throw new NotSupportedException("animation property has been deprecated"); } } /// <summary> /// <para>The ConstantForce attached to this GameObject. (Null if there is none attached).</para> /// </summary> [Obsolete("Property constantForce has been deprecated. Use GetComponent<ConstantForce>() instead. (UnityUpgradable)", true)] public Component constantForce { get { throw new NotSupportedException("constantForce property has been deprecated"); } } /// <summary> /// <para>The Renderer attached to this GameObject. (Null if there is none attached).</para> /// </summary> [Obsolete("Property renderer has been deprecated. Use GetComponent<Renderer>() instead. (UnityUpgradable)", true)] public Component renderer { get { throw new NotSupportedException("renderer property has been deprecated"); } } /// <summary> /// <para>The AudioSource attached to this GameObject. (Null if there is none attached).</para> /// </summary> [Obsolete("Property audio has been deprecated. Use GetComponent<AudioSource>() instead. (UnityUpgradable)", true)] public Component audio { get { throw new NotSupportedException("audio property has been deprecated"); } } /// <summary> /// <para>The GUIText attached to this GameObject. (Null if there is none attached).</para> /// </summary> [Obsolete("Property guiText has been deprecated. Use GetComponent<GUIText>() instead. (UnityUpgradable)", true)] public Component guiText { get { throw new NotSupportedException("guiText property has been deprecated"); } } /// <summary> /// <para>The NetworkView attached to this GameObject (Read Only). (null if there is none attached).</para> /// </summary> [Obsolete("Property networkView has been deprecated. Use GetComponent<NetworkView>() instead. (UnityUpgradable)", true)] public Component networkView { get { throw new NotSupportedException("networkView property has been deprecated"); } } [Obsolete("Property guiElement has been deprecated. Use GetComponent<GUIElement>() instead. (UnityUpgradable)", true)] public Component guiElement { get { throw new NotSupportedException("guiElement property has been deprecated"); } } /// <summary> /// <para>The GUITexture attached to this GameObject (Read Only). (null if there is none attached).</para> /// </summary> [Obsolete("Property guiTexture has been deprecated. Use GetComponent<GUITexture>() instead. (UnityUpgradable)", true)] public Component guiTexture { get { throw new NotSupportedException("guiTexture property has been deprecated"); } } /// <summary> /// <para>The Collider attached to this GameObject. (Null if there is none attached).</para> /// </summary> [Obsolete("Property collider has been deprecated. Use GetComponent<Collider>() instead. (UnityUpgradable)", true)] public Component collider { get { throw new NotSupportedException("collider property has been deprecated"); } } /// <summary> /// <para>The Collider2D component attached to the object.</para> /// </summary> [Obsolete("Property collider2D has been deprecated. Use GetComponent<Collider2D>() instead. (UnityUpgradable)", true)] public Component collider2D { get { throw new NotSupportedException("collider2D property has been deprecated"); } } /// <summary> /// <para>The HingeJoint attached to this GameObject. (Null if there is none attached).</para> /// </summary> [Obsolete("Property hingeJoint has been deprecated. Use GetComponent<HingeJoint>() instead. (UnityUpgradable)", true)] public Component hingeJoint { get { throw new NotSupportedException("hingeJoint property has been deprecated"); } } /// <summary> /// <para>The ParticleEmitter attached to this GameObject. (Null if there is none attached).</para> /// </summary> [Obsolete("Property particleEmitter has been deprecated. Use GetComponent<ParticleEmitter>() instead. (UnityUpgradable)", true)] public Component particleEmitter { get { throw new NotSupportedException("particleEmitter property has been deprecated"); } } /// <summary> /// <para>The ParticleSystem attached to this GameObject. (Null if there is none attached).</para> /// </summary> [Obsolete("Property particleSystem has been deprecated. Use GetComponent<ParticleSystem>() instead. (UnityUpgradable)", true)] public Component particleSystem { get { throw new NotSupportedException("particleSystem property has been deprecated"); } } /// <summary> /// <para>Returns the component of Type type if the game object has one attached, null if it doesn't.</para> /// </summary> /// <param name="type">The type of Component to retrieve.</param> [TypeInferenceRule(TypeInferenceRules.TypeReferencedByFirstArgument)] public Component GetComponent(Type type) { return this.gameObject.GetComponent(type); } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] internal extern void GetComponentFastPath(Type type, IntPtr oneFurtherThanResultValue); [SecuritySafeCritical] public unsafe T GetComponent<T>() { CastHelper<T> castHelper = default(CastHelper<T>); this.GetComponentFastPath(typeof(T), new IntPtr((void*)(&castHelper.onePointerFurtherThanT))); return castHelper.t; } /// <summary> /// <para>Returns the component with name type if the game object has one attached, null if it doesn't.</para> /// </summary> /// <param name="type"></param> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public extern Component GetComponent(string type); [TypeInferenceRule(TypeInferenceRules.TypeReferencedByFirstArgument)] public Component GetComponentInChildren(Type t, bool includeInactive) { return this.gameObject.GetComponentInChildren(t, includeInactive); } /// <summary> /// <para>Returns the component of Type type in the GameObject or any of its children using depth first search.</para> /// </summary> /// <param name="t">The type of Component to retrieve.</param> /// <returns> /// <para>A component of the matching type, if found.</para> /// </returns> [TypeInferenceRule(TypeInferenceRules.TypeReferencedByFirstArgument)] public Component GetComponentInChildren(Type t) { return this.GetComponentInChildren(t, false); } [ExcludeFromDocs] public T GetComponentInChildren<T>() { bool includeInactive = false; return this.GetComponentInChildren<T>(includeInactive); } public T GetComponentInChildren<T>([DefaultValue("false")] bool includeInactive) { return (T)((object)this.GetComponentInChildren(typeof(T), includeInactive)); } /// <summary> /// <para>Returns all components of Type type in the GameObject or any of its children.</para> /// </summary> /// <param name="t">The type of Component to retrieve.</param> /// <param name="includeInactive">Should Components on inactive GameObjects be included in the found set?</param> [ExcludeFromDocs] public Component[] GetComponentsInChildren(Type t) { bool includeInactive = false; return this.GetComponentsInChildren(t, includeInactive); } /// <summary> /// <para>Returns all components of Type type in the GameObject or any of its children.</para> /// </summary> /// <param name="t">The type of Component to retrieve.</param> /// <param name="includeInactive">Should Components on inactive GameObjects be included in the found set?</param> public Component[] GetComponentsInChildren(Type t, [DefaultValue("false")] bool includeInactive) { return this.gameObject.GetComponentsInChildren(t, includeInactive); } public T[] GetComponentsInChildren<T>(bool includeInactive) { return this.gameObject.GetComponentsInChildren<T>(includeInactive); } public void GetComponentsInChildren<T>(bool includeInactive, List<T> result) { this.gameObject.GetComponentsInChildren<T>(includeInactive, result); } public T[] GetComponentsInChildren<T>() { return this.GetComponentsInChildren<T>(false); } public void GetComponentsInChildren<T>(List<T> results) { this.GetComponentsInChildren<T>(false, results); } /// <summary> /// <para>Returns the component of Type type in the GameObject or any of its parents.</para> /// </summary> /// <param name="t">The type of Component to retrieve.</param> /// <returns> /// <para>A component of the matching type, if found.</para> /// </returns> [TypeInferenceRule(TypeInferenceRules.TypeReferencedByFirstArgument)] public Component GetComponentInParent(Type t) { return this.gameObject.GetComponentInParent(t); } public T GetComponentInParent<T>() { return (T)((object)this.GetComponentInParent(typeof(T))); } [ExcludeFromDocs] public Component[] GetComponentsInParent(Type t) { bool includeInactive = false; return this.GetComponentsInParent(t, includeInactive); } /// <summary> /// <para>Returns all components of Type type in the GameObject or any of its parents.</para> /// </summary> /// <param name="t">The type of Component to retrieve.</param> /// <param name="includeInactive">Should inactive Components be included in the found set?</param> public Component[] GetComponentsInParent(Type t, [DefaultValue("false")] bool includeInactive) { return this.gameObject.GetComponentsInParent(t, includeInactive); } public T[] GetComponentsInParent<T>(bool includeInactive) { return this.gameObject.GetComponentsInParent<T>(includeInactive); } public void GetComponentsInParent<T>(bool includeInactive, List<T> results) { this.gameObject.GetComponentsInParent<T>(includeInactive, results); } public T[] GetComponentsInParent<T>() { return this.GetComponentsInParent<T>(false); } /// <summary> /// <para>Returns all components of Type type in the GameObject.</para> /// </summary> /// <param name="type">The type of Component to retrieve.</param> public Component[] GetComponents(Type type) { return this.gameObject.GetComponents(type); } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private extern void GetComponentsForListInternal(Type searchType, object resultList); public void GetComponents(Type type, List<Component> results) { this.GetComponentsForListInternal(type, results); } public void GetComponents<T>(List<T> results) { this.GetComponentsForListInternal(typeof(T), results); } public T[] GetComponents<T>() { return this.gameObject.GetComponents<T>(); } /// <summary> /// <para>Is this game object tagged with tag ?</para> /// </summary> /// <param name="tag">The tag to compare.</param> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public extern bool CompareTag(string tag); /// <summary> /// <para>Calls the method named methodName on every MonoBehaviour in this game object and on every ancestor of the behaviour.</para> /// </summary> /// <param name="methodName">Name of method to call.</param> /// <param name="value">Optional parameter value for the method.</param> /// <param name="options">Should an error be raised if the method does not exist on the target object?</param> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public extern void SendMessageUpwards(string methodName, [DefaultValue("null")] object value, [DefaultValue("SendMessageOptions.RequireReceiver")] SendMessageOptions options); /// <summary> /// <para>Calls the method named methodName on every MonoBehaviour in this game object and on every ancestor of the behaviour.</para> /// </summary> /// <param name="methodName">Name of method to call.</param> /// <param name="value">Optional parameter value for the method.</param> /// <param name="options">Should an error be raised if the method does not exist on the target object?</param> [ExcludeFromDocs] public void SendMessageUpwards(string methodName, object value) { SendMessageOptions options = SendMessageOptions.RequireReceiver; this.SendMessageUpwards(methodName, value, options); } /// <summary> /// <para>Calls the method named methodName on every MonoBehaviour in this game object and on every ancestor of the behaviour.</para> /// </summary> /// <param name="methodName">Name of method to call.</param> /// <param name="value">Optional parameter value for the method.</param> /// <param name="options">Should an error be raised if the method does not exist on the target object?</param> [ExcludeFromDocs] public void SendMessageUpwards(string methodName) { SendMessageOptions options = SendMessageOptions.RequireReceiver; object value = null; this.SendMessageUpwards(methodName, value, options); } /// <summary> /// <para>Calls the method named methodName on every MonoBehaviour in this game object and on every ancestor of the behaviour.</para> /// </summary> /// <param name="methodName">Name of method to call.</param> /// <param name="value">Optional parameter value for the method.</param> /// <param name="options">Should an error be raised if the method does not exist on the target object?</param> public void SendMessageUpwards(string methodName, SendMessageOptions options) { this.SendMessageUpwards(methodName, null, options); } /// <summary> /// <para>Calls the method named methodName on every MonoBehaviour in this game object.</para> /// </summary> /// <param name="methodName">Name of the method to call.</param> /// <param name="value">Optional parameter for the method.</param> /// <param name="options">Should an error be raised if the target object doesn't implement the method for the message?</param> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public extern void SendMessage(string methodName, [DefaultValue("null")] object value, [DefaultValue("SendMessageOptions.RequireReceiver")] SendMessageOptions options); /// <summary> /// <para>Calls the method named methodName on every MonoBehaviour in this game object.</para> /// </summary> /// <param name="methodName">Name of the method to call.</param> /// <param name="value">Optional parameter for the method.</param> /// <param name="options">Should an error be raised if the target object doesn't implement the method for the message?</param> [ExcludeFromDocs] public void SendMessage(string methodName, object value) { SendMessageOptions options = SendMessageOptions.RequireReceiver; this.SendMessage(methodName, value, options); } /// <summary> /// <para>Calls the method named methodName on every MonoBehaviour in this game object.</para> /// </summary> /// <param name="methodName">Name of the method to call.</param> /// <param name="value">Optional parameter for the method.</param> /// <param name="options">Should an error be raised if the target object doesn't implement the method for the message?</param> [ExcludeFromDocs] public void SendMessage(string methodName) { SendMessageOptions options = SendMessageOptions.RequireReceiver; object value = null; this.SendMessage(methodName, value, options); } /// <summary> /// <para>Calls the method named methodName on every MonoBehaviour in this game object.</para> /// </summary> /// <param name="methodName">Name of the method to call.</param> /// <param name="value">Optional parameter for the method.</param> /// <param name="options">Should an error be raised if the target object doesn't implement the method for the message?</param> public void SendMessage(string methodName, SendMessageOptions options) { this.SendMessage(methodName, null, options); } /// <summary> /// <para>Calls the method named methodName on every MonoBehaviour in this game object or any of its children.</para> /// </summary> /// <param name="methodName">Name of the method to call.</param> /// <param name="parameter">Optional parameter to pass to the method (can be any value).</param> /// <param name="options">Should an error be raised if the method does not exist for a given target object?</param> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public extern void BroadcastMessage(string methodName, [DefaultValue("null")] object parameter, [DefaultValue("SendMessageOptions.RequireReceiver")] SendMessageOptions options); /// <summary> /// <para>Calls the method named methodName on every MonoBehaviour in this game object or any of its children.</para> /// </summary> /// <param name="methodName">Name of the method to call.</param> /// <param name="parameter">Optional parameter to pass to the method (can be any value).</param> /// <param name="options">Should an error be raised if the method does not exist for a given target object?</param> [ExcludeFromDocs] public void BroadcastMessage(string methodName, object parameter) { SendMessageOptions options = SendMessageOptions.RequireReceiver; this.BroadcastMessage(methodName, parameter, options); } /// <summary> /// <para>Calls the method named methodName on every MonoBehaviour in this game object or any of its children.</para> /// </summary> /// <param name="methodName">Name of the method to call.</param> /// <param name="parameter">Optional parameter to pass to the method (can be any value).</param> /// <param name="options">Should an error be raised if the method does not exist for a given target object?</param> [ExcludeFromDocs] public void BroadcastMessage(string methodName) { SendMessageOptions options = SendMessageOptions.RequireReceiver; object parameter = null; this.BroadcastMessage(methodName, parameter, options); } /// <summary> /// <para>Calls the method named methodName on every MonoBehaviour in this game object or any of its children.</para> /// </summary> /// <param name="methodName">Name of the method to call.</param> /// <param name="parameter">Optional parameter to pass to the method (can be any value).</param> /// <param name="options">Should an error be raised if the method does not exist for a given target object?</param> public void BroadcastMessage(string methodName, SendMessageOptions options) { this.BroadcastMessage(methodName, null, options); } } }
Component
D:
E:
F:
G:
H:
I:
J:
K:
L:
M:
using System; using System.Runtime.CompilerServices; using UnityEngine.Internal; using UnityEngine.Scripting; using UnityEngineInternal; namespace UnityEngine { /// <summary> /// <para>A collection of common math functions.</para> /// </summary> public struct Mathf { /// <summary> /// <para>The infamous 3.14159265358979... value (Read Only).</para> /// </summary> public const float PI = 3.14159274f; /// <summary> /// <para>A representation of positive infinity (Read Only).</para> /// </summary> public const float Infinity = float.PositiveInfinity; /// <summary> /// <para>A representation of negative infinity (Read Only).</para> /// </summary> public const float NegativeInfinity = float.NegativeInfinity; /// <summary> /// <para>Degrees-to-radians conversion constant (Read Only).</para> /// </summary> public const float Deg2Rad = 0.0174532924f; /// <summary> /// <para>Radians-to-degrees conversion constant (Read Only).</para> /// </summary> public const float Rad2Deg = 57.29578f; /// <summary> /// <para>A tiny floating point value (Read Only).</para> /// </summary> public static readonly float Epsilon = (!MathfInternal.IsFlushToZeroEnabled) ? MathfInternal.FloatMinDenormal : MathfInternal.FloatMinNormal; /// <summary> /// <para>Returns the closest power of two value.</para> /// </summary> /// <param name="value"></param> [GeneratedByOldBindingsGenerator, ThreadAndSerializationSafe] [MethodImpl(MethodImplOptions.InternalCall)] public static extern int ClosestPowerOfTwo(int value); /// <summary> /// <para>Converts the given value from gamma (sRGB) to linear color space.</para> /// </summary> /// <param name="value"></param> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public static extern float GammaToLinearSpace(float value); /// <summary> /// <para>Converts the given value from linear to gamma (sRGB) color space.</para> /// </summary> /// <param name="value"></param> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public static extern float LinearToGammaSpace(float value); /// <summary> /// <para>Convert a color temperature in Kelvin to RGB color.</para> /// </summary> /// <param name="kelvin">Temperature in Kelvin. Range 1000 to 40000 Kelvin.</param> /// <returns> /// <para>Correlated Color Temperature as floating point RGB color.</para> /// </returns> public static Color CorrelatedColorTemperatureToRGB(float kelvin) { Color result; Mathf.INTERNAL_CALL_CorrelatedColorTemperatureToRGB(kelvin, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_CorrelatedColorTemperatureToRGB(float kelvin, out Color value); /// <summary> /// <para>Returns true if the value is power of two.</para> /// </summary> /// <param name="value"></param> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public static extern bool IsPowerOfTwo(int value); /// <summary> /// <para>Returns the next power of two value.</para> /// </summary> /// <param name="value"></param> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public static extern int NextPowerOfTwo(int value); /// <summary> /// <para>Generate 2D Perlin noise.</para> /// </summary> /// <param name="x">X-coordinate of sample point.</param> /// <param name="y">Y-coordinate of sample point.</param> /// <returns> /// <para>Value between 0.0 and 1.0.</para> /// </returns> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public static extern float PerlinNoise(float x, float y); [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public static extern ushort FloatToHalf(float val); [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public static extern float HalfToFloat(ushort val); /// <summary> /// <para>Returns the sine of angle f in radians.</para> /// </summary> /// <param name="f">The argument as a radian.</param> /// <returns> /// <para>The return value between -1 and +1.</para> /// </returns> public static float Sin(float f) { return (float)Math.Sin((double)f); } /// <summary> /// <para>Returns the cosine of angle f in radians.</para> /// </summary> /// <param name="f"></param> public static float Cos(float f) { return (float)Math.Cos((double)f); } /// <summary> /// <para>Returns the tangent of angle f in radians.</para> /// </summary> /// <param name="f"></param> public static float Tan(float f) { return (float)Math.Tan((double)f); } /// <summary> /// <para>Returns the arc-sine of f - the angle in radians whose sine is f.</para> /// </summary> /// <param name="f"></param> public static float Asin(float f) { return (float)Math.Asin((double)f); } /// <summary> /// <para>Returns the arc-cosine of f - the angle in radians whose cosine is f.</para> /// </summary> /// <param name="f"></param> public static float Acos(float f) { return (float)Math.Acos((double)f); } /// <summary> /// <para>Returns the arc-tangent of f - the angle in radians whose tangent is f.</para> /// </summary> /// <param name="f"></param> public static float Atan(float f) { return (float)Math.Atan((double)f); } /// <summary> /// <para>Returns the angle in radians whose Tan is y/x.</para> /// </summary> /// <param name="y"></param> /// <param name="x"></param> public static float Atan2(float y, float x) { return (float)Math.Atan2((double)y, (double)x); } /// <summary> /// <para>Returns square root of f.</para> /// </summary> /// <param name="f"></param> public static float Sqrt(float f) { return (float)Math.Sqrt((double)f); } /// <summary> /// <para>Returns the absolute value of f.</para> /// </summary> /// <param name="f"></param> public static float Abs(float f) { return Math.Abs(f); } /// <summary> /// <para>Returns the absolute value of value.</para> /// </summary> /// <param name="value"></param> public static int Abs(int value) { return Math.Abs(value); } /// <summary> /// <para>Returns the smallest of two or more values.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="values"></param> public static float Min(float a, float b) { return (a >= b) ? b : a; } /// <summary> /// <para>Returns the smallest of two or more values.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="values"></param> public static float Min(params float[] values) { int num = values.Length; float result; ) { result = 0f; } else { ]; ; i < num; i++) { if (values[i] < num2) { num2 = values[i]; } } result = num2; } return result; } /// <summary> /// <para>Returns the smallest of two or more values.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="values"></param> public static int Min(int a, int b) { return (a >= b) ? b : a; } /// <summary> /// <para>Returns the smallest of two or more values.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="values"></param> public static int Min(params int[] values) { int num = values.Length; int result; ) { result = ; } else { ]; ; i < num; i++) { if (values[i] < num2) { num2 = values[i]; } } result = num2; } return result; } /// <summary> /// <para>Returns largest of two or more values.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="values"></param> public static float Max(float a, float b) { return (a <= b) ? b : a; } /// <summary> /// <para>Returns largest of two or more values.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="values"></param> public static float Max(params float[] values) { int num = values.Length; float result; ) { result = 0f; } else { ]; ; i < num; i++) { if (values[i] > num2) { num2 = values[i]; } } result = num2; } return result; } /// <summary> /// <para>Returns the largest of two or more values.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="values"></param> public static int Max(int a, int b) { return (a <= b) ? b : a; } /// <summary> /// <para>Returns the largest of two or more values.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="values"></param> public static int Max(params int[] values) { int num = values.Length; int result; ) { result = ; } else { ]; ; i < num; i++) { if (values[i] > num2) { num2 = values[i]; } } result = num2; } return result; } /// <summary> /// <para>Returns f raised to power p.</para> /// </summary> /// <param name="f"></param> /// <param name="p"></param> public static float Pow(float f, float p) { return (float)Math.Pow((double)f, (double)p); } /// <summary> /// <para>Returns e raised to the specified power.</para> /// </summary> /// <param name="power"></param> public static float Exp(float power) { return (float)Math.Exp((double)power); } /// <summary> /// <para>Returns the logarithm of a specified number in a specified base.</para> /// </summary> /// <param name="f"></param> /// <param name="p"></param> public static float Log(float f, float p) { return (float)Math.Log((double)f, (double)p); } /// <summary> /// <para>Returns the natural (base e) logarithm of a specified number.</para> /// </summary> /// <param name="f"></param> public static float Log(float f) { return (float)Math.Log((double)f); } /// <summary> /// <para>Returns the base 10 logarithm of a specified number.</para> /// </summary> /// <param name="f"></param> public static float Log10(float f) { return (float)Math.Log10((double)f); } /// <summary> /// <para>Returns the smallest integer greater to or equal to f.</para> /// </summary> /// <param name="f"></param> public static float Ceil(float f) { return (float)Math.Ceiling((double)f); } /// <summary> /// <para>Returns the largest integer smaller to or equal to f.</para> /// </summary> /// <param name="f"></param> public static float Floor(float f) { return (float)Math.Floor((double)f); } /// <summary> /// <para>Returns f rounded to the nearest integer.</para> /// </summary> /// <param name="f"></param> public static float Round(float f) { return (float)Math.Round((double)f); } /// <summary> /// <para>Returns the smallest integer greater to or equal to f.</para> /// </summary> /// <param name="f"></param> public static int CeilToInt(float f) { return (int)Math.Ceiling((double)f); } /// <summary> /// <para>Returns the largest integer smaller to or equal to f.</para> /// </summary> /// <param name="f"></param> public static int FloorToInt(float f) { return (int)Math.Floor((double)f); } /// <summary> /// <para>Returns f rounded to the nearest integer.</para> /// </summary> /// <param name="f"></param> public static int RoundToInt(float f) { return (int)Math.Round((double)f); } /// <summary> /// <para>Returns the sign of f.</para> /// </summary> /// <param name="f"></param> public static float Sign(float f) { return (f < 0f) ? -1f : 1f; } /// <summary> /// <para>Clamps a value between a minimum float and maximum float value.</para> /// </summary> /// <param name="value"></param> /// <param name="min"></param> /// <param name="max"></param> public static float Clamp(float value, float min, float max) { if (value < min) { value = min; } else if (value > max) { value = max; } return value; } /// <summary> /// <para>Clamps value between min and max and returns value.</para> /// </summary> /// <param name="value"></param> /// <param name="min"></param> /// <param name="max"></param> public static int Clamp(int value, int min, int max) { if (value < min) { value = min; } else if (value > max) { value = max; } return value; } /// <summary> /// <para>Clamps value between 0 and 1 and returns value.</para> /// </summary> /// <param name="value"></param> public static float Clamp01(float value) { float result; if (value < 0f) { result = 0f; } else if (value > 1f) { result = 1f; } else { result = value; } return result; } /// <summary> /// <para>Linearly interpolates between a and b by t.</para> /// </summary> /// <param name="a">The start value.</param> /// <param name="b">The end value.</param> /// <param name="t">The interpolation value between the two floats.</param> /// <returns> /// <para>The interpolated float result between the two float values.</para> /// </returns> public static float Lerp(float a, float b, float t) { return a + (b - a) * Mathf.Clamp01(t); } /// <summary> /// <para>Linearly interpolates between a and b by t with no limit to t.</para> /// </summary> /// <param name="a">The start value.</param> /// <param name="b">The end value.</param> /// <param name="t">The interpolation between the two floats.</param> /// <returns> /// <para>The float value as a result from the linear interpolation.</para> /// </returns> public static float LerpUnclamped(float a, float b, float t) { return a + (b - a) * t; } /// <summary> /// <para>Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="t"></param> public static float LerpAngle(float a, float b, float t) { float num = Mathf.Repeat(b - a, 360f); if (num > 180f) { num -= 360f; } return a + num * Mathf.Clamp01(t); } /// <summary> /// <para>Moves a value current towards target.</para> /// </summary> /// <param name="current">The current value.</param> /// <param name="target">The value to move towards.</param> /// <param name="maxDelta">The maximum change that should be applied to the value.</param> public static float MoveTowards(float current, float target, float maxDelta) { float result; if (Mathf.Abs(target - current) <= maxDelta) { result = target; } else { result = current + Mathf.Sign(target - current) * maxDelta; } return result; } /// <summary> /// <para>Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.</para> /// </summary> /// <param name="current"></param> /// <param name="target"></param> /// <param name="maxDelta"></param> public static float MoveTowardsAngle(float current, float target, float maxDelta) { float num = Mathf.DeltaAngle(current, target); float result; if (-maxDelta < num && num < maxDelta) { result = target; } else { target = current + num; result = Mathf.MoveTowards(current, target, maxDelta); } return result; } /// <summary> /// <para>Interpolates between min and max with smoothing at the limits.</para> /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <param name="t"></param> public static float SmoothStep(float from, float to, float t) { t = Mathf.Clamp01(t); t = -2f * t * t * t + 3f * t * t; return to * t + from * (1f - t); } public static float Gamma(float value, float absmax, float gamma) { bool flag = false; if (value < 0f) { flag = true; } float num = Mathf.Abs(value); float result; if (num > absmax) { result = ((!flag) ? num : (-num)); } else { float num2 = Mathf.Pow(num / absmax, gamma) * absmax; result = ((!flag) ? num2 : (-num2)); } return result; } /// <summary> /// <para>Compares two floating point values and returns true if they are similar.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> public static bool Approximately(float a, float b) { return Mathf.Abs(b - a) < Mathf.Max(1E-06f * Mathf.Max(Mathf.Abs(a), Mathf.Abs(b)), Mathf.Epsilon * 8f); } [ExcludeFromDocs] public static float SmoothDamp(float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed) { float deltaTime = Time.deltaTime; return Mathf.SmoothDamp(current, target, ref currentVelocity, smoothTime, maxSpeed, deltaTime); } [ExcludeFromDocs] public static float SmoothDamp(float current, float target, ref float currentVelocity, float smoothTime) { float deltaTime = Time.deltaTime; float maxSpeed = float.PositiveInfinity; return Mathf.SmoothDamp(current, target, ref currentVelocity, smoothTime, maxSpeed, deltaTime); } public static float SmoothDamp(float current, float target, ref float currentVelocity, float smoothTime, [DefaultValue("Mathf.Infinity")] float maxSpeed, [DefaultValue("Time.deltaTime")] float deltaTime) { smoothTime = Mathf.Max(0.0001f, smoothTime); float num = 2f / smoothTime; float num2 = num * deltaTime; float num3 = 1f / (1f + num2 + 0.48f * num2 * num2 + 0.235f * num2 * num2 * num2); float num4 = current - target; float num5 = target; float num6 = maxSpeed * smoothTime; num4 = Mathf.Clamp(num4, -num6, num6); target = current - num4; float num7 = (currentVelocity + num * num4) * deltaTime; currentVelocity = (currentVelocity - num * num7) * num3; float num8 = target + (num4 + num7) * num3; if (num5 - current > 0f == num8 > num5) { num8 = num5; currentVelocity = (num8 - num5) / deltaTime; } return num8; } [ExcludeFromDocs] public static float SmoothDampAngle(float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed) { float deltaTime = Time.deltaTime; return Mathf.SmoothDampAngle(current, target, ref currentVelocity, smoothTime, maxSpeed, deltaTime); } [ExcludeFromDocs] public static float SmoothDampAngle(float current, float target, ref float currentVelocity, float smoothTime) { float deltaTime = Time.deltaTime; float maxSpeed = float.PositiveInfinity; return Mathf.SmoothDampAngle(current, target, ref currentVelocity, smoothTime, maxSpeed, deltaTime); } public static float SmoothDampAngle(float current, float target, ref float currentVelocity, float smoothTime, [DefaultValue("Mathf.Infinity")] float maxSpeed, [DefaultValue("Time.deltaTime")] float deltaTime) { target = current + Mathf.DeltaAngle(current, target); return Mathf.SmoothDamp(current, target, ref currentVelocity, smoothTime, maxSpeed, deltaTime); } /// <summary> /// <para>Loops the value t, so that it is never larger than length and never smaller than 0.</para> /// </summary> /// <param name="t"></param> /// <param name="length"></param> public static float Repeat(float t, float length) { return t - Mathf.Floor(t / length) * length; } /// <summary> /// <para>PingPongs the value t, so that it is never larger than length and never smaller than 0.</para> /// </summary> /// <param name="t"></param> /// <param name="length"></param> public static float PingPong(float t, float length) { t = Mathf.Repeat(t, length * 2f); return length - Mathf.Abs(t - length); } /// <summary> /// <para>Calculates the linear parameter t that produces the interpolant value within the range [a, b].</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="value"></param> public static float InverseLerp(float a, float b, float value) { float result; if (a != b) { result = Mathf.Clamp01((value - a) / (b - a)); } else { result = 0f; } return result; } /// <summary> /// <para>Calculates the shortest difference between two given angles given in degrees.</para> /// </summary> /// <param name="current"></param> /// <param name="target"></param> public static float DeltaAngle(float current, float target) { float num = Mathf.Repeat(target - current, 360f); if (num > 180f) { num -= 360f; } return num; } internal static bool LineIntersection(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, ref Vector2 result) { float num = p2.x - p1.x; float num2 = p2.y - p1.y; float num3 = p4.x - p3.x; float num4 = p4.y - p3.y; float num5 = num * num4 - num2 * num3; bool result2; if (num5 == 0f) { result2 = false; } else { float num6 = p3.x - p1.x; float num7 = p3.y - p1.y; float num8 = (num6 * num4 - num7 * num3) / num5; result = new Vector2(p1.x + num8 * num, p1.y + num8 * num2); result2 = true; } return result2; } internal static bool LineSegmentIntersection(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, ref Vector2 result) { float num = p2.x - p1.x; float num2 = p2.y - p1.y; float num3 = p4.x - p3.x; float num4 = p4.y - p3.y; float num5 = num * num4 - num2 * num3; bool result2; if (num5 == 0f) { result2 = false; } else { float num6 = p3.x - p1.x; float num7 = p3.y - p1.y; float num8 = (num6 * num4 - num7 * num3) / num5; if (num8 < 0f || num8 > 1f) { result2 = false; } else { float num9 = (num6 * num2 - num7 * num) / num5; if (num9 < 0f || num9 > 1f) { result2 = false; } else { result = new Vector2(p1.x + num8 * num, p1.y + num8 * num2); result2 = true; } } } return result2; } internal static long RandomToLong(System.Random r) { ]; r.NextBytes(array); ) & 9223372036854775807uL); } } }
Mathf
using System; using System.Collections; using System.Runtime.CompilerServices; using UnityEngine.Internal; using UnityEngine.Scripting; namespace UnityEngine { /// <summary> /// <para>MonoBehaviour is the base class from which every Unity script derives.</para> /// </summary> [RequiredByNativeCode] public class MonoBehaviour : Behaviour { /// <summary> /// <para>Disabling this lets you skip the GUI layout phase.</para> /// </summary> public extern bool useGUILayout { [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] get; [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] set; } /// <summary> /// <para>Allow a specific instance of a MonoBehaviour to run in edit mode (only available in the editor).</para> /// </summary> public extern bool runInEditMode { [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] get; [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] set; } [GeneratedByOldBindingsGenerator, ThreadAndSerializationSafe] [MethodImpl(MethodImplOptions.InternalCall)] public extern MonoBehaviour(); [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private extern void Internal_CancelInvokeAll(); [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private extern bool Internal_IsInvokingAll(); /// <summary> /// <para>Invokes the method methodName in time seconds.</para> /// </summary> /// <param name="methodName"></param> /// <param name="time"></param> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public extern void Invoke(string methodName, float time); /// <summary> /// <para>Invokes the method methodName in time seconds, then repeatedly every repeatRate seconds.</para> /// </summary> /// <param name="methodName"></param> /// <param name="time"></param> /// <param name="repeatRate"></param> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public extern void InvokeRepeating(string methodName, float time, float repeatRate); /// <summary> /// <para>Cancels all Invoke calls on this MonoBehaviour.</para> /// </summary> public void CancelInvoke() { this.Internal_CancelInvokeAll(); } /// <summary> /// <para>Cancels all Invoke calls with name methodName on this behaviour.</para> /// </summary> /// <param name="methodName"></param> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public extern void CancelInvoke(string methodName); /// <summary> /// <para>Is any invoke on methodName pending?</para> /// </summary> /// <param name="methodName"></param> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public extern bool IsInvoking(string methodName); /// <summary> /// <para>Is any invoke pending on this MonoBehaviour?</para> /// </summary> public bool IsInvoking() { return this.Internal_IsInvokingAll(); } /// <summary> /// <para>Starts a coroutine.</para> /// </summary> /// <param name="routine"></param> public Coroutine StartCoroutine(IEnumerator routine) { return this.StartCoroutine_Auto_Internal(routine); } [Obsolete("StartCoroutine_Auto has been deprecated. Use StartCoroutine instead (UnityUpgradable) -> StartCoroutine([mscorlib] System.Collections.IEnumerator)", false)] public Coroutine StartCoroutine_Auto(IEnumerator routine) { return this.StartCoroutine(routine); } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private extern Coroutine StartCoroutine_Auto_Internal(IEnumerator routine); /// <summary> /// <para>Starts a coroutine named methodName.</para> /// </summary> /// <param name="methodName"></param> /// <param name="value"></param> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public extern Coroutine StartCoroutine(string methodName, [DefaultValue("null")] object value); /// <summary> /// <para>Starts a coroutine named methodName.</para> /// </summary> /// <param name="methodName"></param> /// <param name="value"></param> [ExcludeFromDocs] public Coroutine StartCoroutine(string methodName) { object value = null; return this.StartCoroutine(methodName, value); } /// <summary> /// <para>Stops the first coroutine named methodName, or the coroutine stored in routine running on this behaviour.</para> /// </summary> /// <param name="methodName">Name of coroutine.</param> /// <param name="routine">Name of the function in code.</param> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public extern void StopCoroutine(string methodName); /// <summary> /// <para>Stops the first coroutine named methodName, or the coroutine stored in routine running on this behaviour.</para> /// </summary> /// <param name="methodName">Name of coroutine.</param> /// <param name="routine">Name of the function in code.</param> public void StopCoroutine(IEnumerator routine) { this.StopCoroutineViaEnumerator_Auto(routine); } public void StopCoroutine(Coroutine routine) { this.StopCoroutine_Auto(routine); } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] internal extern void StopCoroutineViaEnumerator_Auto(IEnumerator routine); [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] internal extern void StopCoroutine_Auto(Coroutine routine); /// <summary> /// <para>Stops all coroutines running on this behaviour.</para> /// </summary> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public extern void StopAllCoroutines(); /// <summary> /// <para>Logs message to the Unity Console (identical to Debug.Log).</para> /// </summary> /// <param name="message"></param> public static void print(object message) { Debug.Log(message); } } }
MonoBehaviour
using System; using System.Runtime.CompilerServices; using UnityEngine.Scripting; namespace UnityEngine { /// <summary> /// <para>A standard 4x4 transformation matrix.</para> /// </summary> [UsedByNativeCode] public struct Matrix4x4 { public float m00; public float m10; public float m20; public float m30; public float m01; public float m11; public float m21; public float m31; public float m02; public float m12; public float m22; public float m32; public float m03; public float m13; public float m23; public float m33; /// <summary> /// <para>The inverse of this matrix (Read Only).</para> /// </summary> public Matrix4x4 inverse { get { return Matrix4x4.Inverse(this); } } /// <summary> /// <para>Returns the transpose of this matrix (Read Only).</para> /// </summary> public Matrix4x4 transpose { get { return Matrix4x4.Transpose(this); } } /// <summary> /// <para>Is this the identity matrix?</para> /// </summary> public extern bool isIdentity { [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] get; } /// <summary> /// <para>The determinant of the matrix.</para> /// </summary> public float determinant { get { return Matrix4x4.Determinant(this); } } public float this[int row, int column] { get { ]; } set { ] = value; } } public float this[int index] { get { float result; switch (index) { : result = this.m00; break; : result = this.m10; break; : result = this.m20; break; : result = this.m30; break; : result = this.m01; break; : result = this.m11; break; : result = this.m21; break; : result = this.m31; break; : result = this.m02; break; : result = this.m12; break; : result = this.m22; break; : result = this.m32; break; : result = this.m03; break; : result = this.m13; break; : result = this.m23; break; : result = this.m33; break; default: throw new IndexOutOfRangeException("Invalid matrix index!"); } return result; } set { switch (index) { : this.m00 = value; break; : this.m10 = value; break; : this.m20 = value; break; : this.m30 = value; break; : this.m01 = value; break; : this.m11 = value; break; : this.m21 = value; break; : this.m31 = value; break; : this.m02 = value; break; : this.m12 = value; break; : this.m22 = value; break; : this.m32 = value; break; : this.m03 = value; break; : this.m13 = value; break; : this.m23 = value; break; : this.m33 = value; break; default: throw new IndexOutOfRangeException("Invalid matrix index!"); } } } /// <summary> /// <para>Returns a matrix with all elements set to zero (Read Only).</para> /// </summary> public static Matrix4x4 zero { get { return new Matrix4x4 { m00 = 0f, m01 = 0f, m02 = 0f, m03 = 0f, m10 = 0f, m11 = 0f, m12 = 0f, m13 = 0f, m20 = 0f, m21 = 0f, m22 = 0f, m23 = 0f, m30 = 0f, m31 = 0f, m32 = 0f, m33 = 0f }; } } /// <summary> /// <para>Returns the identity matrix (Read Only).</para> /// </summary> public static Matrix4x4 identity { get { return new Matrix4x4 { m00 = 1f, m01 = 0f, m02 = 0f, m03 = 0f, m10 = 0f, m11 = 1f, m12 = 0f, m13 = 0f, m20 = 0f, m21 = 0f, m22 = 1f, m23 = 0f, m30 = 0f, m31 = 0f, m32 = 0f, m33 = 1f }; } } [ThreadAndSerializationSafe] public static Matrix4x4 Inverse(Matrix4x4 m) { Matrix4x4 result; Matrix4x4.INTERNAL_CALL_Inverse(ref m, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_Inverse(ref Matrix4x4 m, out Matrix4x4 value); public static Matrix4x4 Transpose(Matrix4x4 m) { Matrix4x4 result; Matrix4x4.INTERNAL_CALL_Transpose(ref m, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_Transpose(ref Matrix4x4 m, out Matrix4x4 value); internal static bool Invert(Matrix4x4 inMatrix, out Matrix4x4 dest) { return Matrix4x4.INTERNAL_CALL_Invert(ref inMatrix, out dest); } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern bool INTERNAL_CALL_Invert(ref Matrix4x4 inMatrix, out Matrix4x4 dest); public static float Determinant(Matrix4x4 m) { return Matrix4x4.INTERNAL_CALL_Determinant(ref m); } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern float INTERNAL_CALL_Determinant(ref Matrix4x4 m); /// <summary> /// <para>Sets this matrix to a translation, rotation and scaling matrix.</para> /// </summary> /// <param name="pos"></param> /// <param name="q"></param> /// <param name="s"></param> public void SetTRS(Vector3 pos, Quaternion q, Vector3 s) { this = Matrix4x4.TRS(pos, q, s); } /// <summary> /// <para>Creates a translation, rotation and scaling matrix.</para> /// </summary> /// <param name="pos"></param> /// <param name="q"></param> /// <param name="s"></param> public static Matrix4x4 TRS(Vector3 pos, Quaternion q, Vector3 s) { Matrix4x4 result; Matrix4x4.INTERNAL_CALL_TRS(ref pos, ref q, ref s, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_TRS(ref Vector3 pos, ref Quaternion q, ref Vector3 s, out Matrix4x4 value); /// <summary> /// <para>Creates an orthogonal projection matrix.</para> /// </summary> /// <param name="left"></param> /// <param name="right"></param> /// <param name="bottom"></param> /// <param name="top"></param> /// <param name="zNear"></param> /// <param name="zFar"></param> public static Matrix4x4 Ortho(float left, float right, float bottom, float top, float zNear, float zFar) { Matrix4x4 result; Matrix4x4.INTERNAL_CALL_Ortho(left, right, bottom, top, zNear, zFar, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_Ortho(float left, float right, float bottom, float top, float zNear, float zFar, out Matrix4x4 value); /// <summary> /// <para>Creates a perspective projection matrix.</para> /// </summary> /// <param name="fov"></param> /// <param name="aspect"></param> /// <param name="zNear"></param> /// <param name="zFar"></param> public static Matrix4x4 Perspective(float fov, float aspect, float zNear, float zFar) { Matrix4x4 result; Matrix4x4.INTERNAL_CALL_Perspective(fov, aspect, zNear, zFar, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_Perspective(float fov, float aspect, float zNear, float zFar, out Matrix4x4 value); /// <summary> /// <para>Given a source point, a target point, and an up vector, computes a transformation matrix that corresponds to a camera viewing the target from the source, such that the right-hand vector is perpendicular to the up vector.</para> /// </summary> /// <param name="from">The source point.</param> /// <param name="to">The target point.</param> /// <param name="up">The vector describing the up direction (typically Vector3.up).</param> /// <returns> /// <para>The resulting transformation matrix.</para> /// </returns> public static Matrix4x4 LookAt(Vector3 from, Vector3 to, Vector3 up) { Matrix4x4 result; Matrix4x4.INTERNAL_CALL_LookAt(ref from, ref to, ref up, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_LookAt(ref Vector3 from, ref Vector3 to, ref Vector3 up, out Matrix4x4 value); public override int GetHashCode() { ).GetHashCode() ^ ).GetHashCode() << ^ ).GetHashCode() >> ^ ).GetHashCode() >> ; } public override bool Equals(object other) { bool result; if (!(other is Matrix4x4)) { result = false; } else { Matrix4x4 matrix4x = (Matrix4x4)other; result = ().Equals(matrix4x.GetColumn()) && ).Equals(matrix4x.GetColumn()) && ).Equals(matrix4x.GetColumn()) && ).Equals(matrix4x.GetColumn())); } return result; } public static Matrix4x4 operator *(Matrix4x4 lhs, Matrix4x4 rhs) { return new Matrix4x4 { m00 = lhs.m00 * rhs.m00 + lhs.m01 * rhs.m10 + lhs.m02 * rhs.m20 + lhs.m03 * rhs.m30, m01 = lhs.m00 * rhs.m01 + lhs.m01 * rhs.m11 + lhs.m02 * rhs.m21 + lhs.m03 * rhs.m31, m02 = lhs.m00 * rhs.m02 + lhs.m01 * rhs.m12 + lhs.m02 * rhs.m22 + lhs.m03 * rhs.m32, m03 = lhs.m00 * rhs.m03 + lhs.m01 * rhs.m13 + lhs.m02 * rhs.m23 + lhs.m03 * rhs.m33, m10 = lhs.m10 * rhs.m00 + lhs.m11 * rhs.m10 + lhs.m12 * rhs.m20 + lhs.m13 * rhs.m30, m11 = lhs.m10 * rhs.m01 + lhs.m11 * rhs.m11 + lhs.m12 * rhs.m21 + lhs.m13 * rhs.m31, m12 = lhs.m10 * rhs.m02 + lhs.m11 * rhs.m12 + lhs.m12 * rhs.m22 + lhs.m13 * rhs.m32, m13 = lhs.m10 * rhs.m03 + lhs.m11 * rhs.m13 + lhs.m12 * rhs.m23 + lhs.m13 * rhs.m33, m20 = lhs.m20 * rhs.m00 + lhs.m21 * rhs.m10 + lhs.m22 * rhs.m20 + lhs.m23 * rhs.m30, m21 = lhs.m20 * rhs.m01 + lhs.m21 * rhs.m11 + lhs.m22 * rhs.m21 + lhs.m23 * rhs.m31, m22 = lhs.m20 * rhs.m02 + lhs.m21 * rhs.m12 + lhs.m22 * rhs.m22 + lhs.m23 * rhs.m32, m23 = lhs.m20 * rhs.m03 + lhs.m21 * rhs.m13 + lhs.m22 * rhs.m23 + lhs.m23 * rhs.m33, m30 = lhs.m30 * rhs.m00 + lhs.m31 * rhs.m10 + lhs.m32 * rhs.m20 + lhs.m33 * rhs.m30, m31 = lhs.m30 * rhs.m01 + lhs.m31 * rhs.m11 + lhs.m32 * rhs.m21 + lhs.m33 * rhs.m31, m32 = lhs.m30 * rhs.m02 + lhs.m31 * rhs.m12 + lhs.m32 * rhs.m22 + lhs.m33 * rhs.m32, m33 = lhs.m30 * rhs.m03 + lhs.m31 * rhs.m13 + lhs.m32 * rhs.m23 + lhs.m33 * rhs.m33 }; } public static Vector4 operator *(Matrix4x4 lhs, Vector4 v) { Vector4 result; result.x = lhs.m00 * v.x + lhs.m01 * v.y + lhs.m02 * v.z + lhs.m03 * v.w; result.y = lhs.m10 * v.x + lhs.m11 * v.y + lhs.m12 * v.z + lhs.m13 * v.w; result.z = lhs.m20 * v.x + lhs.m21 * v.y + lhs.m22 * v.z + lhs.m23 * v.w; result.w = lhs.m30 * v.x + lhs.m31 * v.y + lhs.m32 * v.z + lhs.m33 * v.w; return result; } public static bool operator ==(Matrix4x4 lhs, Matrix4x4 rhs) { ) == rhs.GetColumn() && lhs.GetColumn() == rhs.GetColumn() && lhs.GetColumn() == rhs.GetColumn() && lhs.GetColumn() == rhs.GetColumn(); } public static bool operator !=(Matrix4x4 lhs, Matrix4x4 rhs) { return !(lhs == rhs); } /// <summary> /// <para>Get a column of the matrix.</para> /// </summary> /// <param name="i"></param> public Vector4 GetColumn(int i) { , i], , i], , i], , i]); } /// <summary> /// <para>Returns a row of the matrix.</para> /// </summary> /// <param name="i"></param> public Vector4 GetRow(int i) { ], ], ], ]); } /// <summary> /// <para>Sets a column of the matrix.</para> /// </summary> /// <param name="i"></param> /// <param name="v"></param> public void SetColumn(int i, Vector4 v) { , i] = v.x; , i] = v.y; , i] = v.z; , i] = v.w; } /// <summary> /// <para>Sets a row of the matrix.</para> /// </summary> /// <param name="i"></param> /// <param name="v"></param> public void SetRow(int i, Vector4 v) { ] = v.x; ] = v.y; ] = v.z; ] = v.w; } /// <summary> /// <para>Transforms a position by this matrix (generic).</para> /// </summary> /// <param name="v"></param> public Vector3 MultiplyPoint(Vector3 v) { Vector3 result; result.x = this.m00 * v.x + this.m01 * v.y + this.m02 * v.z + this.m03; result.y = this.m10 * v.x + this.m11 * v.y + this.m12 * v.z + this.m13; result.z = this.m20 * v.x + this.m21 * v.y + this.m22 * v.z + this.m23; float num = this.m30 * v.x + this.m31 * v.y + this.m32 * v.z + this.m33; num = 1f / num; result.x *= num; result.y *= num; result.z *= num; return result; } /// <summary> /// <para>Transforms a position by this matrix (fast).</para> /// </summary> /// <param name="v"></param> public Vector3 MultiplyPoint3x4(Vector3 v) { Vector3 result; result.x = this.m00 * v.x + this.m01 * v.y + this.m02 * v.z + this.m03; result.y = this.m10 * v.x + this.m11 * v.y + this.m12 * v.z + this.m13; result.z = this.m20 * v.x + this.m21 * v.y + this.m22 * v.z + this.m23; return result; } /// <summary> /// <para>Transforms a direction by this matrix.</para> /// </summary> /// <param name="v"></param> public Vector3 MultiplyVector(Vector3 v) { Vector3 result; result.x = this.m00 * v.x + this.m01 * v.y + this.m02 * v.z; result.y = this.m10 * v.x + this.m11 * v.y + this.m12 * v.z; result.z = this.m20 * v.x + this.m21 * v.y + this.m22 * v.z; return result; } /// <summary> /// <para>Creates a scaling matrix.</para> /// </summary> /// <param name="v"></param> public static Matrix4x4 Scale(Vector3 v) { return new Matrix4x4 { m00 = v.x, m01 = 0f, m02 = 0f, m03 = 0f, m10 = 0f, m11 = v.y, m12 = 0f, m13 = 0f, m20 = 0f, m21 = 0f, m22 = v.z, m23 = 0f, m30 = 0f, m31 = 0f, m32 = 0f, m33 = 1f }; } public static Matrix4x4 Translate(Vector3 v) { return new Matrix4x4 { m00 = 1f, m01 = 0f, m02 = 0f, m03 = v.x, m10 = 0f, m11 = 1f, m12 = 0f, m13 = v.y, m20 = 0f, m21 = 0f, m22 = 1f, m23 = v.z, m30 = 0f, m31 = 0f, m32 = 0f, m33 = 1f }; } /// <summary> /// <para>Returns a nicely formatted string for this matrix.</para> /// </summary> /// <param name="format"></param> public override string ToString() { return UnityString.Format("{0:F5}\t{1:F5}\t{2:F5}\t{3:F5}\n{4:F5}\t{5:F5}\t{6:F5}\t{7:F5}\n{8:F5}\t{9:F5}\t{10:F5}\t{11:F5}\n{12:F5}\t{13:F5}\t{14:F5}\t{15:F5}\n", new object[] { this.m00, this.m01, this.m02, this.m03, this.m10, this.m11, this.m12, this.m13, this.m20, this.m21, this.m22, this.m23, this.m30, this.m31, this.m32, this.m33 }); } /// <summary> /// <para>Returns a nicely formatted string for this matrix.</para> /// </summary> /// <param name="format"></param> public string ToString(string format) { return UnityString.Format("{0}\t{1}\t{2}\t{3}\n{4}\t{5}\t{6}\t{7}\n{8}\t{9}\t{10}\t{11}\n{12}\t{13}\t{14}\t{15}\n", new object[] { this.m00.ToString(format), this.m01.ToString(format), this.m02.ToString(format), this.m03.ToString(format), this.m10.ToString(format), this.m11.ToString(format), this.m12.ToString(format), this.m13.ToString(format), this.m20.ToString(format), this.m21.ToString(format), this.m22.ToString(format), this.m23.ToString(format), this.m30.ToString(format), this.m31.ToString(format), this.m32.ToString(format), this.m33.ToString(format) }); } } }
Matrix4x4
N:
O:
using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; using UnityEngine.Internal; using UnityEngine.Scripting; using UnityEngineInternal; namespace UnityEngine { /// <summary> /// <para>Base class for all objects Unity can reference.</para> /// </summary> [RequiredByNativeCode] [StructLayout(LayoutKind.Sequential)] public class Object { private IntPtr m_CachedPtr; private int m_InstanceID; private string m_UnityRuntimeErrorString; ; /// <summary> /// <para>The name of the object.</para> /// </summary> public extern string name { [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] get; [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] set; } /// <summary> /// <para>Should the object be hidden, saved with the scene or modifiable by the user?</para> /// </summary> public extern HideFlags hideFlags { [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] get; [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] set; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern Object Internal_CloneSingle(Object data); [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern Object Internal_CloneSingleWithParent(Object data, Transform parent, bool worldPositionStays); [ThreadAndSerializationSafe] private static Object Internal_InstantiateSingle(Object data, Vector3 pos, Quaternion rot) { return Object.INTERNAL_CALL_Internal_InstantiateSingle(data, ref pos, ref rot); } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern Object INTERNAL_CALL_Internal_InstantiateSingle(Object data, ref Vector3 pos, ref Quaternion rot); private static Object Internal_InstantiateSingleWithParent(Object data, Transform parent, Vector3 pos, Quaternion rot) { return Object.INTERNAL_CALL_Internal_InstantiateSingleWithParent(data, parent, ref pos, ref rot); } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern Object INTERNAL_CALL_Internal_InstantiateSingleWithParent(Object data, Transform parent, ref Vector3 pos, ref Quaternion rot); [GeneratedByOldBindingsGenerator, ThreadAndSerializationSafe] [MethodImpl(MethodImplOptions.InternalCall)] private static extern int GetOffsetOfInstanceIDInCPlusPlusObject(); [GeneratedByOldBindingsGenerator, ThreadAndSerializationSafe] [MethodImpl(MethodImplOptions.InternalCall)] private extern void EnsureRunningOnMainThread(); /// <summary> /// <para>Removes a gameobject, component or asset.</para> /// </summary> /// <param name="obj">The object to destroy.</param> /// <param name="t">The optional amount of time to delay before destroying the object.</param> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public static extern void Destroy(Object obj, [DefaultValue("0.0F")] float t); /// <summary> /// <para>Removes a gameobject, component or asset.</para> /// </summary> /// <param name="obj">The object to destroy.</param> /// <param name="t">The optional amount of time to delay before destroying the object.</param> [ExcludeFromDocs] public static void Destroy(Object obj) { float t = 0f; Object.Destroy(obj, t); } /// <summary> /// <para>Destroys the object obj immediately. You are strongly recommended to use Destroy instead.</para> /// </summary> /// <param name="obj">Object to be destroyed.</param> /// <param name="allowDestroyingAssets">Set to true to allow assets to be destoyed.</param> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public static extern void DestroyImmediate(Object obj, [DefaultValue("false")] bool allowDestroyingAssets); /// <summary> /// <para>Destroys the object obj immediately. You are strongly recommended to use Destroy instead.</para> /// </summary> /// <param name="obj">Object to be destroyed.</param> /// <param name="allowDestroyingAssets">Set to true to allow assets to be destoyed.</param> [ExcludeFromDocs] public static void DestroyImmediate(Object obj) { bool allowDestroyingAssets = false; Object.DestroyImmediate(obj, allowDestroyingAssets); } /// <summary> /// <para>Returns a list of all active loaded objects of Type type.</para> /// </summary> /// <param name="type">The type of object to find.</param> /// <returns> /// <para>The array of objects found matching the type specified.</para> /// </returns> [GeneratedByOldBindingsGenerator, TypeInferenceRule(TypeInferenceRules.ArrayOfTypeReferencedByFirstArgument)] [MethodImpl(MethodImplOptions.InternalCall)] public static extern Object[] FindObjectsOfType(Type type); /// <summary> /// <para>Makes the object target not be destroyed automatically when loading a new scene.</para> /// </summary> /// <param name="target"></param> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public static extern void DontDestroyOnLoad(Object target); [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public static extern void DestroyObject(Object obj, [DefaultValue("0.0F")] float t); [ExcludeFromDocs] public static void DestroyObject(Object obj) { float t = 0f; Object.DestroyObject(obj, t); } [Obsolete("use Object.FindObjectsOfType instead."), GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public static extern Object[] FindSceneObjectsOfType(Type type); /// <summary> /// <para>Returns a list of all active and inactive loaded objects of Type type, including assets.</para> /// </summary> /// <param name="type">The type of object or asset to find.</param> /// <returns> /// <para>The array of objects and assets found matching the type specified.</para> /// </returns> [Obsolete("use Resources.FindObjectsOfTypeAll instead."), GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public static extern Object[] FindObjectsOfTypeIncludingAssets(Type type); /// <summary> /// <para>Returns a list of all active and inactive loaded objects of Type type.</para> /// </summary> /// <param name="type">The type of object to find.</param> /// <returns> /// <para>The array of objects found matching the type specified.</para> /// </returns> [Obsolete("Please use Resources.FindObjectsOfTypeAll instead")] public static Object[] FindObjectsOfTypeAll(Type type) { return Resources.FindObjectsOfTypeAll(type); } /// <summary> /// <para>Returns the name of the game object.</para> /// </summary> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public override extern string ToString(); [GeneratedByOldBindingsGenerator, ThreadAndSerializationSafe] [MethodImpl(MethodImplOptions.InternalCall)] internal static extern bool DoesObjectWithInstanceIDExist(int instanceID); /// <summary> /// <para>Returns the instance id of the object.</para> /// </summary> [SecuritySafeCritical] public int GetInstanceID() { this.EnsureRunningOnMainThread(); return this.m_InstanceID; } public override int GetHashCode() { return this.m_InstanceID; } public override bool Equals(object other) { Object @object = other as Object; return (!(@object == null) || other == null || other is Object) && Object.CompareBaseObjects(this, @object); } public static implicit operator bool(Object exists) { return !Object.CompareBaseObjects(exists, null); } private static bool CompareBaseObjects(Object lhs, Object rhs) { bool flag = lhs == null; bool flag2 = rhs == null; bool result; if (flag2 && flag) { result = true; } else if (flag2) { result = !Object.IsNativeObjectAlive(lhs); } else if (flag) { result = !Object.IsNativeObjectAlive(rhs); } else { result = (lhs.m_InstanceID == rhs.m_InstanceID); } return result; } private static bool IsNativeObjectAlive(Object o) { return o.GetCachedPtr() != IntPtr.Zero || (!(o is MonoBehaviour) && !(o is ScriptableObject) && Object.DoesObjectWithInstanceIDExist(o.GetInstanceID())); } private IntPtr GetCachedPtr() { return this.m_CachedPtr; } /// <summary> /// <para>Clones the object original and returns the clone.</para> /// </summary> /// <param name="original">An existing object that you want to make a copy of.</param> /// <param name="position">Position for the new object.</param> /// <param name="rotation">Orientation of the new object.</param> /// <param name="parent">Parent that will be assigned to the new object.</param> /// <param name="instantiateInWorldSpace">Pass true when assigning a parent Object to maintain the world position of the Object, instead of setting its position relative to the new parent. Pass false to set the Object's position relative to its new parent.</param> /// <returns> /// <para>The instantiated clone.</para> /// </returns> [TypeInferenceRule(TypeInferenceRules.TypeOfFirstArgument)] public static Object Instantiate(Object original, Vector3 position, Quaternion rotation) { Object.CheckNullArgument(original, "The Object you want to instantiate is null."); if (original is ScriptableObject) { throw new ArgumentException("Cannot instantiate a ScriptableObject with a position and rotation"); } return Object.Internal_InstantiateSingle(original, position, rotation); } /// <summary> /// <para>Clones the object original and returns the clone.</para> /// </summary> /// <param name="original">An existing object that you want to make a copy of.</param> /// <param name="position">Position for the new object.</param> /// <param name="rotation">Orientation of the new object.</param> /// <param name="parent">Parent that will be assigned to the new object.</param> /// <param name="instantiateInWorldSpace">Pass true when assigning a parent Object to maintain the world position of the Object, instead of setting its position relative to the new parent. Pass false to set the Object's position relative to its new parent.</param> /// <returns> /// <para>The instantiated clone.</para> /// </returns> [TypeInferenceRule(TypeInferenceRules.TypeOfFirstArgument)] public static Object Instantiate(Object original, Vector3 position, Quaternion rotation, Transform parent) { Object result; if (parent == null) { result = Object.Internal_InstantiateSingle(original, position, rotation); } else { Object.CheckNullArgument(original, "The Object you want to instantiate is null."); result = Object.Internal_InstantiateSingleWithParent(original, parent, position, rotation); } return result; } /// <summary> /// <para>Clones the object original and returns the clone.</para> /// </summary> /// <param name="original">An existing object that you want to make a copy of.</param> /// <param name="position">Position for the new object.</param> /// <param name="rotation">Orientation of the new object.</param> /// <param name="parent">Parent that will be assigned to the new object.</param> /// <param name="instantiateInWorldSpace">Pass true when assigning a parent Object to maintain the world position of the Object, instead of setting its position relative to the new parent. Pass false to set the Object's position relative to its new parent.</param> /// <returns> /// <para>The instantiated clone.</para> /// </returns> [TypeInferenceRule(TypeInferenceRules.TypeOfFirstArgument)] public static Object Instantiate(Object original) { Object.CheckNullArgument(original, "The Object you want to instantiate is null."); return Object.Internal_CloneSingle(original); } /// <summary> /// <para>Clones the object original and returns the clone.</para> /// </summary> /// <param name="original">An existing object that you want to make a copy of.</param> /// <param name="position">Position for the new object.</param> /// <param name="rotation">Orientation of the new object.</param> /// <param name="parent">Parent that will be assigned to the new object.</param> /// <param name="instantiateInWorldSpace">Pass true when assigning a parent Object to maintain the world position of the Object, instead of setting its position relative to the new parent. Pass false to set the Object's position relative to its new parent.</param> /// <returns> /// <para>The instantiated clone.</para> /// </returns> [TypeInferenceRule(TypeInferenceRules.TypeOfFirstArgument)] public static Object Instantiate(Object original, Transform parent) { return Object.Instantiate(original, parent, false); } /// <summary> /// <para>Clones the object original and returns the clone.</para> /// </summary> /// <param name="original">An existing object that you want to make a copy of.</param> /// <param name="position">Position for the new object.</param> /// <param name="rotation">Orientation of the new object.</param> /// <param name="parent">Parent that will be assigned to the new object.</param> /// <param name="instantiateInWorldSpace">Pass true when assigning a parent Object to maintain the world position of the Object, instead of setting its position relative to the new parent. Pass false to set the Object's position relative to its new parent.</param> /// <returns> /// <para>The instantiated clone.</para> /// </returns> [TypeInferenceRule(TypeInferenceRules.TypeOfFirstArgument)] public static Object Instantiate(Object original, Transform parent, bool instantiateInWorldSpace) { Object result; if (parent == null) { result = Object.Internal_CloneSingle(original); } else { Object.CheckNullArgument(original, "The Object you want to instantiate is null."); result = Object.Internal_CloneSingleWithParent(original, parent, instantiateInWorldSpace); } return result; } public static T Instantiate<T>(T original) where T : Object { Object.CheckNullArgument(original, "The Object you want to instantiate is null."); return (T)((object)Object.Internal_CloneSingle(original)); } public static T Instantiate<T>(T original, Vector3 position, Quaternion rotation) where T : Object { return (T)((object)Object.Instantiate(original, position, rotation)); } public static T Instantiate<T>(T original, Vector3 position, Quaternion rotation, Transform parent) where T : Object { return (T)((object)Object.Instantiate(original, position, rotation, parent)); } public static T Instantiate<T>(T original, Transform parent) where T : Object { return Object.Instantiate<T>(original, parent, false); } public static T Instantiate<T>(T original, Transform parent, bool worldPositionStays) where T : Object { return (T)((object)Object.Instantiate(original, parent, worldPositionStays)); } public static T[] FindObjectsOfType<T>() where T : Object { return Resources.ConvertObjects<T>(Object.FindObjectsOfType(typeof(T))); } public static T FindObjectOfType<T>() where T : Object { return (T)((object)Object.FindObjectOfType(typeof(T))); } private static void CheckNullArgument(object arg, string message) { if (arg == null) { throw new ArgumentException(message); } } /// <summary> /// <para>Returns the first active loaded object of Type type.</para> /// </summary> /// <param name="type">The type of object to find.</param> /// <returns> /// <para>An array of objects which matched the specified type, cast as Object.</para> /// </returns> [TypeInferenceRule(TypeInferenceRules.TypeReferencedByFirstArgument)] public static Object FindObjectOfType(Type type) { Object[] array = Object.FindObjectsOfType(type); Object result; ) { result = array[]; } else { result = null; } return result; } public static bool operator ==(Object x, Object y) { return Object.CompareBaseObjects(x, y); } public static bool operator !=(Object x, Object y) { return !Object.CompareBaseObjects(x, y); } } }
Object
P:
Q:
using System; using System.Runtime.CompilerServices; using UnityEngine.Internal; using UnityEngine.Scripting; namespace UnityEngine { /// <summary> /// <para>Quaternions are used to represent rotations.</para> /// </summary> [UsedByNativeCode] public struct Quaternion { /// <summary> /// <para>X component of the Quaternion. Don't modify this directly unless you know quaternions inside out.</para> /// </summary> public float x; /// <summary> /// <para>Y component of the Quaternion. Don't modify this directly unless you know quaternions inside out.</para> /// </summary> public float y; /// <summary> /// <para>Z component of the Quaternion. Don't modify this directly unless you know quaternions inside out.</para> /// </summary> public float z; /// <summary> /// <para>W component of the Quaternion. Don't modify this directly unless you know quaternions inside out.</para> /// </summary> public float w; public const float kEpsilon = 1E-06f; /// <summary> /// <para>Returns the euler angle representation of the rotation.</para> /// </summary> public Vector3 eulerAngles { get { return Quaternion.Internal_MakePositive(Quaternion.Internal_ToEulerRad(this) * 57.29578f); } set { this = Quaternion.Internal_FromEulerRad(value * 0.0174532924f); } } public float this[int index] { get { float result; switch (index) { : result = this.x; break; : result = this.y; break; : result = this.z; break; : result = this.w; break; default: throw new IndexOutOfRangeException("Invalid Quaternion index!"); } return result; } set { switch (index) { : this.x = value; break; : this.y = value; break; : this.z = value; break; : this.w = value; break; default: throw new IndexOutOfRangeException("Invalid Quaternion index!"); } } } /// <summary> /// <para>The identity rotation (Read Only).</para> /// </summary> public static Quaternion identity { get { return new Quaternion(0f, 0f, 0f, 1f); } } /// <summary> /// <para>Constructs new Quaternion with given x,y,z,w components.</para> /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> /// <param name="w"></param> public Quaternion(float x, float y, float z, float w) { this.x = x; this.y = y; this.z = z; this.w = w; } /// <summary> /// <para>Creates a rotation which rotates angle degrees around axis.</para> /// </summary> /// <param name="angle"></param> /// <param name="axis"></param> [ThreadAndSerializationSafe] public static Quaternion AngleAxis(float angle, Vector3 axis) { Quaternion result; Quaternion.INTERNAL_CALL_AngleAxis(angle, ref axis, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_AngleAxis(float angle, ref Vector3 axis, out Quaternion value); public void ToAngleAxis(out float angle, out Vector3 axis) { Quaternion.Internal_ToAxisAngleRad(this, out axis, out angle); angle *= 57.29578f; } /// <summary> /// <para>Creates a rotation which rotates from fromDirection to toDirection.</para> /// </summary> /// <param name="fromDirection"></param> /// <param name="toDirection"></param> public static Quaternion FromToRotation(Vector3 fromDirection, Vector3 toDirection) { Quaternion result; Quaternion.INTERNAL_CALL_FromToRotation(ref fromDirection, ref toDirection, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_FromToRotation(ref Vector3 fromDirection, ref Vector3 toDirection, out Quaternion value); /// <summary> /// <para>Creates a rotation which rotates from fromDirection to toDirection.</para> /// </summary> /// <param name="fromDirection"></param> /// <param name="toDirection"></param> public void SetFromToRotation(Vector3 fromDirection, Vector3 toDirection) { this = Quaternion.FromToRotation(fromDirection, toDirection); } /// <summary> /// <para>Creates a rotation with the specified forward and upwards directions.</para> /// </summary> /// <param name="forward">The direction to look in.</param> /// <param name="upwards">The vector that defines in which direction up is.</param> public static Quaternion LookRotation(Vector3 forward, [DefaultValue("Vector3.up")] Vector3 upwards) { Quaternion result; Quaternion.INTERNAL_CALL_LookRotation(ref forward, ref upwards, out result); return result; } /// <summary> /// <para>Creates a rotation with the specified forward and upwards directions.</para> /// </summary> /// <param name="forward">The direction to look in.</param> /// <param name="upwards">The vector that defines in which direction up is.</param> [ExcludeFromDocs] public static Quaternion LookRotation(Vector3 forward) { Vector3 up = Vector3.up; Quaternion result; Quaternion.INTERNAL_CALL_LookRotation(ref forward, ref up, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_LookRotation(ref Vector3 forward, ref Vector3 upwards, out Quaternion value); /// <summary> /// <para>Spherically interpolates between a and b by t. The parameter t is clamped to the range [0, 1].</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="t"></param> public static Quaternion Slerp(Quaternion a, Quaternion b, float t) { Quaternion result; Quaternion.INTERNAL_CALL_Slerp(ref a, ref b, t, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_Slerp(ref Quaternion a, ref Quaternion b, float t, out Quaternion value); /// <summary> /// <para>Spherically interpolates between a and b by t. The parameter t is not clamped.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="t"></param> public static Quaternion SlerpUnclamped(Quaternion a, Quaternion b, float t) { Quaternion result; Quaternion.INTERNAL_CALL_SlerpUnclamped(ref a, ref b, t, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_SlerpUnclamped(ref Quaternion a, ref Quaternion b, float t, out Quaternion value); /// <summary> /// <para>Interpolates between a and b by t and normalizes the result afterwards. The parameter t is clamped to the range [0, 1].</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="t"></param> public static Quaternion Lerp(Quaternion a, Quaternion b, float t) { Quaternion result; Quaternion.INTERNAL_CALL_Lerp(ref a, ref b, t, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_Lerp(ref Quaternion a, ref Quaternion b, float t, out Quaternion value); /// <summary> /// <para>Interpolates between a and b by t and normalizes the result afterwards. The parameter t is not clamped.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="t"></param> public static Quaternion LerpUnclamped(Quaternion a, Quaternion b, float t) { Quaternion result; Quaternion.INTERNAL_CALL_LerpUnclamped(ref a, ref b, t, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_LerpUnclamped(ref Quaternion a, ref Quaternion b, float t, out Quaternion value); /// <summary> /// <para>Rotates a rotation from towards to.</para> /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <param name="maxDegreesDelta"></param> public static Quaternion RotateTowards(Quaternion from, Quaternion to, float maxDegreesDelta) { float num = Quaternion.Angle(from, to); Quaternion result; if (num == 0f) { result = to; } else { float t = Mathf.Min(1f, maxDegreesDelta / num); result = Quaternion.SlerpUnclamped(from, to, t); } return result; } /// <summary> /// <para>Returns the Inverse of rotation.</para> /// </summary> /// <param name="rotation"></param> public static Quaternion Inverse(Quaternion rotation) { Quaternion result; Quaternion.INTERNAL_CALL_Inverse(ref rotation, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_Inverse(ref Quaternion rotation, out Quaternion value); /// <summary> /// <para>Returns a rotation that rotates z degrees around the z axis, x degrees around the x axis, and y degrees around the y axis (in that order).</para> /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> public static Quaternion Euler(float x, float y, float z) { return Quaternion.Internal_FromEulerRad(new Vector3(x, y, z) * 0.0174532924f); } /// <summary> /// <para>Returns a rotation that rotates z degrees around the z axis, x degrees around the x axis, and y degrees around the y axis (in that order).</para> /// </summary> /// <param name="euler"></param> public static Quaternion Euler(Vector3 euler) { return Quaternion.Internal_FromEulerRad(euler * 0.0174532924f); } private static Vector3 Internal_ToEulerRad(Quaternion rotation) { Vector3 result; Quaternion.INTERNAL_CALL_Internal_ToEulerRad(ref rotation, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_Internal_ToEulerRad(ref Quaternion rotation, out Vector3 value); private static Quaternion Internal_FromEulerRad(Vector3 euler) { Quaternion result; Quaternion.INTERNAL_CALL_Internal_FromEulerRad(ref euler, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_Internal_FromEulerRad(ref Vector3 euler, out Quaternion value); private static void Internal_ToAxisAngleRad(Quaternion q, out Vector3 axis, out float angle) { Quaternion.INTERNAL_CALL_Internal_ToAxisAngleRad(ref q, out axis, out angle); } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_Internal_ToAxisAngleRad(ref Quaternion q, out Vector3 axis, out float angle); [Obsolete("Use Quaternion.Euler instead. This function was deprecated because it uses radians instead of degrees")] public static Quaternion EulerRotation(float x, float y, float z) { return Quaternion.Internal_FromEulerRad(new Vector3(x, y, z)); } [Obsolete("Use Quaternion.Euler instead. This function was deprecated because it uses radians instead of degrees")] public static Quaternion EulerRotation(Vector3 euler) { return Quaternion.Internal_FromEulerRad(euler); } [Obsolete("Use Quaternion.Euler instead. This function was deprecated because it uses radians instead of degrees")] public void SetEulerRotation(float x, float y, float z) { this = Quaternion.Internal_FromEulerRad(new Vector3(x, y, z)); } [Obsolete("Use Quaternion.Euler instead. This function was deprecated because it uses radians instead of degrees")] public void SetEulerRotation(Vector3 euler) { this = Quaternion.Internal_FromEulerRad(euler); } [Obsolete("Use Quaternion.eulerAngles instead. This function was deprecated because it uses radians instead of degrees")] public Vector3 ToEuler() { return Quaternion.Internal_ToEulerRad(this); } [Obsolete("Use Quaternion.Euler instead. This function was deprecated because it uses radians instead of degrees")] public static Quaternion EulerAngles(float x, float y, float z) { return Quaternion.Internal_FromEulerRad(new Vector3(x, y, z)); } [Obsolete("Use Quaternion.Euler instead. This function was deprecated because it uses radians instead of degrees")] public static Quaternion EulerAngles(Vector3 euler) { return Quaternion.Internal_FromEulerRad(euler); } [Obsolete("Use Quaternion.ToAngleAxis instead. This function was deprecated because it uses radians instead of degrees")] public void ToAxisAngle(out Vector3 axis, out float angle) { Quaternion.Internal_ToAxisAngleRad(this, out axis, out angle); } [Obsolete("Use Quaternion.Euler instead. This function was deprecated because it uses radians instead of degrees")] public void SetEulerAngles(float x, float y, float z) { this.SetEulerRotation(new Vector3(x, y, z)); } [Obsolete("Use Quaternion.Euler instead. This function was deprecated because it uses radians instead of degrees")] public void SetEulerAngles(Vector3 euler) { this = Quaternion.EulerRotation(euler); } [Obsolete("Use Quaternion.eulerAngles instead. This function was deprecated because it uses radians instead of degrees")] public static Vector3 ToEulerAngles(Quaternion rotation) { return Quaternion.Internal_ToEulerRad(rotation); } [Obsolete("Use Quaternion.eulerAngles instead. This function was deprecated because it uses radians instead of degrees")] public Vector3 ToEulerAngles() { return Quaternion.Internal_ToEulerRad(this); } [Obsolete("Use Quaternion.AngleAxis instead. This function was deprecated because it uses radians instead of degrees")] public static Quaternion AxisAngle(Vector3 axis, float angle) { Quaternion result; Quaternion.INTERNAL_CALL_AxisAngle(ref axis, angle, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_AxisAngle(ref Vector3 axis, float angle, out Quaternion value); [Obsolete("Use Quaternion.AngleAxis instead. This function was deprecated because it uses radians instead of degrees")] public void SetAxisAngle(Vector3 axis, float angle) { this = Quaternion.AxisAngle(axis, angle); } /// <summary> /// <para>Set x, y, z and w components of an existing Quaternion.</para> /// </summary> /// <param name="new_x"></param> /// <param name="new_y"></param> /// <param name="new_z"></param> /// <param name="new_w"></param> public void Set(float new_x, float new_y, float new_z, float new_w) { this.x = new_x; this.y = new_y; this.z = new_z; this.w = new_w; } public static Quaternion operator *(Quaternion lhs, Quaternion rhs) { return new Quaternion(lhs.w * rhs.x + lhs.x * rhs.w + lhs.y * rhs.z - lhs.z * rhs.y, lhs.w * rhs.y + lhs.y * rhs.w + lhs.z * rhs.x - lhs.x * rhs.z, lhs.w * rhs.z + lhs.z * rhs.w + lhs.x * rhs.y - lhs.y * rhs.x, lhs.w * rhs.w - lhs.x * rhs.x - lhs.y * rhs.y - lhs.z * rhs.z); } public static Vector3 operator *(Quaternion rotation, Vector3 point) { float num = rotation.x * 2f; float num2 = rotation.y * 2f; float num3 = rotation.z * 2f; float num4 = rotation.x * num; float num5 = rotation.y * num2; float num6 = rotation.z * num3; float num7 = rotation.x * num2; float num8 = rotation.x * num3; float num9 = rotation.y * num3; float num10 = rotation.w * num; float num11 = rotation.w * num2; float num12 = rotation.w * num3; Vector3 result; result.x = (1f - (num5 + num6)) * point.x + (num7 - num12) * point.y + (num8 + num11) * point.z; result.y = (num7 + num12) * point.x + (1f - (num4 + num6)) * point.y + (num9 - num10) * point.z; result.z = (num8 - num11) * point.x + (num9 + num10) * point.y + (1f - (num4 + num5)) * point.z; return result; } public static bool operator ==(Quaternion lhs, Quaternion rhs) { return Quaternion.Dot(lhs, rhs) > 0.999999f; } public static bool operator !=(Quaternion lhs, Quaternion rhs) { return !(lhs == rhs); } /// <summary> /// <para>The dot product between two rotations.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> public static float Dot(Quaternion a, Quaternion b) { return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w; } /// <summary> /// <para>Creates a rotation with the specified forward and upwards directions.</para> /// </summary> /// <param name="view">The direction to look in.</param> /// <param name="up">The vector that defines in which direction up is.</param> [ExcludeFromDocs] public void SetLookRotation(Vector3 view) { Vector3 up = Vector3.up; this.SetLookRotation(view, up); } /// <summary> /// <para>Creates a rotation with the specified forward and upwards directions.</para> /// </summary> /// <param name="view">The direction to look in.</param> /// <param name="up">The vector that defines in which direction up is.</param> public void SetLookRotation(Vector3 view, [DefaultValue("Vector3.up")] Vector3 up) { this = Quaternion.LookRotation(view, up); } /// <summary> /// <para>Returns the angle in degrees between two rotations a and b.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> public static float Angle(Quaternion a, Quaternion b) { float f = Quaternion.Dot(a, b); return Mathf.Acos(Mathf.Min(Mathf.Abs(f), 1f)) * 2f * 57.29578f; } private static Vector3 Internal_MakePositive(Vector3 euler) { float num = -0.005729578f; float num2 = 360f + num; if (euler.x < num) { euler.x += 360f; } else if (euler.x > num2) { euler.x -= 360f; } if (euler.y < num) { euler.y += 360f; } else if (euler.y > num2) { euler.y -= 360f; } if (euler.z < num) { euler.z += 360f; } else if (euler.z > num2) { euler.z -= 360f; } return euler; } public override int GetHashCode() { ^ ^ ; } public override bool Equals(object other) { bool result; if (!(other is Quaternion)) { result = false; } else { Quaternion quaternion = (Quaternion)other; result = (this.x.Equals(quaternion.x) && this.y.Equals(quaternion.y) && this.z.Equals(quaternion.z) && this.w.Equals(quaternion.w)); } return result; } /// <summary> /// <para>Returns a nicely formatted string of the Quaternion.</para> /// </summary> /// <param name="format"></param> public override string ToString() { return UnityString.Format("({0:F1}, {1:F1}, {2:F1}, {3:F1})", new object[] { this.x, this.y, this.z, this.w }); } /// <summary> /// <para>Returns a nicely formatted string of the Quaternion.</para> /// </summary> /// <param name="format"></param> public string ToString(string format) { return UnityString.Format("({0}, {1}, {2}, {3})", new object[] { this.x.ToString(format), this.y.ToString(format), this.z.ToString(format), this.w.ToString(format) }); } } }
Quaternion
R:
using System; using System.Runtime.CompilerServices; using UnityEngine.Scripting; using UnityEngineInternal; namespace UnityEngine { /// <summary> /// <para>The Resources class allows you to find and access Objects including assets.</para> /// </summary> public sealed class Resources { internal static T[] ConvertObjects<T>(Object[] rawObjects) where T : Object { T[] result; if (rawObjects == null) { result = null; } else { T[] array = new T[rawObjects.Length]; ; i < array.Length; i++) { array[i] = (T)((object)rawObjects[i]); } result = array; } return result; } /// <summary> /// <para>Returns a list of all objects of Type type.</para> /// </summary> /// <param name="type">Type of the class to match while searching.</param> /// <returns> /// <para>An array of objects whose class is type or is derived from type.</para> /// </returns> [GeneratedByOldBindingsGenerator, TypeInferenceRule(TypeInferenceRules.ArrayOfTypeReferencedByFirstArgument)] [MethodImpl(MethodImplOptions.InternalCall)] public static extern Object[] FindObjectsOfTypeAll(Type type); public static T[] FindObjectsOfTypeAll<T>() where T : Object { return Resources.ConvertObjects<T>(Resources.FindObjectsOfTypeAll(typeof(T))); } /// <summary> /// <para>Loads an asset stored at path in a Resources folder.</para> /// </summary> /// <param name="path">Pathname of the target folder. When using the empty string (i.e., ""), the function will load the entire contents of the Resources folder.</param> /// <param name="systemTypeInstance">Type filter for objects returned.</param> public static Object Load(string path) { return Resources.Load(path, typeof(Object)); } public static T Load<T>(string path) where T : Object { return (T)((object)Resources.Load(path, typeof(T))); } /// <summary> /// <para>Loads an asset stored at path in a Resources folder.</para> /// </summary> /// <param name="path">Pathname of the target folder. When using the empty string (i.e., ""), the function will load the entire contents of the Resources folder.</param> /// <param name="systemTypeInstance">Type filter for objects returned.</param> [GeneratedByOldBindingsGenerator, TypeInferenceRule(TypeInferenceRules.TypeReferencedBySecondArgument)] [MethodImpl(MethodImplOptions.InternalCall)] public static extern Object Load(string path, Type systemTypeInstance); /// <summary> /// <para>Asynchronously loads an asset stored at path in a Resources folder.</para> /// </summary> /// <param name="path">Pathname of the target folder. When using the empty string (i.e., ""), the function will load the entire contents of the Resources folder.</param> /// <param name="systemTypeInstance">Type filter for objects returned.</param> /// <param name="type"></param> public static ResourceRequest LoadAsync(string path) { return Resources.LoadAsync(path, typeof(Object)); } public static ResourceRequest LoadAsync<T>(string path) where T : Object { return Resources.LoadAsync(path, typeof(T)); } /// <summary> /// <para>Asynchronously loads an asset stored at path in a Resources folder.</para> /// </summary> /// <param name="path">Pathname of the target folder. When using the empty string (i.e., ""), the function will load the entire contents of the Resources folder.</param> /// <param name="systemTypeInstance">Type filter for objects returned.</param> /// <param name="type"></param> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public static extern ResourceRequest LoadAsync(string path, Type type); /// <summary> /// <para>Loads all assets in a folder or file at path in a Resources folder.</para> /// </summary> /// <param name="path">Pathname of the target folder. When using the empty string (i.e., ""), the function will load the entire contents of the Resources folder.</param> /// <param name="systemTypeInstance">Type filter for objects returned.</param> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public static extern Object[] LoadAll(string path, Type systemTypeInstance); /// <summary> /// <para>Loads all assets in a folder or file at path in a Resources folder.</para> /// </summary> /// <param name="path">Pathname of the target folder. When using the empty string (i.e., ""), the function will load the entire contents of the Resources folder.</param> public static Object[] LoadAll(string path) { return Resources.LoadAll(path, typeof(Object)); } public static T[] LoadAll<T>(string path) where T : Object { return Resources.ConvertObjects<T>(Resources.LoadAll(path, typeof(T))); } [GeneratedByOldBindingsGenerator, TypeInferenceRule(TypeInferenceRules.TypeReferencedByFirstArgument)] [MethodImpl(MethodImplOptions.InternalCall)] public static extern Object GetBuiltinResource(Type type, string path); public static T GetBuiltinResource<T>(string path) where T : Object { return (T)((object)Resources.GetBuiltinResource(typeof(T), path)); } /// <summary> /// <para>Unloads assetToUnload from memory.</para> /// </summary> /// <param name="assetToUnload"></param> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public static extern void UnloadAsset(Object assetToUnload); /// <summary> /// <para>Unloads assets that are not used.</para> /// </summary> /// <returns> /// <para>Object on which you can yield to wait until the operation completes.</para> /// </returns> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public static extern AsyncOperation UnloadUnusedAssets(); /// <summary> /// <para>Returns a resource at an asset path (Editor Only).</para> /// </summary> /// <param name="assetPath">Pathname of the target asset.</param> /// <param name="type">Type filter for objects returned.</param> [Obsolete("Use AssetDatabase.LoadAssetAtPath instead (UnityUpgradable) -> * [UnityEditor] UnityEditor.AssetDatabase.LoadAssetAtPath(*)", true), TypeInferenceRule(TypeInferenceRules.TypeReferencedBySecondArgument)] public static Object LoadAssetAtPath(string assetPath, Type type) { return null; } [Obsolete("Use AssetDatabase.LoadAssetAtPath<T>() instead (UnityUpgradable) -> * [UnityEditor] UnityEditor.AssetDatabase.LoadAssetAtPath<T>(*)", true)] public static T LoadAssetAtPath<T>(string assetPath) where T : Object { return (T)((object)null); } } }
Resources
S:
using System; namespace UnityEngine { /// <summary> /// <para>The coordinate space in which to operate.</para> /// </summary> public enum Space { /// <summary> /// <para>Applies transformation relative to the world coordinate system.</para> /// </summary> World, /// <summary> /// <para>Applies transformation relative to the local coordinate system.</para> /// </summary> Self } }
Space
T:
using System; using System.Collections; using System.Runtime.CompilerServices; using UnityEngine.Internal; using UnityEngine.Scripting; namespace UnityEngine { /// <summary> /// <para>Position, rotation and scale of an object.</para> /// </summary> public class Transform : Component, IEnumerable { private sealed class Enumerator : IEnumerator { private Transform outer; ; public object Current { get { return this.outer.GetChild(this.currentIndex); } } internal Enumerator(Transform outer) { this.outer = outer; } public bool MoveNext() { int childCount = this.outer.childCount; return ++this.currentIndex < childCount; } public void Reset() { ; } } /// <summary> /// <para>The position of the transform in world space.</para> /// </summary> public Vector3 position { get { Vector3 result; this.INTERNAL_get_position(out result); return result; } set { this.INTERNAL_set_position(ref value); } } /// <summary> /// <para>Position of the transform relative to the parent transform.</para> /// </summary> public Vector3 localPosition { get { Vector3 result; this.INTERNAL_get_localPosition(out result); return result; } set { this.INTERNAL_set_localPosition(ref value); } } /// <summary> /// <para>The rotation as Euler angles in degrees.</para> /// </summary> public Vector3 eulerAngles { get { return this.rotation.eulerAngles; } set { this.rotation = Quaternion.Euler(value); } } /// <summary> /// <para>The rotation as Euler angles in degrees relative to the parent transform's rotation.</para> /// </summary> public Vector3 localEulerAngles { get { return this.localRotation.eulerAngles; } set { this.localRotation = Quaternion.Euler(value); } } /// <summary> /// <para>The red axis of the transform in world space.</para> /// </summary> public Vector3 right { get { return this.rotation * Vector3.right; } set { this.rotation = Quaternion.FromToRotation(Vector3.right, value); } } /// <summary> /// <para>The green axis of the transform in world space.</para> /// </summary> public Vector3 up { get { return this.rotation * Vector3.up; } set { this.rotation = Quaternion.FromToRotation(Vector3.up, value); } } /// <summary> /// <para>The blue axis of the transform in world space.</para> /// </summary> public Vector3 forward { get { return this.rotation * Vector3.forward; } set { this.rotation = Quaternion.LookRotation(value); } } /// <summary> /// <para>The rotation of the transform in world space stored as a Quaternion.</para> /// </summary> public Quaternion rotation { get { Quaternion result; this.INTERNAL_get_rotation(out result); return result; } set { this.INTERNAL_set_rotation(ref value); } } /// <summary> /// <para>The rotation of the transform relative to the parent transform's rotation.</para> /// </summary> public Quaternion localRotation { get { Quaternion result; this.INTERNAL_get_localRotation(out result); return result; } set { this.INTERNAL_set_localRotation(ref value); } } internal extern RotationOrder rotationOrder { [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] get; [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] set; } /// <summary> /// <para>The scale of the transform relative to the parent.</para> /// </summary> public Vector3 localScale { get { Vector3 result; this.INTERNAL_get_localScale(out result); return result; } set { this.INTERNAL_set_localScale(ref value); } } /// <summary> /// <para>The parent of the transform.</para> /// </summary> public Transform parent { get { return this.parentInternal; } set { if (this is RectTransform) { Debug.LogWarning("Parent of RectTransform is being set with parent property. Consider using the SetParent method instead, with the worldPositionStays argument set to false. This will retain local orientation and scale rather than world orientation and scale, which can prevent common UI scaling issues.", this); } this.parentInternal = value; } } internal extern Transform parentInternal { [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] get; [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] set; } /// <summary> /// <para>Matrix that transforms a point from world space into local space (Read Only).</para> /// </summary> public Matrix4x4 worldToLocalMatrix { get { Matrix4x4 result; this.INTERNAL_get_worldToLocalMatrix(out result); return result; } } /// <summary> /// <para>Matrix that transforms a point from local space into world space (Read Only).</para> /// </summary> public Matrix4x4 localToWorldMatrix { get { Matrix4x4 result; this.INTERNAL_get_localToWorldMatrix(out result); return result; } } /// <summary> /// <para>Returns the topmost transform in the hierarchy.</para> /// </summary> public extern Transform root { [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] get; } /// <summary> /// <para>The number of children the Transform has.</para> /// </summary> public extern int childCount { [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] get; } /// <summary> /// <para>The global scale of the object (Read Only).</para> /// </summary> public Vector3 lossyScale { get { Vector3 result; this.INTERNAL_get_lossyScale(out result); return result; } } /// <summary> /// <para>Has the transform changed since the last time the flag was set to 'false'?</para> /// </summary> public extern bool hasChanged { [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] get; [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] set; } /// <summary> /// <para>The transform capacity of the transform's hierarchy data structure.</para> /// </summary> public extern int hierarchyCapacity { [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] get; [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] set; } /// <summary> /// <para>The number of transforms in the transform's hierarchy data structure.</para> /// </summary> public extern int hierarchyCount { [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] get; } protected Transform() { } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private extern void INTERNAL_get_position(out Vector3 value); [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private extern void INTERNAL_set_position(ref Vector3 value); [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private extern void INTERNAL_get_localPosition(out Vector3 value); [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private extern void INTERNAL_set_localPosition(ref Vector3 value); internal Vector3 GetLocalEulerAngles(RotationOrder order) { Vector3 result; Transform.INTERNAL_CALL_GetLocalEulerAngles(this, order, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_GetLocalEulerAngles(Transform self, RotationOrder order, out Vector3 value); internal void SetLocalEulerAngles(Vector3 euler, RotationOrder order) { Transform.INTERNAL_CALL_SetLocalEulerAngles(this, ref euler, order); } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_SetLocalEulerAngles(Transform self, ref Vector3 euler, RotationOrder order); internal void SetLocalEulerHint(Vector3 euler) { Transform.INTERNAL_CALL_SetLocalEulerHint(this, ref euler); } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_SetLocalEulerHint(Transform self, ref Vector3 euler); [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private extern void INTERNAL_get_rotation(out Quaternion value); [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private extern void INTERNAL_set_rotation(ref Quaternion value); [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private extern void INTERNAL_get_localRotation(out Quaternion value); [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private extern void INTERNAL_set_localRotation(ref Quaternion value); [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private extern void INTERNAL_get_localScale(out Vector3 value); [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private extern void INTERNAL_set_localScale(ref Vector3 value); /// <summary> /// <para>Set the parent of the transform.</para> /// </summary> /// <param name="parent">The parent Transform to use.</param> /// <param name="worldPositionStays">If true, the parent-relative position, scale and /// rotation are modified such that the object keeps the same world space position, /// rotation and scale as before.</param> public void SetParent(Transform parent) { this.SetParent(parent, true); } /// <summary> /// <para>Set the parent of the transform.</para> /// </summary> /// <param name="parent">The parent Transform to use.</param> /// <param name="worldPositionStays">If true, the parent-relative position, scale and /// rotation are modified such that the object keeps the same world space position, /// rotation and scale as before.</param> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public extern void SetParent(Transform parent, bool worldPositionStays); [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private extern void INTERNAL_get_worldToLocalMatrix(out Matrix4x4 value); [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private extern void INTERNAL_get_localToWorldMatrix(out Matrix4x4 value); /// <summary> /// <para>Sets the world space position and rotation of the Transform component.</para> /// </summary> /// <param name="position"></param> /// <param name="rotation"></param> public void SetPositionAndRotation(Vector3 position, Quaternion rotation) { Transform.INTERNAL_CALL_SetPositionAndRotation(this, ref position, ref rotation); } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_SetPositionAndRotation(Transform self, ref Vector3 position, ref Quaternion rotation); /// <summary> /// <para>Moves the transform in the direction and distance of translation.</para> /// </summary> /// <param name="translation"></param> /// <param name="relativeTo"></param> [ExcludeFromDocs] public void Translate(Vector3 translation) { Space relativeTo = Space.Self; this.Translate(translation, relativeTo); } /// <summary> /// <para>Moves the transform in the direction and distance of translation.</para> /// </summary> /// <param name="translation"></param> /// <param name="relativeTo"></param> public void Translate(Vector3 translation, [DefaultValue("Space.Self")] Space relativeTo) { if (relativeTo == Space.World) { this.position += translation; } else { this.position += this.TransformDirection(translation); } } /// <summary> /// <para>Moves the transform by x along the x axis, y along the y axis, and z along the z axis.</para> /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> /// <param name="relativeTo"></param> [ExcludeFromDocs] public void Translate(float x, float y, float z) { Space relativeTo = Space.Self; this.Translate(x, y, z, relativeTo); } /// <summary> /// <para>Moves the transform by x along the x axis, y along the y axis, and z along the z axis.</para> /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> /// <param name="relativeTo"></param> public void Translate(float x, float y, float z, [DefaultValue("Space.Self")] Space relativeTo) { this.Translate(new Vector3(x, y, z), relativeTo); } /// <summary> /// <para>Moves the transform in the direction and distance of translation.</para> /// </summary> /// <param name="translation"></param> /// <param name="relativeTo"></param> public void Translate(Vector3 translation, Transform relativeTo) { if (relativeTo) { this.position += relativeTo.TransformDirection(translation); } else { this.position += translation; } } /// <summary> /// <para>Moves the transform by x along the x axis, y along the y axis, and z along the z axis.</para> /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> /// <param name="relativeTo"></param> public void Translate(float x, float y, float z, Transform relativeTo) { this.Translate(new Vector3(x, y, z), relativeTo); } [ExcludeFromDocs] public void Rotate(Vector3 eulerAngles) { Space relativeTo = Space.Self; this.Rotate(eulerAngles, relativeTo); } /// <summary> /// <para>Applies a rotation of eulerAngles.z degrees around the z axis, eulerAngles.x degrees around the x axis, and eulerAngles.y degrees around the y axis (in that order).</para> /// </summary> /// <param name="eulerAngles">Rotation to apply.</param> /// <param name="relativeTo">Rotation is local to object or World.</param> public void Rotate(Vector3 eulerAngles, [DefaultValue("Space.Self")] Space relativeTo) { Quaternion rhs = Quaternion.Euler(eulerAngles.x, eulerAngles.y, eulerAngles.z); if (relativeTo == Space.Self) { this.localRotation *= rhs; } else { this.rotation *= Quaternion.Inverse(this.rotation) * rhs * this.rotation; } } [ExcludeFromDocs] public void Rotate(float xAngle, float yAngle, float zAngle) { Space relativeTo = Space.Self; this.Rotate(xAngle, yAngle, zAngle, relativeTo); } /// <summary> /// <para>Applies a rotation of zAngle degrees around the z axis, xAngle degrees around the x axis, and yAngle degrees around the y axis (in that order).</para> /// </summary> /// <param name="xAngle">Degrees to rotate around the X axis.</param> /// <param name="yAngle">Degrees to rotate around the Y axis.</param> /// <param name="zAngle">Degrees to rotate around the Z axis.</param> /// <param name="relativeTo">Rotation is local to object or World.</param> public void Rotate(float xAngle, float yAngle, float zAngle, [DefaultValue("Space.Self")] Space relativeTo) { this.Rotate(new Vector3(xAngle, yAngle, zAngle), relativeTo); } internal void RotateAroundInternal(Vector3 axis, float angle) { Transform.INTERNAL_CALL_RotateAroundInternal(this, ref axis, angle); } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_RotateAroundInternal(Transform self, ref Vector3 axis, float angle); [ExcludeFromDocs] public void Rotate(Vector3 axis, float angle) { Space relativeTo = Space.Self; this.Rotate(axis, angle, relativeTo); } /// <summary> /// <para>Rotates the object around axis by angle degrees.</para> /// </summary> /// <param name="axis">Axis to apply rotation to.</param> /// <param name="angle">Degrees to rotation to apply.</param> /// <param name="relativeTo">Rotation is local to object or World.</param> public void Rotate(Vector3 axis, float angle, [DefaultValue("Space.Self")] Space relativeTo) { if (relativeTo == Space.Self) { this.RotateAroundInternal(base.transform.TransformDirection(axis), angle * 0.0174532924f); } else { this.RotateAroundInternal(axis, angle * 0.0174532924f); } } /// <summary> /// <para>Rotates the transform about axis passing through point in world coordinates by angle degrees.</para> /// </summary> /// <param name="point"></param> /// <param name="axis"></param> /// <param name="angle"></param> public void RotateAround(Vector3 point, Vector3 axis, float angle) { Vector3 vector = this.position; Quaternion rotation = Quaternion.AngleAxis(angle, axis); Vector3 vector2 = vector - point; vector2 = rotation * vector2; vector = point + vector2; this.position = vector; this.RotateAroundInternal(axis, angle * 0.0174532924f); } /// <summary> /// <para>Rotates the transform so the forward vector points at target's current position.</para> /// </summary> /// <param name="target">Object to point towards.</param> /// <param name="worldUp">Vector specifying the upward direction.</param> [ExcludeFromDocs] public void LookAt(Transform target) { Vector3 up = Vector3.up; this.LookAt(target, up); } /// <summary> /// <para>Rotates the transform so the forward vector points at target's current position.</para> /// </summary> /// <param name="target">Object to point towards.</param> /// <param name="worldUp">Vector specifying the upward direction.</param> public void LookAt(Transform target, [DefaultValue("Vector3.up")] Vector3 worldUp) { if (target) { this.LookAt(target.position, worldUp); } } /// <summary> /// <para>Rotates the transform so the forward vector points at worldPosition.</para> /// </summary> /// <param name="worldPosition">Point to look at.</param> /// <param name="worldUp">Vector specifying the upward direction.</param> public void LookAt(Vector3 worldPosition, [DefaultValue("Vector3.up")] Vector3 worldUp) { Transform.INTERNAL_CALL_LookAt(this, ref worldPosition, ref worldUp); } /// <summary> /// <para>Rotates the transform so the forward vector points at worldPosition.</para> /// </summary> /// <param name="worldPosition">Point to look at.</param> /// <param name="worldUp">Vector specifying the upward direction.</param> [ExcludeFromDocs] public void LookAt(Vector3 worldPosition) { Vector3 up = Vector3.up; Transform.INTERNAL_CALL_LookAt(this, ref worldPosition, ref up); } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_LookAt(Transform self, ref Vector3 worldPosition, ref Vector3 worldUp); /// <summary> /// <para>Transforms direction from local space to world space.</para> /// </summary> /// <param name="direction"></param> public Vector3 TransformDirection(Vector3 direction) { Vector3 result; Transform.INTERNAL_CALL_TransformDirection(this, ref direction, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_TransformDirection(Transform self, ref Vector3 direction, out Vector3 value); /// <summary> /// <para>Transforms direction x, y, z from local space to world space.</para> /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> public Vector3 TransformDirection(float x, float y, float z) { return this.TransformDirection(new Vector3(x, y, z)); } /// <summary> /// <para>Transforms a direction from world space to local space. The opposite of Transform.TransformDirection.</para> /// </summary> /// <param name="direction"></param> public Vector3 InverseTransformDirection(Vector3 direction) { Vector3 result; Transform.INTERNAL_CALL_InverseTransformDirection(this, ref direction, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_InverseTransformDirection(Transform self, ref Vector3 direction, out Vector3 value); /// <summary> /// <para>Transforms the direction x, y, z from world space to local space. The opposite of Transform.TransformDirection.</para> /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> public Vector3 InverseTransformDirection(float x, float y, float z) { return this.InverseTransformDirection(new Vector3(x, y, z)); } /// <summary> /// <para>Transforms vector from local space to world space.</para> /// </summary> /// <param name="vector"></param> public Vector3 TransformVector(Vector3 vector) { Vector3 result; Transform.INTERNAL_CALL_TransformVector(this, ref vector, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_TransformVector(Transform self, ref Vector3 vector, out Vector3 value); /// <summary> /// <para>Transforms vector x, y, z from local space to world space.</para> /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> public Vector3 TransformVector(float x, float y, float z) { return this.TransformVector(new Vector3(x, y, z)); } /// <summary> /// <para>Transforms a vector from world space to local space. The opposite of Transform.TransformVector.</para> /// </summary> /// <param name="vector"></param> public Vector3 InverseTransformVector(Vector3 vector) { Vector3 result; Transform.INTERNAL_CALL_InverseTransformVector(this, ref vector, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_InverseTransformVector(Transform self, ref Vector3 vector, out Vector3 value); /// <summary> /// <para>Transforms the vector x, y, z from world space to local space. The opposite of Transform.TransformVector.</para> /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> public Vector3 InverseTransformVector(float x, float y, float z) { return this.InverseTransformVector(new Vector3(x, y, z)); } /// <summary> /// <para>Transforms position from local space to world space.</para> /// </summary> /// <param name="position"></param> public Vector3 TransformPoint(Vector3 position) { Vector3 result; Transform.INTERNAL_CALL_TransformPoint(this, ref position, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_TransformPoint(Transform self, ref Vector3 position, out Vector3 value); /// <summary> /// <para>Transforms the position x, y, z from local space to world space.</para> /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> public Vector3 TransformPoint(float x, float y, float z) { return this.TransformPoint(new Vector3(x, y, z)); } /// <summary> /// <para>Transforms position from world space to local space.</para> /// </summary> /// <param name="position"></param> public Vector3 InverseTransformPoint(Vector3 position) { Vector3 result; Transform.INTERNAL_CALL_InverseTransformPoint(this, ref position, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_InverseTransformPoint(Transform self, ref Vector3 position, out Vector3 value); /// <summary> /// <para>Transforms the position x, y, z from world space to local space. The opposite of Transform.TransformPoint.</para> /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> public Vector3 InverseTransformPoint(float x, float y, float z) { return this.InverseTransformPoint(new Vector3(x, y, z)); } /// <summary> /// <para>Unparents all children.</para> /// </summary> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public extern void DetachChildren(); /// <summary> /// <para>Move the transform to the start of the local transform list.</para> /// </summary> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public extern void SetAsFirstSibling(); /// <summary> /// <para>Move the transform to the end of the local transform list.</para> /// </summary> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public extern void SetAsLastSibling(); /// <summary> /// <para>Sets the sibling index.</para> /// </summary> /// <param name="index">Index to set.</param> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public extern void SetSiblingIndex(int index); /// <summary> /// <para>Gets the sibling index.</para> /// </summary> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public extern int GetSiblingIndex(); /// <summary> /// <para>Finds a child by name and returns it.</para> /// </summary> /// <param name="name">Name of child to be found.</param> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public extern Transform Find(string name); [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] internal extern void SendTransformChangedScale(); [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private extern void INTERNAL_get_lossyScale(out Vector3 value); /// <summary> /// <para>Is this transform a child of parent?</para> /// </summary> /// <param name="parent"></param> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public extern bool IsChildOf(Transform parent); [Obsolete("FindChild has been deprecated. Use Find instead (UnityUpgradable) -> Find([mscorlib] System.String)", false)] public Transform FindChild(string name) { return this.Find(name); } public IEnumerator GetEnumerator() { return new Transform.Enumerator(this); } /// <summary> /// <para></para> /// </summary> /// <param name="axis"></param> /// <param name="angle"></param> [Obsolete("use Transform.Rotate instead.")] public void RotateAround(Vector3 axis, float angle) { Transform.INTERNAL_CALL_RotateAround(this, ref axis, angle); } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_RotateAround(Transform self, ref Vector3 axis, float angle); [Obsolete("use Transform.Rotate instead.")] public void RotateAroundLocal(Vector3 axis, float angle) { Transform.INTERNAL_CALL_RotateAroundLocal(this, ref axis, angle); } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_RotateAroundLocal(Transform self, ref Vector3 axis, float angle); /// <summary> /// <para>Returns a transform child by index.</para> /// </summary> /// <param name="index">Index of the child transform to return. Must be smaller than Transform.childCount.</param> /// <returns> /// <para>Transform child by index.</para> /// </returns> [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public extern Transform GetChild(int index); [Obsolete("use Transform.childCount instead."), GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] public extern int GetChildCount(); [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] internal extern bool IsNonUniformScaleTransform(); } }
Transform
U:
V:
using System; using UnityEngine.Scripting; namespace UnityEngine { /// <summary> /// <para>Representation of 2D vectors and points.</para> /// </summary> [UsedByNativeCode] public struct Vector2 { /// <summary> /// <para>X component of the vector.</para> /// </summary> public float x; /// <summary> /// <para>Y component of the vector.</para> /// </summary> public float y; public const float kEpsilon = 1E-05f; public float this[int index] { get { float result; ) { ) { throw new IndexOutOfRangeException("Invalid Vector2 index!"); } result = this.y; } else { result = this.x; } return result; } set { ) { ) { throw new IndexOutOfRangeException("Invalid Vector2 index!"); } this.y = value; } else { this.x = value; } } } /// <summary> /// <para>Returns this vector with a magnitude of 1 (Read Only).</para> /// </summary> public Vector2 normalized { get { Vector2 result = new Vector2(this.x, this.y); result.Normalize(); return result; } } /// <summary> /// <para>Returns the length of this vector (Read Only).</para> /// </summary> public float magnitude { get { return Mathf.Sqrt(this.x * this.x + this.y * this.y); } } /// <summary> /// <para>Returns the squared length of this vector (Read Only).</para> /// </summary> public float sqrMagnitude { get { return this.x * this.x + this.y * this.y; } } /// <summary> /// <para>Shorthand for writing Vector2(0, 0).</para> /// </summary> public static Vector2 zero { get { return new Vector2(0f, 0f); } } /// <summary> /// <para>Shorthand for writing Vector2(1, 1).</para> /// </summary> public static Vector2 one { get { return new Vector2(1f, 1f); } } /// <summary> /// <para>Shorthand for writing Vector2(0, 1).</para> /// </summary> public static Vector2 up { get { return new Vector2(0f, 1f); } } /// <summary> /// <para>Shorthand for writing Vector2(0, -1).</para> /// </summary> public static Vector2 down { get { return new Vector2(0f, -1f); } } /// <summary> /// <para>Shorthand for writing Vector2(-1, 0).</para> /// </summary> public static Vector2 left { get { return new Vector2(-1f, 0f); } } /// <summary> /// <para>Shorthand for writing Vector2(1, 0).</para> /// </summary> public static Vector2 right { get { return new Vector2(1f, 0f); } } /// <summary> /// <para>Constructs a new vector with given x, y components.</para> /// </summary> /// <param name="x"></param> /// <param name="y"></param> public Vector2(float x, float y) { this.x = x; this.y = y; } /// <summary> /// <para>Set x and y components of an existing Vector2.</para> /// </summary> /// <param name="newX"></param> /// <param name="newY"></param> public void Set(float newX, float newY) { this.x = newX; this.y = newY; } /// <summary> /// <para>Linearly interpolates between vectors a and b by t.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="t"></param> public static Vector2 Lerp(Vector2 a, Vector2 b, float t) { t = Mathf.Clamp01(t); return new Vector2(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t); } /// <summary> /// <para>Linearly interpolates between vectors a and b by t.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="t"></param> public static Vector2 LerpUnclamped(Vector2 a, Vector2 b, float t) { return new Vector2(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t); } /// <summary> /// <para>Moves a point current towards target.</para> /// </summary> /// <param name="current"></param> /// <param name="target"></param> /// <param name="maxDistanceDelta"></param> public static Vector2 MoveTowards(Vector2 current, Vector2 target, float maxDistanceDelta) { Vector2 a = target - current; float magnitude = a.magnitude; Vector2 result; if (magnitude <= maxDistanceDelta || magnitude == 0f) { result = target; } else { result = current + a / magnitude * maxDistanceDelta; } return result; } /// <summary> /// <para>Multiplies two vectors component-wise.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> public static Vector2 Scale(Vector2 a, Vector2 b) { return new Vector2(a.x * b.x, a.y * b.y); } /// <summary> /// <para>Multiplies every component of this vector by the same component of scale.</para> /// </summary> /// <param name="scale"></param> public void Scale(Vector2 scale) { this.x *= scale.x; this.y *= scale.y; } /// <summary> /// <para>Makes this vector have a magnitude of 1.</para> /// </summary> public void Normalize() { float magnitude = this.magnitude; if (magnitude > 1E-05f) { this /= magnitude; } else { this = Vector2.zero; } } /// <summary> /// <para>Returns a nicely formatted string for this vector.</para> /// </summary> /// <param name="format"></param> public override string ToString() { return UnityString.Format("({0:F1}, {1:F1})", new object[] { this.x, this.y }); } /// <summary> /// <para>Returns a nicely formatted string for this vector.</para> /// </summary> /// <param name="format"></param> public string ToString(string format) { return UnityString.Format("({0}, {1})", new object[] { this.x.ToString(format), this.y.ToString(format) }); } public override int GetHashCode() { ; } /// <summary> /// <para>Returns true if the given vector is exactly equal to this vector.</para> /// </summary> /// <param name="other"></param> public override bool Equals(object other) { bool result; if (!(other is Vector2)) { result = false; } else { Vector2 vector = (Vector2)other; result = (this.x.Equals(vector.x) && this.y.Equals(vector.y)); } return result; } /// <summary> /// <para>Reflects a vector off the vector defined by a normal.</para> /// </summary> /// <param name="inDirection"></param> /// <param name="inNormal"></param> public static Vector2 Reflect(Vector2 inDirection, Vector2 inNormal) { return -2f * Vector2.Dot(inNormal, inDirection) * inNormal + inDirection; } /// <summary> /// <para>Dot Product of two vectors.</para> /// </summary> /// <param name="lhs"></param> /// <param name="rhs"></param> public static float Dot(Vector2 lhs, Vector2 rhs) { return lhs.x * rhs.x + lhs.y * rhs.y; } /// <summary> /// <para>Returns the angle in degrees between from and to.</para> /// </summary> /// <param name="from"></param> /// <param name="to"></param> public static float Angle(Vector2 from, Vector2 to) { return Mathf.Acos(Mathf.Clamp(Vector2.Dot(from.normalized, to.normalized), -1f, 1f)) * 57.29578f; } /// <summary> /// <para>Returns the distance between a and b.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> public static float Distance(Vector2 a, Vector2 b) { return (a - b).magnitude; } /// <summary> /// <para>Returns a copy of vector with its magnitude clamped to maxLength.</para> /// </summary> /// <param name="vector"></param> /// <param name="maxLength"></param> public static Vector2 ClampMagnitude(Vector2 vector, float maxLength) { Vector2 result; if (vector.sqrMagnitude > maxLength * maxLength) { result = vector.normalized * maxLength; } else { result = vector; } return result; } public static float SqrMagnitude(Vector2 a) { return a.x * a.x + a.y * a.y; } public float SqrMagnitude() { return this.x * this.x + this.y * this.y; } /// <summary> /// <para>Returns a vector that is made from the smallest components of two vectors.</para> /// </summary> /// <param name="lhs"></param> /// <param name="rhs"></param> public static Vector2 Min(Vector2 lhs, Vector2 rhs) { return new Vector2(Mathf.Min(lhs.x, rhs.x), Mathf.Min(lhs.y, rhs.y)); } /// <summary> /// <para>Returns a vector that is made from the largest components of two vectors.</para> /// </summary> /// <param name="lhs"></param> /// <param name="rhs"></param> public static Vector2 Max(Vector2 lhs, Vector2 rhs) { return new Vector2(Mathf.Max(lhs.x, rhs.x), Mathf.Max(lhs.y, rhs.y)); } public static Vector2 SmoothDamp(Vector2 current, Vector2 target, ref Vector2 currentVelocity, float smoothTime, float maxSpeed, float deltaTime) { smoothTime = Mathf.Max(0.0001f, smoothTime); float num = 2f / smoothTime; float num2 = num * deltaTime; float d = 1f / (1f + num2 + 0.48f * num2 * num2 + 0.235f * num2 * num2 * num2); Vector2 vector = current - target; Vector2 vector2 = target; float maxLength = maxSpeed * smoothTime; vector = Vector2.ClampMagnitude(vector, maxLength); target = current - vector; Vector2 vector3 = (currentVelocity + num * vector) * deltaTime; currentVelocity = (currentVelocity - num * vector3) * d; Vector2 vector4 = target + (vector + vector3) * d; if (Vector2.Dot(vector2 - current, vector4 - vector2) > 0f) { vector4 = vector2; currentVelocity = (vector4 - vector2) / deltaTime; } return vector4; } public static Vector2 operator +(Vector2 a, Vector2 b) { return new Vector2(a.x + b.x, a.y + b.y); } public static Vector2 operator -(Vector2 a, Vector2 b) { return new Vector2(a.x - b.x, a.y - b.y); } public static Vector2 operator -(Vector2 a) { return new Vector2(-a.x, -a.y); } public static Vector2 operator *(Vector2 a, float d) { return new Vector2(a.x * d, a.y * d); } public static Vector2 operator *(float d, Vector2 a) { return new Vector2(a.x * d, a.y * d); } public static Vector2 operator /(Vector2 a, float d) { return new Vector2(a.x / d, a.y / d); } public static bool operator ==(Vector2 lhs, Vector2 rhs) { return (lhs - rhs).sqrMagnitude < 9.99999944E-11f; } public static bool operator !=(Vector2 lhs, Vector2 rhs) { return !(lhs == rhs); } public static implicit operator Vector2(Vector3 v) { return new Vector2(v.x, v.y); } public static implicit operator Vector3(Vector2 v) { return new Vector3(v.x, v.y, 0f); } } }
Vector2
using System; using System.Runtime.CompilerServices; using UnityEngine.Internal; using UnityEngine.Scripting; namespace UnityEngine { /// <summary> /// <para>Representation of 3D vectors and points.</para> /// </summary> [UsedByNativeCode] public struct Vector3 { public const float kEpsilon = 1E-05f; /// <summary> /// <para>X component of the vector.</para> /// </summary> public float x; /// <summary> /// <para>Y component of the vector.</para> /// </summary> public float y; /// <summary> /// <para>Z component of the vector.</para> /// </summary> public float z; public float this[int index] { get { float result; switch (index) { : result = this.x; break; : result = this.y; break; : result = this.z; break; default: throw new IndexOutOfRangeException("Invalid Vector3 index!"); } return result; } set { switch (index) { : this.x = value; break; : this.y = value; break; : this.z = value; break; default: throw new IndexOutOfRangeException("Invalid Vector3 index!"); } } } /// <summary> /// <para>Returns this vector with a magnitude of 1 (Read Only).</para> /// </summary> public Vector3 normalized { get { return Vector3.Normalize(this); } } /// <summary> /// <para>Returns the length of this vector (Read Only).</para> /// </summary> public float magnitude { get { return Mathf.Sqrt(this.x * this.x + this.y * this.y + this.z * this.z); } } /// <summary> /// <para>Returns the squared length of this vector (Read Only).</para> /// </summary> public float sqrMagnitude { get { return this.x * this.x + this.y * this.y + this.z * this.z; } } /// <summary> /// <para>Shorthand for writing Vector3(0, 0, 0).</para> /// </summary> public static Vector3 zero { get { return new Vector3(0f, 0f, 0f); } } /// <summary> /// <para>Shorthand for writing Vector3(1, 1, 1).</para> /// </summary> public static Vector3 one { get { return new Vector3(1f, 1f, 1f); } } /// <summary> /// <para>Shorthand for writing Vector3(0, 0, 1).</para> /// </summary> public static Vector3 forward { get { return new Vector3(0f, 0f, 1f); } } /// <summary> /// <para>Shorthand for writing Vector3(0, 0, -1).</para> /// </summary> public static Vector3 back { get { return new Vector3(0f, 0f, -1f); } } /// <summary> /// <para>Shorthand for writing Vector3(0, 1, 0).</para> /// </summary> public static Vector3 up { get { return new Vector3(0f, 1f, 0f); } } /// <summary> /// <para>Shorthand for writing Vector3(0, -1, 0).</para> /// </summary> public static Vector3 down { get { return new Vector3(0f, -1f, 0f); } } /// <summary> /// <para>Shorthand for writing Vector3(-1, 0, 0).</para> /// </summary> public static Vector3 left { get { return new Vector3(-1f, 0f, 0f); } } /// <summary> /// <para>Shorthand for writing Vector3(1, 0, 0).</para> /// </summary> public static Vector3 right { get { return new Vector3(1f, 0f, 0f); } } [Obsolete("Use Vector3.forward instead.")] public static Vector3 fwd { get { return new Vector3(0f, 0f, 1f); } } /// <summary> /// <para>Creates a new vector with given x, y, z components.</para> /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> public Vector3(float x, float y, float z) { this.x = x; this.y = y; this.z = z; } /// <summary> /// <para>Creates a new vector with given x, y components and sets z to zero.</para> /// </summary> /// <param name="x"></param> /// <param name="y"></param> public Vector3(float x, float y) { this.x = x; this.y = y; this.z = 0f; } /// <summary> /// <para>Spherically interpolates between two vectors.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="t"></param> [ThreadAndSerializationSafe] public static Vector3 Slerp(Vector3 a, Vector3 b, float t) { Vector3 result; Vector3.INTERNAL_CALL_Slerp(ref a, ref b, t, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_Slerp(ref Vector3 a, ref Vector3 b, float t, out Vector3 value); /// <summary> /// <para>Spherically interpolates between two vectors.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="t"></param> public static Vector3 SlerpUnclamped(Vector3 a, Vector3 b, float t) { Vector3 result; Vector3.INTERNAL_CALL_SlerpUnclamped(ref a, ref b, t, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_SlerpUnclamped(ref Vector3 a, ref Vector3 b, float t, out Vector3 value); private static void Internal_OrthoNormalize2(ref Vector3 a, ref Vector3 b) { Vector3.INTERNAL_CALL_Internal_OrthoNormalize2(ref a, ref b); } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_Internal_OrthoNormalize2(ref Vector3 a, ref Vector3 b); private static void Internal_OrthoNormalize3(ref Vector3 a, ref Vector3 b, ref Vector3 c) { Vector3.INTERNAL_CALL_Internal_OrthoNormalize3(ref a, ref b, ref c); } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_Internal_OrthoNormalize3(ref Vector3 a, ref Vector3 b, ref Vector3 c); public static void OrthoNormalize(ref Vector3 normal, ref Vector3 tangent) { Vector3.Internal_OrthoNormalize2(ref normal, ref tangent); } public static void OrthoNormalize(ref Vector3 normal, ref Vector3 tangent, ref Vector3 binormal) { Vector3.Internal_OrthoNormalize3(ref normal, ref tangent, ref binormal); } /// <summary> /// <para>Rotates a vector current towards target.</para> /// </summary> /// <param name="current"></param> /// <param name="target"></param> /// <param name="maxRadiansDelta"></param> /// <param name="maxMagnitudeDelta"></param> public static Vector3 RotateTowards(Vector3 current, Vector3 target, float maxRadiansDelta, float maxMagnitudeDelta) { Vector3 result; Vector3.INTERNAL_CALL_RotateTowards(ref current, ref target, maxRadiansDelta, maxMagnitudeDelta, out result); return result; } [GeneratedByOldBindingsGenerator] [MethodImpl(MethodImplOptions.InternalCall)] private static extern void INTERNAL_CALL_RotateTowards(ref Vector3 current, ref Vector3 target, float maxRadiansDelta, float maxMagnitudeDelta, out Vector3 value); [Obsolete("Use Vector3.ProjectOnPlane instead.")] public static Vector3 Exclude(Vector3 excludeThis, Vector3 fromThat) { return fromThat - Vector3.Project(fromThat, excludeThis); } /// <summary> /// <para>Linearly interpolates between two vectors.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="t"></param> public static Vector3 Lerp(Vector3 a, Vector3 b, float t) { t = Mathf.Clamp01(t); return new Vector3(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t); } /// <summary> /// <para>Linearly interpolates between two vectors.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="t"></param> public static Vector3 LerpUnclamped(Vector3 a, Vector3 b, float t) { return new Vector3(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t); } /// <summary> /// <para>Moves a point current in a straight line towards a target point.</para> /// </summary> /// <param name="current"></param> /// <param name="target"></param> /// <param name="maxDistanceDelta"></param> public static Vector3 MoveTowards(Vector3 current, Vector3 target, float maxDistanceDelta) { Vector3 a = target - current; float magnitude = a.magnitude; Vector3 result; if (magnitude <= maxDistanceDelta || magnitude == 0f) { result = target; } else { result = current + a / magnitude * maxDistanceDelta; } return result; } [ExcludeFromDocs] public static Vector3 SmoothDamp(Vector3 current, Vector3 target, ref Vector3 currentVelocity, float smoothTime, float maxSpeed) { float deltaTime = Time.deltaTime; return Vector3.SmoothDamp(current, target, ref currentVelocity, smoothTime, maxSpeed, deltaTime); } [ExcludeFromDocs] public static Vector3 SmoothDamp(Vector3 current, Vector3 target, ref Vector3 currentVelocity, float smoothTime) { float deltaTime = Time.deltaTime; float maxSpeed = float.PositiveInfinity; return Vector3.SmoothDamp(current, target, ref currentVelocity, smoothTime, maxSpeed, deltaTime); } public static Vector3 SmoothDamp(Vector3 current, Vector3 target, ref Vector3 currentVelocity, float smoothTime, [DefaultValue("Mathf.Infinity")] float maxSpeed, [DefaultValue("Time.deltaTime")] float deltaTime) { smoothTime = Mathf.Max(0.0001f, smoothTime); float num = 2f / smoothTime; float num2 = num * deltaTime; float d = 1f / (1f + num2 + 0.48f * num2 * num2 + 0.235f * num2 * num2 * num2); Vector3 vector = current - target; Vector3 vector2 = target; float maxLength = maxSpeed * smoothTime; vector = Vector3.ClampMagnitude(vector, maxLength); target = current - vector; Vector3 vector3 = (currentVelocity + num * vector) * deltaTime; currentVelocity = (currentVelocity - num * vector3) * d; Vector3 vector4 = target + (vector + vector3) * d; if (Vector3.Dot(vector2 - current, vector4 - vector2) > 0f) { vector4 = vector2; currentVelocity = (vector4 - vector2) / deltaTime; } return vector4; } /// <summary> /// <para>Set x, y and z components of an existing Vector3.</para> /// </summary> /// <param name="new_x"></param> /// <param name="new_y"></param> /// <param name="new_z"></param> public void Set(float new_x, float new_y, float new_z) { this.x = new_x; this.y = new_y; this.z = new_z; } /// <summary> /// <para>Multiplies two vectors component-wise.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> public static Vector3 Scale(Vector3 a, Vector3 b) { return new Vector3(a.x * b.x, a.y * b.y, a.z * b.z); } /// <summary> /// <para>Multiplies every component of this vector by the same component of scale.</para> /// </summary> /// <param name="scale"></param> public void Scale(Vector3 scale) { this.x *= scale.x; this.y *= scale.y; this.z *= scale.z; } /// <summary> /// <para>Cross Product of two vectors.</para> /// </summary> /// <param name="lhs"></param> /// <param name="rhs"></param> public static Vector3 Cross(Vector3 lhs, Vector3 rhs) { return new Vector3(lhs.y * rhs.z - lhs.z * rhs.y, lhs.z * rhs.x - lhs.x * rhs.z, lhs.x * rhs.y - lhs.y * rhs.x); } public override int GetHashCode() { ^ ; } /// <summary> /// <para>Returns true if the given vector is exactly equal to this vector.</para> /// </summary> /// <param name="other"></param> public override bool Equals(object other) { bool result; if (!(other is Vector3)) { result = false; } else { Vector3 vector = (Vector3)other; result = (this.x.Equals(vector.x) && this.y.Equals(vector.y) && this.z.Equals(vector.z)); } return result; } /// <summary> /// <para>Reflects a vector off the plane defined by a normal.</para> /// </summary> /// <param name="inDirection"></param> /// <param name="inNormal"></param> public static Vector3 Reflect(Vector3 inDirection, Vector3 inNormal) { return -2f * Vector3.Dot(inNormal, inDirection) * inNormal + inDirection; } /// <summary> /// <para></para> /// </summary> /// <param name="value"></param> public static Vector3 Normalize(Vector3 value) { float num = Vector3.Magnitude(value); Vector3 result; if (num > 1E-05f) { result = value / num; } else { result = Vector3.zero; } return result; } /// <summary> /// <para>Makes this vector have a magnitude of 1.</para> /// </summary> public void Normalize() { float num = Vector3.Magnitude(this); if (num > 1E-05f) { this /= num; } else { this = Vector3.zero; } } /// <summary> /// <para>Dot Product of two vectors.</para> /// </summary> /// <param name="lhs"></param> /// <param name="rhs"></param> public static float Dot(Vector3 lhs, Vector3 rhs) { return lhs.x * rhs.x + lhs.y * rhs.y + lhs.z * rhs.z; } /// <summary> /// <para>Projects a vector onto another vector.</para> /// </summary> /// <param name="vector"></param> /// <param name="onNormal"></param> public static Vector3 Project(Vector3 vector, Vector3 onNormal) { float num = Vector3.Dot(onNormal, onNormal); Vector3 result; if (num < Mathf.Epsilon) { result = Vector3.zero; } else { result = onNormal * Vector3.Dot(vector, onNormal) / num; } return result; } /// <summary> /// <para>Projects a vector onto a plane defined by a normal orthogonal to the plane.</para> /// </summary> /// <param name="vector"></param> /// <param name="planeNormal"></param> public static Vector3 ProjectOnPlane(Vector3 vector, Vector3 planeNormal) { return vector - Vector3.Project(vector, planeNormal); } /// <summary> /// <para>Returns the angle in degrees between from and to.</para> /// </summary> /// <param name="from">The angle extends round from this vector.</param> /// <param name="to">The angle extends round to this vector.</param> public static float Angle(Vector3 from, Vector3 to) { return Mathf.Acos(Mathf.Clamp(Vector3.Dot(from.normalized, to.normalized), -1f, 1f)) * 57.29578f; } /// <summary> /// <para>Returns the distance between a and b.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> public static float Distance(Vector3 a, Vector3 b) { Vector3 vector = new Vector3(a.x - b.x, a.y - b.y, a.z - b.z); return Mathf.Sqrt(vector.x * vector.x + vector.y * vector.y + vector.z * vector.z); } /// <summary> /// <para>Returns a copy of vector with its magnitude clamped to maxLength.</para> /// </summary> /// <param name="vector"></param> /// <param name="maxLength"></param> public static Vector3 ClampMagnitude(Vector3 vector, float maxLength) { Vector3 result; if (vector.sqrMagnitude > maxLength * maxLength) { result = vector.normalized * maxLength; } else { result = vector; } return result; } public static float Magnitude(Vector3 a) { return Mathf.Sqrt(a.x * a.x + a.y * a.y + a.z * a.z); } public static float SqrMagnitude(Vector3 a) { return a.x * a.x + a.y * a.y + a.z * a.z; } /// <summary> /// <para>Returns a vector that is made from the smallest components of two vectors.</para> /// </summary> /// <param name="lhs"></param> /// <param name="rhs"></param> public static Vector3 Min(Vector3 lhs, Vector3 rhs) { return new Vector3(Mathf.Min(lhs.x, rhs.x), Mathf.Min(lhs.y, rhs.y), Mathf.Min(lhs.z, rhs.z)); } /// <summary> /// <para>Returns a vector that is made from the largest components of two vectors.</para> /// </summary> /// <param name="lhs"></param> /// <param name="rhs"></param> public static Vector3 Max(Vector3 lhs, Vector3 rhs) { return new Vector3(Mathf.Max(lhs.x, rhs.x), Mathf.Max(lhs.y, rhs.y), Mathf.Max(lhs.z, rhs.z)); } public static Vector3 operator +(Vector3 a, Vector3 b) { return new Vector3(a.x + b.x, a.y + b.y, a.z + b.z); } public static Vector3 operator -(Vector3 a, Vector3 b) { return new Vector3(a.x - b.x, a.y - b.y, a.z - b.z); } public static Vector3 operator -(Vector3 a) { return new Vector3(-a.x, -a.y, -a.z); } public static Vector3 operator *(Vector3 a, float d) { return new Vector3(a.x * d, a.y * d, a.z * d); } public static Vector3 operator *(float d, Vector3 a) { return new Vector3(a.x * d, a.y * d, a.z * d); } public static Vector3 operator /(Vector3 a, float d) { return new Vector3(a.x / d, a.y / d, a.z / d); } public static bool operator ==(Vector3 lhs, Vector3 rhs) { return Vector3.SqrMagnitude(lhs - rhs) < 9.99999944E-11f; } public static bool operator !=(Vector3 lhs, Vector3 rhs) { return !(lhs == rhs); } /// <summary> /// <para>Returns a nicely formatted string for this vector.</para> /// </summary> /// <param name="format"></param> public override string ToString() { return UnityString.Format("({0:F1}, {1:F1}, {2:F1})", new object[] { this.x, this.y, this.z }); } /// <summary> /// <para>Returns a nicely formatted string for this vector.</para> /// </summary> /// <param name="format"></param> public string ToString(string format) { return UnityString.Format("({0}, {1}, {2})", new object[] { this.x.ToString(format), this.y.ToString(format), this.z.ToString(format) }); } [Obsolete("Use Vector3.Angle instead. AngleBetween uses radians instead of degrees and was deprecated for this reason")] public static float AngleBetween(Vector3 from, Vector3 to) { return Mathf.Acos(Mathf.Clamp(Vector3.Dot(from.normalized, to.normalized), -1f, 1f)); } } }
Vector3
using System; using UnityEngine.Scripting; namespace UnityEngine { /// <summary> /// <para>Representation of four-dimensional vectors.</para> /// </summary> [UsedByNativeCode] public struct Vector4 { public const float kEpsilon = 1E-05f; /// <summary> /// <para>X component of the vector.</para> /// </summary> public float x; /// <summary> /// <para>Y component of the vector.</para> /// </summary> public float y; /// <summary> /// <para>Z component of the vector.</para> /// </summary> public float z; /// <summary> /// <para>W component of the vector.</para> /// </summary> public float w; public float this[int index] { get { float result; switch (index) { : result = this.x; break; : result = this.y; break; : result = this.z; break; : result = this.w; break; default: throw new IndexOutOfRangeException("Invalid Vector4 index!"); } return result; } set { switch (index) { : this.x = value; break; : this.y = value; break; : this.z = value; break; : this.w = value; break; default: throw new IndexOutOfRangeException("Invalid Vector4 index!"); } } } /// <summary> /// <para>Returns this vector with a magnitude of 1 (Read Only).</para> /// </summary> public Vector4 normalized { get { return Vector4.Normalize(this); } } /// <summary> /// <para>Returns the length of this vector (Read Only).</para> /// </summary> public float magnitude { get { return Mathf.Sqrt(Vector4.Dot(this, this)); } } /// <summary> /// <para>Returns the squared length of this vector (Read Only).</para> /// </summary> public float sqrMagnitude { get { return Vector4.Dot(this, this); } } /// <summary> /// <para>Shorthand for writing Vector4(0,0,0,0).</para> /// </summary> public static Vector4 zero { get { return new Vector4(0f, 0f, 0f, 0f); } } /// <summary> /// <para>Shorthand for writing Vector4(1,1,1,1).</para> /// </summary> public static Vector4 one { get { return new Vector4(1f, 1f, 1f, 1f); } } /// <summary> /// <para>Creates a new vector with given x, y, z, w components.</para> /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> /// <param name="w"></param> public Vector4(float x, float y, float z, float w) { this.x = x; this.y = y; this.z = z; this.w = w; } /// <summary> /// <para>Creates a new vector with given x, y, z components and sets w to zero.</para> /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> public Vector4(float x, float y, float z) { this.x = x; this.y = y; this.z = z; this.w = 0f; } /// <summary> /// <para>Creates a new vector with given x, y components and sets z and w to zero.</para> /// </summary> /// <param name="x"></param> /// <param name="y"></param> public Vector4(float x, float y) { this.x = x; this.y = y; this.z = 0f; this.w = 0f; } /// <summary> /// <para>Set x, y, z and w components of an existing Vector4.</para> /// </summary> /// <param name="new_x"></param> /// <param name="new_y"></param> /// <param name="new_z"></param> /// <param name="new_w"></param> public void Set(float new_x, float new_y, float new_z, float new_w) { this.x = new_x; this.y = new_y; this.z = new_z; this.w = new_w; } /// <summary> /// <para>Linearly interpolates between two vectors.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="t"></param> public static Vector4 Lerp(Vector4 a, Vector4 b, float t) { t = Mathf.Clamp01(t); return new Vector4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t); } /// <summary> /// <para>Linearly interpolates between two vectors.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="t"></param> public static Vector4 LerpUnclamped(Vector4 a, Vector4 b, float t) { return new Vector4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t); } /// <summary> /// <para>Moves a point current towards target.</para> /// </summary> /// <param name="current"></param> /// <param name="target"></param> /// <param name="maxDistanceDelta"></param> public static Vector4 MoveTowards(Vector4 current, Vector4 target, float maxDistanceDelta) { Vector4 a = target - current; float magnitude = a.magnitude; Vector4 result; if (magnitude <= maxDistanceDelta || magnitude == 0f) { result = target; } else { result = current + a / magnitude * maxDistanceDelta; } return result; } /// <summary> /// <para>Multiplies two vectors component-wise.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> public static Vector4 Scale(Vector4 a, Vector4 b) { return new Vector4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w); } /// <summary> /// <para>Multiplies every component of this vector by the same component of scale.</para> /// </summary> /// <param name="scale"></param> public void Scale(Vector4 scale) { this.x *= scale.x; this.y *= scale.y; this.z *= scale.z; this.w *= scale.w; } public override int GetHashCode() { ^ ^ ; } /// <summary> /// <para>Returns true if the given vector is exactly equal to this vector.</para> /// </summary> /// <param name="other"></param> public override bool Equals(object other) { bool result; if (!(other is Vector4)) { result = false; } else { Vector4 vector = (Vector4)other; result = (this.x.Equals(vector.x) && this.y.Equals(vector.y) && this.z.Equals(vector.z) && this.w.Equals(vector.w)); } return result; } /// <summary> /// <para></para> /// </summary> /// <param name="a"></param> public static Vector4 Normalize(Vector4 a) { float num = Vector4.Magnitude(a); Vector4 result; if (num > 1E-05f) { result = a / num; } else { result = Vector4.zero; } return result; } /// <summary> /// <para>Makes this vector have a magnitude of 1.</para> /// </summary> public void Normalize() { float num = Vector4.Magnitude(this); if (num > 1E-05f) { this /= num; } else { this = Vector4.zero; } } /// <summary> /// <para>Dot Product of two vectors.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> public static float Dot(Vector4 a, Vector4 b) { return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w; } /// <summary> /// <para>Projects a vector onto another vector.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> public static Vector4 Project(Vector4 a, Vector4 b) { return b * Vector4.Dot(a, b) / Vector4.Dot(b, b); } /// <summary> /// <para>Returns the distance between a and b.</para> /// </summary> /// <param name="a"></param> /// <param name="b"></param> public static float Distance(Vector4 a, Vector4 b) { return Vector4.Magnitude(a - b); } public static float Magnitude(Vector4 a) { return Mathf.Sqrt(Vector4.Dot(a, a)); } /// <summary> /// <para>Returns a vector that is made from the smallest components of two vectors.</para> /// </summary> /// <param name="lhs"></param> /// <param name="rhs"></param> public static Vector4 Min(Vector4 lhs, Vector4 rhs) { return new Vector4(Mathf.Min(lhs.x, rhs.x), Mathf.Min(lhs.y, rhs.y), Mathf.Min(lhs.z, rhs.z), Mathf.Min(lhs.w, rhs.w)); } /// <summary> /// <para>Returns a vector that is made from the largest components of two vectors.</para> /// </summary> /// <param name="lhs"></param> /// <param name="rhs"></param> public static Vector4 Max(Vector4 lhs, Vector4 rhs) { return new Vector4(Mathf.Max(lhs.x, rhs.x), Mathf.Max(lhs.y, rhs.y), Mathf.Max(lhs.z, rhs.z), Mathf.Max(lhs.w, rhs.w)); } public static Vector4 operator +(Vector4 a, Vector4 b) { return new Vector4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w); } public static Vector4 operator -(Vector4 a, Vector4 b) { return new Vector4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w); } public static Vector4 operator -(Vector4 a) { return new Vector4(-a.x, -a.y, -a.z, -a.w); } public static Vector4 operator *(Vector4 a, float d) { return new Vector4(a.x * d, a.y * d, a.z * d, a.w * d); } public static Vector4 operator *(float d, Vector4 a) { return new Vector4(a.x * d, a.y * d, a.z * d, a.w * d); } public static Vector4 operator /(Vector4 a, float d) { return new Vector4(a.x / d, a.y / d, a.z / d, a.w / d); } public static bool operator ==(Vector4 lhs, Vector4 rhs) { return Vector4.SqrMagnitude(lhs - rhs) < 9.99999944E-11f; } public static bool operator !=(Vector4 lhs, Vector4 rhs) { return !(lhs == rhs); } public static implicit operator Vector4(Vector3 v) { return new Vector4(v.x, v.y, v.z, 0f); } public static implicit operator Vector3(Vector4 v) { return new Vector3(v.x, v.y, v.z); } public static implicit operator Vector4(Vector2 v) { return new Vector4(v.x, v.y, 0f, 0f); } public static implicit operator Vector2(Vector4 v) { return new Vector2(v.x, v.y); } /// <summary> /// <para>Returns a nicely formatted string for this vector.</para> /// </summary> /// <param name="format"></param> public override string ToString() { return UnityString.Format("({0:F1}, {1:F1}, {2:F1}, {3:F1})", new object[] { this.x, this.y, this.z, this.w }); } /// <summary> /// <para>Returns a nicely formatted string for this vector.</para> /// </summary> /// <param name="format"></param> public string ToString(string format) { return UnityString.Format("({0}, {1}, {2}, {3})", new object[] { this.x.ToString(format), this.y.ToString(format), this.z.ToString(format), this.w.ToString(format) }); } public static float SqrMagnitude(Vector4 a) { return Vector4.Dot(a, a); } public float SqrMagnitude() { return Vector4.Dot(this, this); } } }
Vector4
W:
X:
Y:
Z:
Unity 代码 学习的更多相关文章
- Unity ShaderLab学习总结
http://www.jianshu.com/p/7b9498e58659 Unity ShaderLab学习总结 Why Bothers? 为什么已经有ShaderForge这种可视化Shader编 ...
- Unity Shader 学习之旅
Unity Shader 学习之旅 unityshader图形图像 纸上学来终觉浅,绝知此事要躬行 美丽的梦和美丽的诗一样 都是可遇而不可求的——席慕蓉 一.渲染流水线 示例图 Tips:什么是 GP ...
- u-boot代码学习内容
前言 u-boot代码庞大,不可能全部细读,只能有选择的读部分代码.在读代码之前,根据韦东山教材,关于代码学习内容和深度做以下预先划定. 一.Makefile.mkconfig.config.mk等 ...
- unity 基础学习 transform
unity 基础学习 transform 1.unity采用的是右手坐标系,X轴右手为+,Y轴向上为+,Z轴朝里为+; 但是我们从3D MAX中导入模型之后,发现轴向并没有遵从这个原理, 其实是 ...
- Unity 代码编译成dll 更新dll实现热更代码
Unity 代码编译成dll 更新dll实现热更代码 实现流程 代码编译成DLL DLL打包成AssetBundle 加载AssetBundle 加载代码程序集 获取指定类 使用反射赋值 C#代码编译 ...
- Unity Shader 学习之旅之SurfaceShader
Unity Shader 学习之旅之SurfaceShader unity shader 图形图像 如果大地的每个角落都充满了光明 谁还需要星星,谁还会 在夜里凝望 寻找遥远的安慰——江河 官方文档 ...
- unity 代码有调整,重新导出 iOS 最烦的就是 覆盖导出后项目不能打开
unity 代码有调整,重新导出 iOS 最烦的就是 覆盖导出后项目不能打开,原因是 editor 里面的脚本,破坏了 Unity-iPhone.xcodeproj 里面的结构,具体是什么原因,也不 ...
- Objective-C代码学习大纲(3)
Objective-C代码学习大纲(3) 2011-05-11 14:06 佚名 otierney 字号:T | T 本文为台湾出版的<Objective-C学习大纲>的翻译文档,系统介绍 ...
- visual studio tools for unity代码提示快捷键
visual studio tools for unity代码提示快捷键 ctrl+ shift +q
随机推荐
- Cracking The Coding Interview2.3
#include <iostream> #include <string> using namespace std; class linklist { private: cla ...
- loadrunner json中文无法识别问题
http://blog.sina.com.cn/s/blog_6ff7a3b50101awmy.html
- mysql 给表和字段加注释
给表加注释: ALTER TABLE table_name COMMENT='这是表的注释'; 给列加注释: ALTER table table_name MODIFY `column_name` d ...
- matlab中的reshape快速理解,卷积和乘积之间的转换
reshape: THe convertion between convolution and multiplication:
- 基于spec互评Alpha版本
作业要求[https://edu.cnblogs.com/campus/nenu/2018fall/homework/2323] 队名:二次元梦之队 组长:刘莹莹 组员:周昊 潘世维 王玉潘 赵美增 ...
- 小波学习之一(单层一维离散小波变换DWT的Mallat算法C++和MATLAB实现) ---转载
1 Mallat算法 离散序列的Mallat算法分解公式如下: 其中,H(n).G(n)分别表示所选取的小波函数对应的低通和高通滤波器的抽头系数序列. 从Mallat算法的分解原理可知,分解后的序 ...
- 九、编写led驱动
led.c #include <linux/init.h> #include <linux/module.h> #include <linux/cdev.h> #i ...
- JavaScript , js 上下文(this 的指代)
上下文 代表 this 变量的值, 以及 它的 指代; 它决定一个函数怎么被调用; 当一个函数作为一个对象的方法被调用的时候, this总是指向 调用这个方法的对象. ----- 1 ,情况一: 字面 ...
- 【转】 纯技术帖:MMOG网络同步算法揭秘
http://www.360doc.com/content/12/0723/11/110467_225954142.shtml 来源:网络 概述 游戏发展从单机游戏到局域网游戏再到mmog(Massi ...
- 2.32 js几种定位方法总结
2.32 js几种定位方法总结 前言本篇总结了几种js常用的定位元素方法,并用js点击按钮,对input输入框输入文本 一.以下总结了5种js定位的方法除了id是定位到的是单个element元素对象, ...