예제 #1
0
    private void AddShipObject(string key, ShipData value)
    {
        if (!value.messageID.Equals("0"))
        {
            return;                                 //**원래라면 여기서 장애물 선별해야함.
        }
        ARLocation.Location newLocation = new ARLocation.Location()
        {
            Latitude     = double.Parse(value.latitude),
            Longitude    = double.Parse(value.longitude),
            Altitude     = 0,
            AltitudeMode = ARLocation.AltitudeMode.GroundRelative
        };

        //new object
        GameObject       copyPrefab = Instantiate <GameObject>(_shipObjPrefab);
        ShipObjectScript objSc      = copyPrefab.GetComponent <ShipObjectScript>();

        objSc._mapVC = _mapVC;

        ARLocation.PlaceAtLocation.PlaceAtOptions opts = new ARLocation.PlaceAtLocation.PlaceAtOptions()
        {
            HideObjectUntilItIsPlaced  = true,
            MaxNumberOfLocationUpdates = 1, //** 업데이트 횟 수 관리
            MovementSmoothing          = 0,
            UseMovingAverage           = true
        };

        objSc._mainSceneController = this;
        objSc._userKey             = key;
        objSc.SetShipData(value);

        objSc._placeAtLocationScript = ARLocation.PlaceAtLocation.AddPlaceAtComponentCustom(objSc._placeAtLocationScript, newLocation, opts);

        objSc._placeAtLocationScript.ObjectLocationUpdated.AddListener(ObjectUpdatedEvent); //이벤트 등록 (델리게이트)

        _shipObjs.Add(key, copyPrefab);
    }