/// <summary> /// Closes the project with an option to save before closing. /// </summary> /// <param name="saveBeforeClosing"> /// Saves before closing if <see langword="true"/>. /// </param> public async Task Close(bool saveBeforeClosing) { if (saveBeforeClosing) { await SaveAllAsync(); } SaveableObjects.Clear(); await App.Metadata.ClearCurrentProject(); }
/// <summary> /// Closes the project with an option to save before closing. /// </summary> /// <param name="saveBeforeClosing"> /// Saves before closing if <see langword="true"/>. /// </param> public async Task Close(bool saveBeforeClosing) { if (saveBeforeClosing) { await this.SaveAllAsync(); } SaveableObjects.Clear(); App.Metadata.CurrentProject = null; }
public GameObject CreateObjectFromData(List <string> data) { SaveableObjects objects = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <SaveableObjects>(); GameObject newObject = GameObject.Instantiate(objects.objects[MapHelper.StringToInt(data[0])].prefab, new Vector3(MapHelper.StringToFloat(data[1]), MapHelper.StringToFloat(data[2]), MapHelper.StringToFloat(data[3])), new Quaternion(MapHelper.StringToFloat(data[4]), MapHelper.StringToFloat(data[5]), MapHelper.StringToFloat(data[6]), 0)); return(newObject); }
void Start() { listContent = this.transform.gameObject; SaveableObjects objects = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <SaveableObjects>(); foreach (SaveableObject so in objects.tiles) { this.NewPanelForSaveableObject(so); } foreach (SaveableObject so in objects.objects) { this.NewPanelForSaveableObject(so); } }
void DeselectAction(string name, int buttonNum) { Texture2D tex = SaveableObjects.LoadTrack(name).texture; trackImage.enabled = true; trackImage.sprite = Sprite.Create(tex, new Rect(0.0f, 0.0f, -tex.width, -tex.height), new Vector2(0.5f, 0.5f), 100.0f); currentButtons[buttonNum].onClick.RemoveAllListeners(); currentButtons[buttonNum].onClick.AddListener(delegate { SelectButtonAction(name, buttonNum); }); currentButtons[buttonNum].transform.GetChild(1).GetComponent <Image>().enabled = false; selectedTrackNames.Remove(name); }
void SelectButtonAction(string name, int buttonNum) { selectedTrackNames.Clear(); Texture2D tex = SaveableObjects.LoadTrack(name).texture; trackImage.enabled = true; trackImage.sprite = Sprite.Create(tex, new Rect(0.0f, 0.0f, -tex.width, -tex.height), new Vector2(0.5f, 0.5f), 100.0f); selectedTrackNames.Add(name); currentButtons[buttonNum].transform.GetChild(1).GetComponent <Image>().enabled = true; if (enabledImage != null && !multiplePossible) { enabledImage.enabled = false; } enabledImage = currentButtons[buttonNum].transform.GetChild(1).GetComponent <Image>(); }
void LoadTrack() { Texture2D tex; if (loadTrackManager.selectedTrackNames[0] != "") { tex = SaveableObjects.LoadTrack(loadTrackManager.selectedTrackNames[0]).texture; tex.filterMode = FilterMode.Point; TrackManager.trackManager.GetComponent <Renderer>().material.SetTexture("_MainTex", (Texture)tex); } else { loadTrackManager.Error("First select a track!"); } LoadBack(); MainOptions(); }
void SelectButtonAction(string name, int buttonNum) { try { Texture2D tex = SaveableObjects.LoadTrack(name).texture; trackImage.enabled = true; if (tex != null) { trackImage.sprite = Sprite.Create(tex, new Rect(0.0f, 0.0f, -tex.width, -tex.height), new Vector2(0.5f, 0.5f), 100.0f); } if (multiplePossible) { currentButtons[buttonNum].onClick.RemoveAllListeners(); currentButtons[buttonNum].onClick.AddListener(delegate { DeselectAction(name, buttonNum); }); } if (transform.childCount > 1) { currentButtons[buttonNum].transform.GetChild(1).GetComponent <Image>().enabled = true; } if (enabledImage != null && !multiplePossible) { enabledImage.enabled = false; selectedTrackNames.Clear(); } enabledImage = currentButtons[buttonNum].transform.GetChild(1).GetComponent <Image>(); selectedTrackNames.Add(name); } catch (System.Exception) { selectedTrackNames.Add(name); currentButtons[buttonNum].transform.GetChild(1).GetComponent <Image>().enabled = true; } }
public void Load() { foreach (SaveableObject obj in SaveableObjects) { if (obj != null) { Destroy(obj.gameObject); } } SaveableObjects.Clear(); int objectCount = PlayerPrefs.GetInt("ObjectCount"); for (int i = 0; i < objectCount; i++) { string[] value = PlayerPrefs.GetString(i.ToString()).Split('_'); GameObject tmp = null; switch (value[0]) { case "Cube": tmp = Instantiate(Resources.Load("Cube") as GameObject); break; case "Cylinder": tmp = Instantiate(Resources.Load("Cylinder") as GameObject); break; case "Sphere": tmp = Instantiate(Resources.Load("Sphere") as GameObject); break; } if (tmp != null) { tmp.GetComponent <SaveableObject>().Load(value); } } }
/// <summary> /// Default constructor which requires to specify the type of object to write /// </summary> public XmlWriter(SaveableObjects objectType) { ObjectType = objectType; }
/// <summary> /// Default constructor /// </summary> public XmlReader(SaveableObjects objectType) { ObjectType = objectType; }
/// <summary> /// Removes this <see cref="SaveableObject"/> from the list of tracked <see /// cref="SaveableObject"/> s. /// </summary> public void Remove() => SaveableObjects.Remove(this);
/// <summary> /// Creates a new <see cref="SaveableObject"/>. /// </summary> public SaveableObject() { SaveableObjects.Add(this); this.PropertyChanged += this.ObservableObjectPropertyChanged; }
/// <summary> /// Default constructor /// </summary> public BinaryReader(SaveableObjects objectType) { ObjectType = objectType; }
/// <summary> /// Setups the <see cref="XmlReader"/> to provided type /// </summary> public static void SetupXmlReader(SaveableObjects type) { XmlReader = new XmlReader(type); }
/// <summary> /// Setups the <see cref="BinaryReader"/> to provided type /// </summary> public static void SetupBinaryReader(SaveableObjects type) { BinaryReader = new BinaryReader(type); }
/// <summary> /// Default constructor which requires to specify the type of object to write /// </summary> public BinaryWriter(SaveableObjects objectType) { ObjectType = objectType; }