public static AXShape fromJSON(AXParametricObject po, AX.SimpleJSON.JSONNode jn) { AXShape shape = new AXShape(jn["name"]); shape.parametricObject = po; shape.ParentNode = po; shape.Parent = po; // parameters if (jn["inputs"] != null) { shape.inputs = new List <AXParameter>(); foreach (AX.SimpleJSON.JSONNode jn_p in jn["inputs"].AsArray) { shape.inputs.Add(AXParameter.fromJSON(jn_p)); } } if (jn["difference"] != null) { shape.difference = AXParameter.fromJSON(jn["difference"]); } if (jn["differenceRail"] != null) { shape.differenceRail = AXParameter.fromJSON(jn["differenceRail"]); } if (jn["intersection"] != null) { shape.intersection = AXParameter.fromJSON(jn["intersection"]); } if (jn["intersectionRail"] != null) { shape.intersectionRail = AXParameter.fromJSON(jn["intersectionRail"]); } if (jn["union"] != null) { shape.union = AXParameter.fromJSON(jn["union"]); } if (jn["grouped"] != null) { shape.grouped = AXParameter.fromJSON(jn["grouped"]); } return(shape); }
public static AXParametricObject ParametricObjectFromJSON(AX.SimpleJSON.JSONNode jn) { AXParametricObject po = new AXParametricObject(jn["type"], jn["name"]); po.Guid = jn["guid"].Value; po.basedOnAssetWithGUID = jn["basedOnAssetWithGUID"].Value; po.description = jn["description"].Value; po.author = jn["author"].Value; po.tags = jn["tags"].Value; po.documentationURL = jn["documentationURL"].Value; if (jn["includeInSidebarMenu"] != null) { po.includeInSidebarMenu = jn["includeInSidebarMenu"].AsBool; } else { po.includeInSidebarMenu = true; } po.isInitialized = jn["isInitialized"].AsBool; po.grouperKey = jn["grouperKey"].Value; if (jn["sortval"] != null) { po.sortval = jn["sortval"].AsFloat; } po.curve = AXJson.CurveFromJSON(jn["curve"]); po.rect = AXJson.RectFromJSON(jn["rect"]); po.bounds = AXJson.BoundsFromJSON(jn["bounds"]); po.transMatrix = AXJson.Matrix4x4FromJSON(jn["transMatrix"]); po.combineMeshes = jn["combineMeshes"].AsBool; po.isRigidbody = jn["isRigidbody"].AsBool; po.colliderType = (AXGeometryTools.ColliderType)jn["colliderType"].AsInt; po.axStaticEditorFlags = (AXStaticEditorFlags)jn["axStaticEditorFlags"].AsInt; //Debug.Log(po.Name + " " + po.grouperKey); // material // look to see if there is a material matching this name.... #if UNITY_EDITOR if (jn["material_assetGUID"] != null) { string path = AssetDatabase.GUIDToAssetPath(jn["material_assetGUID"].Value); //Debug.Log("AssetDatabase.GUIDToAssetPath("+jn["material_assetGUID"].Value+") has path: " + path); // REDO if (path != null) { //Debug.Log(jn["Name"] + ": path="+path); Material matter = (Material)AssetDatabase.LoadAssetAtPath(path, typeof(Material)); //Debug.Log("..."+matter); //po.axMat.mat = (Material) AssetDatabase.LoadAssetAtPath(path, typeof(Material)) ; if (po.axMat == null) { po.axMat = new AXMaterial(); } po.axMat.mat = matter; } } #endif // code if (jn["code"] != null) { po.code = jn["code"].Value.Replace(";", "\n"); } // parameters if (jn["parameters"] != null) { po.parameters = new List <AXParameter>(); foreach (AX.SimpleJSON.JSONNode jn_p in jn["parameters"].AsArray) { po.addParameter(AXParameter.fromJSON(jn_p)); } } // shapes if (jn["shapes"] != null) { po.shapes = new List <AXShape>(); foreach (AX.SimpleJSON.JSONNode jn_p in jn["shapes"].AsArray) { po.shapes.Add(AXShape.fromJSON(po, jn_p)); } } // handles if (jn["handles"] != null) { po.handles = new List <AXHandle>(); foreach (AX.SimpleJSON.JSONNode jn_h in jn["handles"].AsArray) { po.handles.Add(AXHandle.fromJSON(jn_h)); } } // cameraSettings if (jn["cameraSettings"] != null) { po.cameraSettings = JSONSerializersAX.AXCameraFromJSON(jn["cameraSettings"]); po.cameraSettings.setPosition(); } // make the generator for this po po.instantiateGenerator(); return(po); }