| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- using System;
- using UnityEngine;
- namespace ET
- {
- [ObjectSystem]
- public class OperaComponentAwakeSystem : AwakeSystem<OperaComponent>
- {
- public override void Awake(OperaComponent self)
- {
- self.Awake();
- }
- }
- [ObjectSystem]
- public class OperaComponentUpdateSystem : UpdateSystem<OperaComponent>
- {
- public override void Update(OperaComponent self)
- {
- self.Update();
- }
- }
- public class OperaComponent: Entity
- {
- public Vector3 ClickPoint;
- public int mapMask;
- public void Awake()
- {
- this.mapMask = LayerMask.GetMask("Map");
- }
- private readonly Frame_ClickMap frameClickMap = new Frame_ClickMap();
- public void Update()
- {
- if (Input.GetMouseButtonDown(1))
- {
- Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
- RaycastHit hit;
- if (Physics.Raycast(ray, out hit, 1000, this.mapMask))
- {
- this.ClickPoint = hit.point;
- frameClickMap.X = this.ClickPoint.x;
- frameClickMap.Y = this.ClickPoint.y;
- frameClickMap.Z = this.ClickPoint.z;
- SessionComponent.Instance.Session.Send(frameClickMap);
- // 测试actor rpc消息
- this.TestActor().Coroutine();
- }
- }
- }
- public async ETVoid TestActor()
- {
- try
- {
- M2C_TestActorResponse response = (M2C_TestActorResponse)await SessionComponent.Instance.Session.Call(
- new C2M_TestActorRequest() { Info = "actor rpc request" });
- Log.Info(response.Info);
- }
- catch (Exception e)
- {
- Log.Error(e);
- }
- }
- }
- }
|