/// <summary> /// Determine whether this instance is current path or not. /// </summary> /// <returns><c>true</c> if this instance is current path; otherwise, <c>false</c>.</returns> /// <param name="path">Path.</param> public bool IsCurrentPath(EnglishTracingBook.Path path) { bool isCurrentPath = false; if (!enablePriorityOrder) { return(true); } if (path == null) { return(isCurrentPath); } isCurrentPath = true; for (int i = 0; i < paths.Count; i++) { if (paths [i].GetInstanceID() == path.GetInstanceID()) { for (int j = 0; j < i; j++) { if (!paths [j].completed) { isCurrentPath = false; break; } } break; } } return(isCurrentPath); }
public override void OnInspectorGUI() { EnglishTracingBook.Path path = (EnglishTracingBook.Path)target; //get the target EditorGUILayout.Separator(); path.fillMethod = (EnglishTracingBook.Path.FillMethod)EditorGUILayout.EnumPopup("Fill Method", path.fillMethod); if (path.fillMethod == EnglishTracingBook.Path.FillMethod.Linear) { path.type = (EnglishTracingBook.Path.ShapeType)EditorGUILayout.EnumPopup("Type", path.type); path.offset = EditorGUILayout.Slider("Angle Offset", path.offset, -360, 360); path.flip = EditorGUILayout.Toggle("Flip Direction", path.flip); } else if (path.fillMethod == EnglishTracingBook.Path.FillMethod.Radial) { path.quarterRestriction = EditorGUILayout.Toggle("Quarter Restriction", path.quarterRestriction); path.radialAngleOffset = EditorGUILayout.Slider("Radial Offset", path.radialAngleOffset, -360, 360); } path.completeOffset = EditorGUILayout.Slider("Complete Offset", path.completeOffset, 0, 1); path.firstNumber = EditorGUILayout.ObjectField("First Number", path.firstNumber, typeof(Transform)) as Transform; if (path.fillMethod != EnglishTracingBook.Path.FillMethod.Point) { path.secondNumber = EditorGUILayout.ObjectField("Second Number", path.secondNumber, typeof(Transform)) as Transform; } }
/// <summary> /// On the start hit collider event. /// </summary> /// <param name="hit2d">Hit2d.</param> private void OnStartHitCollider(RaycastHit2D hit2d) { path = hit2d.transform.GetComponentInParent <EnglishTracingBook.Path> (); pathFillImage = CommonUtil.FindChildByTag(path.transform, "Fill").GetComponent <Image> (); if (path.completed || !shape.IsCurrentPath(path)) { ReleasePath(); } else { path.StopAllCoroutines(); CommonUtil.FindChildByTag(path.transform, "Fill").GetComponent <Image> ().color = currentPencil.value; } if (path != null) { if (!path.shape.enablePriorityOrder) { shape = path.shape; } } }
/// <summary> /// Release the path. /// </summary> private void ReleasePath() { path = null; pathFillImage = null; }