public override void OnInspectorGUI() { TR_Path path = (TR_Path)target;//get the target EditorGUILayout.Separator(); path.fillMethod = (TR_Path.FillMethod)EditorGUILayout.EnumPopup("Fill Method", path.fillMethod); if (path.fillMethod == TR_Path.FillMethod.Linear) { path.type = (TR_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 == TR_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 != TR_Path.FillMethod.Point) { path.secondNumber = EditorGUILayout.ObjectField("Second Number", path.secondNumber, typeof(Transform)) as Transform; } }
/// <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(TR_Path path) { bool isCurrentPath = false; 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); }
/// <summary> /// On the start hit collider event. /// </summary> /// <param name="hit2d">Hit2d.</param> private void OnStartHitCollider(RaycastHit2D hit2d) { path = hit2d.transform.GetComponentInParent <TR_Path> (); pathFillImage = TR_CommonUtil.FindChildByTag(path.transform, "Fill").GetComponent <Image> (); if (path.completed || !shape.IsCurrentPath(path)) { ReleasePath(); } else { path.StopAllCoroutines(); TR_CommonUtil.FindChildByTag(path.transform, "Fill").GetComponent <Image> ().color = currentPencilColor; } }
/// <summary> /// Release the path. /// </summary> private void ReleasePath() { path = null; pathFillImage = null; }