public static XElement SaveCamera() { GameObject cameraObj = GameMain.Instance.MainCamera.gameObject; var xml = new XElement("Camera", new XElement("Position", Util.ConvertVector3ToString(GameMain.Instance.MainCamera.GetTargetPos())), new XElement("Rotation", Util.ConvertVector3ToString(cameraObj.transform.eulerAngles)), new XElement("Distance", GameMain.Instance.MainCamera.GetDistance().ToString()), new XElement("FieldOfView", cameraObj.GetComponent <Camera>().fieldOfView.ToString())); return(xml); }
private static string GetValue(object instance, Type fieldType, FieldInfo field) { string result = null; object val = field.GetValue(instance); if (val == null) { return(null); } if (fieldType == typeof(Shader) || fieldType == typeof(Texture2D)) { return(null); } if (fieldType.IsPrimitive) { result = val.ToString(); } else if (fieldType.IsEnum) { result = ((int)val).ToString(); } else if (fieldType == typeof(Vector3)) { Vector3 v3 = (Vector3)val; result = Util.ConvertVector3ToString(v3); } else if (fieldType == typeof(Color) || fieldType == typeof(Color32)) { Color32 color = (Color)val; result = Util.ConvertColor32ToString(color); } else if (fieldType == typeof(AnimationCurve)) { AnimationCurve curve = (AnimationCurve)val; result = Util.ConvertAnimationCurveToString(curve); } else if (fieldType == typeof(Transform)) { Vector3 v3 = ((Transform)val).position; result = Util.ConvertVector3ToString(v3); } return(result); }
public static XElement SaveModels() { var xml = new XElement("Models"); foreach (ModelInfo model in models) { var elem = new XElement("Model", new XElement("Position", Util.ConvertVector3ToString(model.position)), new XElement("Rotation", Util.ConvertQuaternionToString(model.rotation)), new XElement("LocalScale", Util.ConvertVector3ToString(model.localScale)), new XElement("ModelType", (int)model.modelType), new XElement("MenuFileName", model.menuFileName), new XElement("ModelName", model.modelName), new XElement("ModelIconName", model.modelIconName)); xml.Add(elem); } return(xml); }
public static XElement SaveLights() { var xml = new XElement("Lights"); foreach (LightInfo light in lights) { var elem = new XElement("Light", new XElement("Position", Util.ConvertVector3ToString(light.position)), new XElement("EulerAngles", Util.ConvertVector3ToString(light.eulerAngles)), new XElement("Intensity", light.intensity.ToString()), new XElement("Range", light.range.ToString()), new XElement("SpotAngle", light.spotAngle.ToString()), new XElement("Color", Util.ConvertColor32ToString((Color32)light.color)), new XElement("Type", ((int)light.type).ToString()), new XElement("Enabled", light.enabled.ToString())); xml.Add(elem); } return(xml); }