// Start is called before the first frame update void Start() { this.root = GameObject.Find("Robot"); this.myObject = GameObject.Find("Robot/" + this.transform.name); this.parts = myObject.GetComponentInChildren <Hakoniwa.Assets.EV3.IEV3Parts>(); this.isConnected = false; this.InitActuator(); this.InitSensor(); this.writer = this.myObject.GetComponentInChildren <IoWriter>(); this.reader = this.myObject.GetComponentInChildren <IoReader>(); this.reader.Initialize(); this.reader.SetCallback(UdpServerCallback); }
public void Initialize() { this.root = GameObject.Find("Robot"); this.myObject = GameObject.Find("Robot/" + this.transform.name); this.parts = myObject.GetComponentInChildren <Hakoniwa.Assets.EV3.IEV3Parts>(); this.isConnected = false; this.InitActuator(); this.InitSensor(); GameObject hakoniwa = GameObject.Find("Hakoniwa"); HakoniwaConfig hakoniwa_cfg = hakoniwa.GetComponentInChildren <Hakoniwa.Core.HakoniwaConfig>(); if (hakoniwa_cfg == null) { UnityEngine.Debug.LogError("Not found hakoniwa_cfg : " + hakoniwa_cfg); return; } this.writer = this.myObject.GetComponentInChildren <IoWriter>(); this.reader = this.myObject.GetComponentInChildren <IoReader>(); this.robotConfig = hakoniwa_cfg.GetRobotConfig(this.transform.name); if (robotConfig == null) { UnityEngine.Debug.LogError("Not found hakoniwa_robot_cfg : " + robotConfig); return; } if (hakoniwa_cfg.IsMmap(robotConfig)) { this.writer.filepath = hakoniwa_cfg.GetRobotMmapWriterFilePath(this.transform.name); this.reader.filepath = hakoniwa_cfg.GetRobotMmapReaderFilePath(this.transform.name); this.writer.InitializeMmap(); this.reader.InitializeMmap(); } else { this.writer.host = hakoniwa_cfg.GetRobotConfig(this.transform.name).Udp.AthrillIpAddr; this.writer.port = hakoniwa_cfg.GetRobotConfig(this.transform.name).Udp.AthrillPort; this.reader.port = hakoniwa_cfg.GetRobotConfig(this.transform.name).Udp.UnityPort; this.writer.Initialize(); this.reader.Initialize(); } this.reader.SetCallback(UdpServerCallback); }