/// <summary> Removes a command </summary> /// <param name="beh"> The command in question </param> public void Shorten(ICommandBehaviour beh) { var rectT = beh.Obj.GetComponent <RectTransform>(); float d_size = rectT.rect.height; total.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, total.rect.height - d_size); total.position += new Vector3(0, d_size / 2); if (after != null) { after.Translate(new Vector3(0, d_size)); } int beh_indx = commands.IndexOf(beh); commands.Remove(beh); for (int i = beh_indx; i < commands.Count; i++) { commands [i].Obj.transform.position += new Vector3(0, d_size); } }
/// <summary> Adds a command </summary> /// <param name="beh"> The command in question </param> private void Add(ICommandBehaviour beh) { var rectT = beh.Obj.GetComponent <RectTransform>(); rectT.SetParent(transform); float d_size = rectT.rect.height; total.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, total.rect.height + d_size); total.position -= new Vector3(0, d_size / 2); if (after != null) { after.Translate(new Vector3(0, -d_size)); } beh.Obj.transform.position = content.position + new Vector3(0, content.rect.yMin + d_size / 2); beh.Parent = this; commands.Add(beh); }