usingSystem.Threading.Tasks;usingUnityEngine;usingGrpc.Core;usingProto.Services;usingProto.Messages;publicclassSetPositionServer:MonoBehaviour{publicPositionTestServerServicemy_class_variable=newPositionTestServerService();privatevoidStart(){varserver=newServer(){Services={SetPositionService.BindService(my_class_variable)},Ports={newServerPort("localhost",50052,ServerCredentials.Insecure)}};server.Start();}privatevoidUpdate(){//transform.position = transform.position + new Vector3(0 * Time.deltaTime, 2 * Time.deltaTime, 0 * Time.deltaTime);//Debug.Log(Time.time);if(Time.time>5){gameObject.SetActive(false);Debug.Log(my_class_variable.posx);gameObject.transform.position=newVector3(my_class_variable.posx,my_class_variable.posy,my_class_variable.posz);gameObject.transform.rotation=Quaternion.Euler(my_class_variable.rotx,my_class_variable.roty,my_class_variable.rotz);gameObject.SetActive(true);}}}publicclassPositionTestServerService:SetPositionService.SetPositionServiceBase{publicfloatposx=0;publicfloatposy=0;publicfloatposz=0;publicfloatrotx=0;publicfloatroty=0;publicfloatrotz=0;publicoverrideTask<Response>SetPosition(Requestrequest,ServerCallContextcontext){// ???????????????varhello=$"SetPosition X = {request.X}, Y = {request.Y}, Z = {request.Z}";varresponse=newResponse{ResponseMessage=hello};posx=request.X;posy=request.Y;posz=request.Z;returnTask.FromResult(response);}publicoverrideTask<Response>SetRotation(Requestrequest,ServerCallContextcontext){// ???????????????varhello=$"SetRotation X = {request.X}, Y = {request.Y}, Z = {request.Z}";varresponse=newResponse{ResponseMessage=hello};rotx=request.X;roty=request.Y;rotz=request.Z;returnTask.FromResult(response);}}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.