/// <summary>
 /// constructor that takes a task and serialize it into its internal data structure
 /// </summary>
 public SerializableTask(Task t)
 {
     TaskDelay   = t.TaskDelay;
     GOName      = t.GOName;
     TypeName    = t.GetType().Name;
     GameObject  = t.GameObject;
     TaskName    = t.TaskName;
     Description = t.Description;
     TaskEvents  = new List <SerializableTaskEvent>();
     foreach (var taskEvent in t.TaskEvents)
     {
         TaskEvents.Add(new SerializableTaskEvent(taskEvent));
     }
     switch (TypeName)
     {
     case "MovingTask":
     {
         MovingTask castedTask = t as MovingTask;
         Position      = castedTask.Position;
         Rotation      = castedTask.Rotation;
         SnapThreshold = castedTask.SnapThreshold;
         MoveType      = castedTask.MoveType;
     } break;
     }
 }
 /// <summary>
 /// constructor that takes a task and serialize it into its internal data structure
 /// </summary>
 public SerializableTask(Task t)
 {
     GOName      = t.GOName;
     TypeName    = t.GetType().Name;
     GameObject  = t.GameObject;
     TaskName    = t.TaskName;
     Description = t.Description;
     if (t.TaskEvent != null)
     {
         TaskEvent = new SerializableTaskEvent(t.TaskEvent);
     }
     switch (TypeName)
     {
     case "MovingTask":
     {
         MovingTask castedTask = t as MovingTask;
         Position      = castedTask.Position;
         Rotation      = castedTask.Rotation;
         SnapThreshold = castedTask.SnapThreshold;
         MoveType      = castedTask.MoveType;
     } break;
     }
 }
        /// <summary>
        /// display this if the task is of type moving task
        /// </summary>
        /// <param name="t"></param>
        public void DisplayMovingTaskDetail(Task t)
        {
            MovingTask castedt = t as MovingTask;

            // to modify snap threshold
            GUILayout.Label("Distance");
            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            castedt.SnapThreshold = GUILayout.HorizontalSlider(castedt.SnapThreshold, 0.1f, 1f);
            GUILayout.Label(castedt.SnapThreshold.ToString(), GUILayout.Width(30));
            GUILayout.EndHorizontal();

            // move type
            GUILayout.BeginHorizontal();
            GUILayout.Label("Type", GUILayout.Width(30));
            castedt.MoveType = (MovingTaskType)EditorGUILayout.EnumPopup(castedt.MoveType);
            GUILayout.EndHorizontal();

            // to modify goal position
            GUILayout.Label("Goal");
            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            GUILayout.Label("x: ");
            float x = EditorGUILayout.FloatField(castedt.Position.x);

            GUILayout.Label("y: ");
            float y = EditorGUILayout.FloatField(castedt.Position.y);

            GUILayout.Label("z: ");
            float z = EditorGUILayout.FloatField(castedt.Position.z);

            castedt.Position = new Vector3(x, y, z);
            GUILayout.Space(20);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            GUILayout.Label("i: ");
            float i = EditorGUILayout.FloatField(castedt.Rotation.x);

            GUILayout.Label("j: ");
            float j = EditorGUILayout.FloatField(castedt.Rotation.y);

            GUILayout.Label("k: ");
            float k = EditorGUILayout.FloatField(castedt.Rotation.z);

            GUILayout.Label("w: ");
            float w = EditorGUILayout.FloatField(castedt.Rotation.w);

            castedt.Rotation = new Quaternion(i, j, k, w);
            GUILayout.Space(20);
            GUILayout.EndHorizontal();

            // easily get the go current position as the goal pos
            if (GUILayout.Button("Use Current GO Position and rotation"))
            {
                if (castedt.GameObject != null)
                {
                    castedt.Position = obj.transform.InverseTransformPoint(t.GameObject.transform.position);
                    castedt.Rotation = Quaternion.Inverse(obj.transform.rotation) * t.GameObject.transform.rotation;
                }
            }
        }