private GroupTask GenerateGroupTask(GroupContent groupContent, PM_Task task) { GroupTask taskObject = UtilityMethod.CreateObjectToParent(groupContent.transform, GroupTaskPrefab).GetComponent <GroupTask>(); return(taskObject); }
private void GenerateGanttChart(PM_Picture picture) { UtilityMethod.ClearChildObject(GanttLeftPanel); UtilityMethod.ClearChildObject(GanttRightPanel); foreach (PM_Group group in picture.groups) { GroupTitle title = GenerateGroupTitle(group); GroupContent content = GenerateGroupContent(group); int contentHeight = 0; int taskLength = group.tasks.Length; for (int i = 0; i < taskLength; i++) { PM_Task task = group.tasks[i]; GroupTask groupTask = GenerateGroupTask(content, task); Debug.Log("Task time " + task.start_time + " , duration " + task.duration); Vector2 anchoredPos = groupTask.rectTran.anchoredPosition; float baseAnchorX = task.duration / 2f; groupTask.rectTran.anchoredPosition = new Vector2(pm_utility.GetTimeToWorldValue(task.start_time) + baseAnchorX, anchoredPos.y - contentHeight); SetObjectSize(groupTask, new Vector2(pm_utility.GetTimeToWorldValue(task.duration), groupTask.rectTran.sizeDelta.y)); contentHeight += (int)groupTask.rectTran.sizeDelta.y; } SetObjectSize(content, new Vector2(content.rectTran.sizeDelta.x, contentHeight)); SetObjectSize(title, new Vector2(title.rectTran.sizeDelta.x, contentHeight)); } }