Ejemplo n.º 1
0
        protected override JSONObject ToJSON(WXHierarchyContext context)
        {
            JSONObject json = new JSONObject(JSONObject.Type.OBJECT);
            JSONObject data = new JSONObject(JSONObject.Type.OBJECT);

            json.AddField("type", getTypeName());
            json.AddField("data", data);
            data.AddField("active", true);

            // if (this.collider != null)
            {
                data.AddField("isTrigger", this.isTrigger);
                if (material != null)
                {
                    WXPhysicsMaterial materialConverter = new WXPhysicsMaterial(material);
                    string            materialPath      = materialConverter.Export(context.preset);
                    if (materialPath != null && materialPath != "")
                    {
                        data.AddField("material", materialPath);
                        context.AddResource(materialPath);
                    }
                }

                JSONObject center = new JSONObject(JSONObject.Type.ARRAY);
                center.Add(-this.center.x);
                center.Add(this.center.y);
                center.Add(this.center.z);
                data.AddField("center", center);

                data.AddField("radius", this.radius);
            }

            return(json);
        }
Ejemplo n.º 2
0
        protected override JSONObject ToJSON(WXHierarchyContext context)
        {
            JSONObject json = new JSONObject(JSONObject.Type.OBJECT);
            JSONObject data = new JSONObject(JSONObject.Type.OBJECT);

            json.AddField("type", getTypeName());
            json.AddField("data", data);
            data.AddField("active", true);

            // if (this.collider != null)
            {
                data.AddField("convex", this.convex);
                data.AddField("isTrigger", this.isTrigger);
                 #if UNITY_2017_1_OR_NEWER
                data.AddField("cookingOptions", (int)this.cookingOptions);
                #endif
                if (material != null)
                {
                    WXPhysicsMaterial materialConverter = new WXPhysicsMaterial(material);
                    string            materialPath      = materialConverter.Export(context.preset);
                    if (materialPath != null && materialPath != "")
                    {
                        data.AddField("material", materialPath);
                        context.AddResource(materialPath);
                    }
                }

                Mesh mesh = this.sharedMesh;
                if (mesh != null)
                {
                    WXMesh meshConverter = new WXMesh(mesh);
                    string meshPath      = meshConverter.Export(context.preset);
                    data.AddField("mesh", meshPath);
                    context.AddResource(meshPath);
                }
            }

            return(json);
        }