private void RemoveSelectedProfile() { if (_ProfileList.SelectedItem != null) { AnimationTreeProfileData data = ((ProfileItem)_ProfileList.SelectedItem).Data; AnimationTreeProfileData[] preProfiles = _Editor.Tree.Profiles; AnimationTreeProfileData[] newProfiles = new AnimationTreeProfileData[preProfiles.Length - 1]; int preIndex = 0; int newIndex = 0; while (newIndex < newProfiles.Length && preIndex < preProfiles.Length) { if (preProfiles[preIndex] == data) { preIndex++; continue; } newProfiles[newIndex] = preProfiles[preIndex]; newIndex++; preIndex++; } _Editor.Tree.Profiles = newProfiles; _ProfileList.Items.Remove(_ProfileList.SelectedItem); _ProfileList.SelectedIndex = 0; SetButtonsEnable(); } else { Debug.LogError("there is no selected profile to remove"); } }
private bool IsProfileExists(AnimationTreeProfileData data) { foreach (ProfileItem item in _ProfileList.Items) { if (item.Data == data) { return(true); } } return(false); }
private void AddNewProfile() { AnimationTreeProfileData profile = new AnimationTreeProfileData(); profile.Name = GetUniqueProfileName("NewProfile"); AnimationTreeProfileData[] preProfiles = _Editor.Tree.Profiles; AnimationTreeProfileData[] newProfiles = new AnimationTreeProfileData[preProfiles.Length + 1]; preProfiles.CopyTo(newProfiles, 0); newProfiles[newProfiles.Length - 1] = profile; _Editor.Tree.Profiles = newProfiles; Add(profile); SetButtonsEnable(); }
public void Load(XmlElement e) { this.Name = e.GetAttributeValueAsString("Name", ""); this.Zoom = e.GetAttributeValueAsFloat("Zoom", Zoom); this.PanX = e.GetAttributeValueAsFloat("PanX", PanX); this.PanY = e.GetAttributeValueAsFloat("PanY", PanY); XmlElement parametersElement = e["Parameters"]; if (parametersElement != null) { int stateCount = parametersElement.GetAttributeValueAsInt("Count", 0); this.Parameters = new AnimationTreeParameter[stateCount]; int i = 0; foreach (var element in parametersElement) { if (element.Name == "Parameter") { AnimationTreeParameter s = new AnimationTreeParameter(); s.Load(element); this.Parameters[i++] = s; } } } XmlElement profilesElement = e["Profiles"]; if (profilesElement != null) { int profileCount = profilesElement.GetAttributeValueAsInt("Count", 0); this.Profiles = new AnimationTreeProfileData[profileCount]; int i = 0; foreach (var element in profilesElement) { if (element.Name == "Profile") { AnimationTreeProfileData p = new AnimationTreeProfileData(); p.Load(element); this.Profiles[i++] = p; } } } XmlElement nodes = e["Nodes"]; //int count = nodes.GetAttributeValueAsInt("Count", 0); Clear(); if (nodes != null) { foreach (var item in nodes) { AnimNodeData node = CreateNode(item); if (node != null) { node.Load(item); this.Add(node); } } } AddRoot(); // create connections XmlElement connections = e["Connections"]; List <ConnectionData> animationConnections = new List <ConnectionData>(); if (connections != null) { foreach (var element in connections) { ConnectionData connection = new ConnectionData(this); connection.Load(element); animationConnections.Add(connection); } } this.Connections = animationConnections.ToArray(); }
public ProfileItem(ProfileEditor editor, AnimationTreeProfileData data) { //this._Editor = editor; this.Data = data; this.Text = data.Name; }
private void Add(AnimationTreeProfileData data) { ProfileItem item = new ProfileItem(this, data); _ProfileList.Items.Add(item); }