Beispiel #1
0
    public void ImportProteinSettings()
    {
        try
        {
            ////read
            serializer = new XmlSerializer(typeof(CutParametersContainer));
            stream     = new FileStream(path, FileMode.Open);
            CutParametersContainer importParams = serializer.Deserialize(stream) as CutParametersContainer;
            stream.Close();

            for (int i = 0; i < importParams.CutObjectProps.Count && i < SceneManager.Get.CutObjects.Count; i++)
            {
                SceneManager.Get.CutObjects[i].IngredientCutParameters = importParams.CutObjectProps[i].ProteinTypeParameters;
                SceneManager.Get.CutObjects[i].Inverse = importParams.CutObjectProps[i].Inverse;
                SceneManager.Get.CutObjects[i].CutType = (CutType)importParams.CutObjectProps[i].CutType;

                //restore transform info
                SceneManager.Get.CutObjects[i].transform.rotation   = importParams.CutObjectProps[i].rotation;
                SceneManager.Get.CutObjects[i].transform.position   = importParams.CutObjectProps[i].position;
                SceneManager.Get.CutObjects[i].transform.localScale = importParams.CutObjectProps[i].scale;
            }
        }
        catch (Exception e)
        {
            Debug.Log("import failed: " + e.ToString());
            return;
        }

        Debug.Log("imported cutobject settings from " + path);
    }
    public void ExportProteinSettings()
    {
        try
        {
            CutParametersContainer exportParams = new CutParametersContainer();

            foreach (CutObject cuto in SceneManager.Get.CutObjects)
            {
                CutObjectProperties props = new CutObjectProperties();
                props.ProteinTypeParameters = cuto.IngredientCutParameters;
                props.Inverse = cuto.Inverse;
                props.CutType = (int)cuto.CutType;
                props.rotation = cuto.transform.rotation;
                props.position = cuto.transform.position;
                props.scale = cuto.transform.localScale;
                exportParams.CutObjectProps.Add(props);            
            }

            ////write
            serializer = new XmlSerializer(typeof(CutParametersContainer));
            stream = new FileStream(path, FileMode.Create);
            serializer.Serialize(stream, exportParams);
            stream.Close();
        }
        catch(Exception e)
        {
            Debug.Log("export failed: " + e.ToString());
            return;
        }

        Debug.Log("exported cutobject settings to " + path);
    }
Beispiel #3
0
    public void ExportProteinSettings()
    {
        try
        {
            CutParametersContainer exportParams = new CutParametersContainer();

            foreach (CutObject cuto in SceneManager.Get.CutObjects)
            {
                CutObjectProperties props = new CutObjectProperties();
                props.ProteinTypeParameters = cuto.IngredientCutParameters;
                props.Inverse  = cuto.Inverse;
                props.CutType  = (int)cuto.CutType;
                props.rotation = cuto.transform.rotation;
                props.position = cuto.transform.position;
                props.scale    = cuto.transform.localScale;
                exportParams.CutObjectProps.Add(props);
            }

            ////write
            serializer = new XmlSerializer(typeof(CutParametersContainer));
            stream     = new FileStream(path, FileMode.Create);
            serializer.Serialize(stream, exportParams);
            stream.Close();
        }
        catch (Exception e)
        {
            Debug.Log("export failed: " + e.ToString());
            return;
        }

        Debug.Log("exported cutobject settings to " + path);
    }