void Start() { fluidColor = Color.green; stencil = null; snapping = false; fluidEnabled = false; materialIndex = 0; paintLines = new PaintLine[pinchDetectors.Length]; for (int i = 0; i < pinchDetectors.Length; i++) { paintLines[i] = new PaintLine(this); } for (int i = 0; i < paintLines.Length; i++) { for (int j = 0; j < paintLines[i].copyMaterials.Length; j++) { paintLines [i].copyMaterials [j].color = Color.green; } } fluidColor = Color.green; }
/// <summary> /// Create paint line. /// </summary> /// <param name="position">Position.</param> private void CreatePaintLine(Vector3 position) { if (paintLinePrefab == null) { return; } GameObject paintLine = Instantiate(paintLinePrefab, Vector3.zero, Quaternion.identity) as GameObject; paintLine.name = "PaintLine"; paintLine.transform.SetParent(transform); paintLine.layer = transform.gameObject.layer; paintLine.GetComponent <RectTransform>().anchoredPosition3D = Vector3.zero; PaintLine pl = paintLine.GetComponent <PaintLine>(); if (pl == null) { return; } pl.lineRenderer.material = material; pl.lineRenderer.colorGradient = color; pl.lineRenderer.sortingOrder = sortingOrder; Vector3 targetPosition = position; targetPosition.y -= Random.Range(0.2f, 5.3f);//控制油笔下降程度 pl.SetWidthDetails(Random.Range(startWidth * 0.2f, startWidth * 0.7f), Random.Range(startWidth * 0.1f, startWidth * 0.4f)); float moveWidthSpeed = Random.Range(0.1f, 6); pl.SetMoveLerpSpeed(moveWidthSpeed); pl.SetWidthLerpSpeed(moveWidthSpeed); pl.SetPointsDetails(position, targetPosition); pl.Begin(); }