private void CurveEditor() { if (spline == null) { spline = master.spline; } EditorGUI.BeginChangeCheck(); if (GUILayout.Button("Add Curve")) { Undo.RecordObject(spline, "Add Curve"); spline.AddCurve(selectedIndex); selectedIndex = -1; EditorUtility.SetDirty(spline); } if (GUILayout.Button("Remove Curve")) { Undo.RecordObject(spline, "Remove Curve"); spline.RemoveCurve(selectedIndex); selectedIndex = -1; EditorUtility.SetDirty(spline); } if (GUILayout.Button("Reset")) { Undo.RecordObject(spline, "Reset"); spline.Reset(); master.Reset(); selectedIndex = -1; EditorUtility.SetDirty(spline); } GUILayout.BeginVertical("box"); GUILayout.Space(5); bool loop = EditorGUILayout.Toggle("Loop", spline.Loop); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(spline, "Toggle Loop"); EditorUtility.SetDirty(spline); spline.Loop = loop; } GUILayout.Label(" Curve Lenght: " + spline.GetCurveLenght()); GUILayout.Space(5); GUILayout.EndVertical(); if (selectedIndex >= 0 && selectedIndex < spline.ControlPointCount) { DrawSelectedPointInspector(); } else { GUILayout.BeginVertical("box"); GUILayout.Space(5); GUILayout.Label(" Select point to edit!"); GUILayout.Space(5); GUILayout.EndVertical(); } }
void RpcUpdateToClients(Vector3 pointToGen) { //if is local then don't need to do this // if(hasAuthority){ // return; // } if (firstTime == true) { usingOfSpline = Using.Mesh; meshType = MeshType.Cylinder; CreateCylinderMesh(); firstTime = false; } spline.AddCurve(pointToGen); UpdateMesh(); Debug.Log("update in CLIENT"); }
void Update() { //set stop when user stops drawing if (stop) { return; } if (Input.touchCount < 1) { return; } Touch touch = Input.GetTouch(0); //if the user released, then the icecream making is done, so activate move script to move the icecream if (touchedIcecream && (touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled)) { stop = true; Debug.Log("entered stop"); //set the movescript on icecream icecreamTransform.gameObject.GetComponent <GoogleARCore.Examples.HelloAR.MoveScript>().enabled = true; } countTouch += 1; if (countTouch % 3 != 0) { return; } Ray raycast = Camera.main.ScreenPointToRay(touch.position); //Ray raycast = Camera.main.ScreenPointToRay(Input.mousePosition); //set the distance by checking the distance of the cone if (!touchedIcecream) { RaycastHit raycastHit; if (Physics.Raycast(raycast, out raycastHit)) { if (raycastHit.transform.tag == "icecream") { icecreamTransform = raycastHit.transform; coneDistance = raycastHit.distance; touchedIcecream = true; } } } else { prevPosition = touchPoint; //inverse transform point transforms the coordinates to local instead of global touchPoint = transform.InverseTransformPoint(raycast.GetPoint(coneDistance)); if (Vector3.Distance(prevPosition, touchPoint) > 0.05f) { if (firstTime == true) { usingOfSpline = Using.Mesh; meshType = MeshType.Cylinder; CreateCylinderMesh(); firstTime = false; } spline.AddCurve(touchPoint); UpdateMesh(); } } }