Exemple #1
0
        //プロパティの値をバイナリ書き込み
        void WritePropertyValue(SerializedProperty property, BinaryWriter writer)
        {
            property = property.Copy();

            switch (property.propertyType)
            {
            case SerializedPropertyType.Integer:
            case SerializedPropertyType.Character:
            case SerializedPropertyType.LayerMask:
            case SerializedPropertyType.Enum:
                writer.Write(property.intValue);
                break;

            case SerializedPropertyType.Boolean:
                writer.Write(property.boolValue);
                break;

            case SerializedPropertyType.Float:
                writer.Write(property.floatValue);
                break;

            case SerializedPropertyType.String:
                writer.Write(property.stringValue);
                break;

            case SerializedPropertyType.ArraySize:
                writer.Write(property.arraySize);
                break;

            case SerializedPropertyType.Color:
                BinaryUtil.WriteColor(property.colorValue, writer);
                break;

            case SerializedPropertyType.Vector2:
                BinaryUtil.WriteVector2(property.vector2Value, writer);
                break;

            case SerializedPropertyType.Vector3:
                BinaryUtil.WriteVector3(property.vector3Value, writer);
                break;

            case SerializedPropertyType.Vector4:
                BinaryUtil.WriteVector3(property.vector4Value, writer);
                break;

            case SerializedPropertyType.Rect:
                BinaryUtil.WriteRect(property.rectValue, writer);
                break;

            case SerializedPropertyType.Bounds:
                BinaryUtil.WriteBounds(property.boundsValue, writer);
                break;

            case SerializedPropertyType.Quaternion:
                BinaryUtil.WriteQuaternion(property.quaternionValue, writer);
                break;

            case SerializedPropertyType.ObjectReference:
                writer.Write(AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(property.objectReferenceValue)));
                break;

            case SerializedPropertyType.Generic:
                WriteGenericPropertyValue(property, writer);
                break;

            case SerializedPropertyType.AnimationCurve:
            case SerializedPropertyType.Gradient:
            default:
                Debug.LogError("Write Not Support Property :" + property.name + ":" + property.propertyType.ToString());
                break;
            }
        }