コード例 #1
0
        static public void ClearValue(this SerializedProperty item)
        {
            if (item.IsTypicalArray())
            {
                item.ClearValue_Array();
            }
            else
            {
                switch (item.propertyType)
                {
                case SerializedPropertyType.Generic:
                    item.ClearValue_Generic();
                    break;

                case SerializedPropertyType.Enum:
                    item.ClearValue_Enum();
                    break;

                case SerializedPropertyType.Boolean:
                    item.boolValue = default(bool);
                    break;

                case SerializedPropertyType.Integer:
                    item.intValue = default(int);
                    break;

                case SerializedPropertyType.Float:
                    item.floatValue = default(float);
                    break;

                case SerializedPropertyType.Character:
                    item.stringValue = default(string);
                    break;

                case SerializedPropertyType.String:
                    item.stringValue = default(string);
                    break;

                case SerializedPropertyType.Vector2:
                    item.vector2Value = default(Vector2);
                    break;

                case SerializedPropertyType.Vector3:
                    item.vector3Value = default(Vector3);
                    break;

                case SerializedPropertyType.Vector4:
                    item.vector4Value = default(Vector4);
                    break;

                case SerializedPropertyType.Rect:
                    item.rectValue = default(Rect);
                    break;

                case SerializedPropertyType.Bounds:
                    item.boundsValue = default(Bounds);
                    break;

                case SerializedPropertyType.Vector2Int:
                    item.vector2IntValue = default(Vector2Int);
                    break;

                case SerializedPropertyType.Vector3Int:
                    item.vector3IntValue = default(Vector3Int);
                    break;

                case SerializedPropertyType.RectInt:
                    item.rectIntValue = default(RectInt);
                    break;

                case SerializedPropertyType.BoundsInt:
                    item.boundsIntValue = default(BoundsInt);
                    break;

                case SerializedPropertyType.Quaternion:
                    item.quaternionValue = default(Quaternion);
                    break;

                case SerializedPropertyType.ArraySize:
                    item.arraySize = default(int);
                    break;

                case SerializedPropertyType.LayerMask:
                    item.intValue = default(int);
                    break;

                case SerializedPropertyType.Color:
                    item.colorValue = default(Color);
                    break;

                case SerializedPropertyType.Gradient:
                    item.colorValue = default(Color);
                    break;

                case SerializedPropertyType.ObjectReference:
                    item.objectReferenceValue = default(UnityEngine.Object);
                    break;

                case SerializedPropertyType.AnimationCurve:
                    item.animationCurveValue = default(AnimationCurve);
                    break;
                }
            }
        }