/// <summary> /// アンカーの可視化に利用するGameobjectを生成します。 /// </summary> /// <param name="isDestination">中継点か目的地かを判定するフラグ</param> public void CreateAnchorObject(bool isDestination) { try { Menu.ChangeStatus(RouteGuideMenu.MODE_CREATE_ANCHOR); this.isDestination = isDestination; if (currentAnchorObject == null) { currentAnchorObject = settingPointAnchor.gameObject; } var dest = AnchorGenerateFactory.GenerateSettingsPointAnchor(isDestination ? SettingPointAnchor.AnchorMode.Destination : SettingPointAnchor.AnchorMode.Point); currentLinkLine = LinkLineGenerateFactory.CreateLinkLineObject(currentAnchorObject, dest.gameObject, AnchorCollection.transform); currentAnchorObject = dest.gameObject; currentAnchorObject.transform.parent = AnchorCollection.transform; currentAnchorObject.transform.position = Camera.main.transform.position + Camera.main.transform.forward * 1f; } catch (Exception e) { Debug.Log(e); throw; } }
/// <summary> /// Spatial Anchorの可視化に必要なオブジェクトの生成を行います。 /// Spatial Anchorの設置が完了した場合に発生するイベント内で実行されます。 /// </summary> /// <param name="identifier">AnchorId</param> /// <param name="appProperties">Spatial Anchorに含まれるAppProperties</param> /// <param name="gameObject">可視化に利用するオブジェクト</param> /// <returns>アンカーの設置対象か。trueの場合設置対象</returns> public bool OnLocatedAnchorObject(string identifier, IDictionary <string, string> appProperties, out GameObject gameObject) { try { appProperties.TryGetValue(RouteGuideInformation.ANCHOR_TYPE, out var anchorType); var destinations = new string[0]; if (appProperties.TryGetValue(RouteGuideInformation.DESTINATION_TITLE, out var destination)) { destinations = destination.Split(','); } // 指定ルート以外のアンカー情報に対しては可視化を行わない。 if (!destinations.Any(x => x.Equals(Destination))) { gameObject = null; return(false); } DestinationPointAnchor point; if (!RouteInfo.LocatedAnchors.ContainsKey(identifier)) { //アンカーの可視化が完了していない場合はアンカーを生成する。 point = AnchorGenerateFactory.GenerateDestinationPointAnchor(RouteInfo.RootPointObjects); gameObject = point.gameObject; lock (lockObj) { RouteInfo.LocatedAnchors.Add(identifier, new RouteGuideInformation.AnchorInfo(appProperties, point.gameObject, currentAnchorId.Equals(RouteGuideInformation.ANCHOR_ID_NOT_INITIALIZED))); } } else { //すでにアンカーが可視化されている場合はそのオブジェクトを取得する。 gameObject = RouteInfo.LocatedAnchors[identifier].AnchorObject; point = gameObject.GetComponent <DestinationPointAnchor>(); RouteInfo.LocatedAnchors[identifier] = new RouteGuideInformation.AnchorInfo(appProperties, gameObject, currentAnchorId.Equals(RouteGuideInformation.ANCHOR_ID_NOT_INITIALIZED)); } currentAnchorId = identifier; if (point != null) { point.Identifier = identifier; if (RouteGuideInformation.ANCHOR_TYPE_DESTINATION.Equals(anchorType)) { point.DestinationTitle = destination; } } return(true); } catch (Exception e) { Debug.Log(e); throw; } }