private void Injecting(IStageScaler scaler, AvaterProvider avaterProvider, IAnchorTargetProvider anchorTargetProvider) { _stageScaler = scaler; _avaterProvider = avaterProvider; _anchorTargetProvider = anchorTargetProvider; _avaterProvider.OnSpawenAvater.Subscribe(go => { go.transform.SetParent(_rooTransform, false); }); //おおきさ _stageScaler.StageScale .Subscribe(x => { _rooTransform.localScale = Vector3.one * x; }); //むき(未使用) _stageScaler.StageAngle .Subscribe(x => { _rooTransform.rotation = Quaternion.AngleAxis(x, Vector3.up) * Quaternion.identity; }); // タップされた場所を基準座標にする _anchorTargetProvider.OnAncherChangedAsObservable .Subscribe(_ => { _rooTransform.position = _anchorTargetProvider.CurrentAncherTransform.position; }); }
private void Inject( IArCameraTransformProvider cameraTransformProvider, IAnchorTargetProvider anchorTargetProvider, IStageScaler stageScaler) { _target = cameraTransformProvider.CameraTransform; _anchorTargetProvider = anchorTargetProvider; _stageScaler = stageScaler; // 初期化終わったフラグ _isInitialized = true; }
private void Inject(IStageScaler stageScaler, StageController stageController, Configs configs) { _stageScaler = stageScaler; _stageController = stageController; _configs = configs; if (_configs.IsVrMode) { //VRの座標に追従 this.UpdateAsObservable() .Subscribe(_ => { if (_trackingTarget == null) { return; } transform.SetPositionAndRotation(_trackingTarget.position, _trackingTarget.rotation); }); } else { //受信データに追従 this.UpdateAsObservable() .Subscribe(_ => { // スケール計算 var scale = _stageScaler.StageScale.Value * scaleOffset; // 現在の原点座標 var root = _stageController.Root.position; // 線形補間 var np = Vector3.Lerp(transform.position, root + _originalTargetPosition * scale, Time.deltaTime * LerpParam); var nr = Quaternion.Lerp(transform.rotation, _originalTargetRotation, Time.deltaTime * LerpParam); transform.SetPositionAndRotation(np, nr); }); } }