示例#1
0
        public virtual async Task SetIsVisibleAsync(bool isVisible, float?fadeTime = null)
        {
            if (fadeTweener.IsRunning)
            {
                fadeTweener.Stop();
            }

            this.isVisible = isVisible;

            OnVisibilityChanged.SafeInvoke(isVisible);

            if (!CanvasGroup)
            {
                return;
            }

            CanvasGroup.interactable   = isVisible;
            CanvasGroup.blocksRaycasts = isVisible;

            var fadeDuration  = fadeTime ?? FadeTime;
            var targetOpacity = isVisible ? 1f : 0f;

            if (fadeDuration == 0f)
            {
                CanvasGroup.alpha = targetOpacity;
                return;
            }

            var tween = new FloatTween(CanvasGroup.alpha, targetOpacity, fadeDuration, alpha => CanvasGroup.alpha = alpha);
            await fadeTweener.RunAsync(tween);
        }
示例#2
0
    public void UpdateTerrainChunk()
    {
        if (lodMeshes == null)
        {
            // meshes are cleared
            return;
        }

        if (!heightMapReceived)
        {
            return;
        }

        // Effecient way to check chunk distance
        float viewerDstFromNearestEdge = Mathf.Sqrt(bounds.SqrDistance(viewerPosition));

        // To check for removal
        bool wasVisible = IsVisible();
        bool visible    = viewerDstFromNearestEdge <= maxViewDst;

        if (visible)
        {
            int lodIndex = 0;
            for (int i = 0; i < detailLevels.Length - 1; i++)
            {
                // In the last case, chunk will not be visible
                if (viewerDstFromNearestEdge > detailLevels[i].visibleDstThreshold)
                {
                    lodIndex = i + 1;
                }
                else
                {
                    break;
                }
            }

            if (lodIndex != prevLODIndex)
            {
                LODMesh lodMesh = lodMeshes[lodIndex];
                if (lodMesh.hasMesh)
                {
                    prevLODIndex    = lodIndex;
                    meshFilter.mesh = lodMesh.mesh;
                }
                else if (!lodMesh.hasRequestedMesh)
                {
                    lodMesh.RequestMesh(heightMap, meshSettings);
                }
            }
        }

        if (wasVisible != visible)
        {
            SetVisible(visible);
            if (OnVisibilityChanged != null)
            {
                OnVisibilityChanged.Invoke(this, visible);
            }
        }
    }
示例#3
0
 internal protected virtual void TriggerOnVisibilityChanged(Component sender, bool state)
 {
     if (OnVisibilityChanged != null)
     {
         OnVisibilityChanged.Invoke(new BoolStateEventArgs(sender, state));
     }
 }
        public void Show()
        {
            if (IsVisible)
            {
                return;
            }

            Logger.Debug("Showing orbits");
            m_hideOrbitCommands.Undo();
            m_hideOrbitCommands = new CommandSet();
            IsVisible           = true;
            OnVisibilityChanged?.Invoke(true);
        }
        public void Hide()
        {
            if (!IsVisible)
            {
                return;
            }

            Logger.Debug("Hiding orbits");
            CreateHideVesselCommands(m_hideOrbitCommands);
            CreateHideBodiesCommands(m_hideOrbitCommands);
            m_hideOrbitCommands.Execute();
            IsVisible = false;
            OnVisibilityChanged?.Invoke(false);
        }
示例#6
0
        public void UpdateTerrainChunk()
        {
            if (!DataMapReceived || Viewer?.ViewerType == TerrainViewer.ViewerTypes.secondary)
            {
                return;
            }

            float viewerDstFromNearestEdge = Mathf.Sqrt(Bounds.SqrDistance(ViewerPosition));

            bool wasVisible = IsVisible;
            bool visible    = viewerDstFromNearestEdge <= MaxViewDistance;

            if (visible)
            {
                int lodIndex = 0;

                for (int i = 0; i < detailLevels.Length - 1; i++)
                {
                    if (viewerDstFromNearestEdge > detailLevels[i].VisibleDistanceThreshold)
                    {
                        lodIndex = i + 1;
                    }
                    else
                    {
                        break;
                    }
                }

                if (lodIndex != CurrentLODIndex)
                {
                    LODMesh lodMesh = lodMeshes[lodIndex];
                    if (lodMesh.HasMesh)
                    {
                        CurrentLODIndex = lodIndex;
                        meshFilter.mesh = lodMesh.Mesh;
                    }
                    else if (!lodMesh.HasRequestedMesh)
                    {
                        lodMesh.RequestMesh(DataMap.HeightMap, MeshSettings);
                    }
                }
            }

            if (wasVisible != visible)
            {
                SetVisible(visible);
                OnVisibilityChanged?.Invoke(this, visible);
            }
        }
        public void Show()
        {
            Log.Info("OrbitVisibilityController.Show");

            if (IsVisible)
            {
                return;
            }

            Log.Debug("Showing orbits");
            m_hideOrbitCommands.Undo();
            m_hideOrbitCommands = new CommandSet();
            IsVisible           = true;
            OnVisibilityChanged?.Invoke(true);
        }
示例#8
0
文件: Menu.cs 项目: Wiciaki/SparkTech
        internal static void SetOpen(bool open)
        {
            if (IsOpen == open)
            {
                return;
            }

            IsOpen = open;

            if (!open)
            {
                SaveHandlers.ForEach(handler => handler.Save());
            }

            OnVisibilityChanged.SafeInvoke(EventArgs.Empty);
        }
示例#9
0
        //Public Methods:
        public void Update()
        {
            //set visibility:
            if (Hand.HandConfidence > .85f && !Visible)
            {
                Visible = true;
                OnVisibilityChanged?.Invoke(this, true);
            }
            else if (Hand.HandConfidence <= .85f && Visible)
            {
                Visible = false;
                OnVisibilityChanged?.Invoke(this, false);
            }

            Skeleton.Update();
            Gesture.Update();
        }
示例#10
0
    public void UpdateTerrainChunk()
    {
        if (mapReceived)
        {
            float viewerDistanceFromNearestEdge = Mathf.Sqrt(bounds.SqrDistance(ViewerPosition));

            bool wasVisible = IsVisible();
            bool visible    = viewerDistanceFromNearestEdge <= maxViewDistance;

            if (visible)
            {
                int lodIndex = 0;
                for (int i = 0; i < detailLevels.Length - 1; i++)
                {
                    if (viewerDistanceFromNearestEdge > detailLevels[i].visibleDistanceThreshold)
                    {
                        lodIndex = i + 1;
                    }
                    else
                    {
                        break;
                    }
                }

                if (lodIndex != previousLODIndex)
                {
                    LODMesh lodMesh = lodMeshes[lodIndex];
                    if (lodMesh.hasMesh)
                    {
                        previousLODIndex = lodIndex;
                        meshFilter.mesh  = lodMesh.mesh;
                    }
                    else if (!lodMesh.hasRequestedMesh)
                    {
                        lodMesh.RequestMesh(heightMap.values, meshSettings);
                    }
                }
            }

            if (wasVisible != visible)
            {
                SetVisible(visible);
                OnVisibilityChanged?.Invoke(this, visible);
            }
        }
    }
示例#11
0
        //Constructors:
        public ManagedFinger(MLHand hand, params ManagedKeypoint[] points)
        {
            //sets:
            _hand            = hand;
            this.points      = points;
            _lastReliableEnd = points[0];

            //hooks:
            foreach (var item in points)
            {
                item.OnFound += HandlePointVisibilityChanged;
                item.OnLost  += HandlePointVisibilityChanged;
            }

            //initial events:
            OnVisibilityChanged?.Invoke(false);
            HandlePointVisibilityChanged();
        }
示例#12
0
        public void UpdateTerrainChunk(bool force)
        {
            // Debug.Log($"[HeightmapReceived={_heightMapReceived}] Updating terrain chunk.");

            if (_heightMapReceived || force)
            {
                var viewerDstFromNearestEdge = Mathf.Sqrt(_bounds.SqrDistance(ViewerPosition));

                var wasVisible = IsVisible();
                var visible = viewerDstFromNearestEdge <= _maxViewDst;

                if (visible)
                {
                    var lodIndex = 0;

                    for (var i = 0; i < _detailLevels.Length - 1; i++)
                        if (viewerDstFromNearestEdge > _detailLevels[i].visibleDstThreshold)
                            lodIndex = i + 1;
                        else
                            break;

                    if (lodIndex != _previousLodIndex)
                    {
                        var lodMesh = _lodMeshes[lodIndex];
                        if (lodMesh.HasMesh)
                        {
                            _previousLodIndex = lodIndex;
                            _meshFilter.mesh = lodMesh.Mesh;
                        }
                        else if (!lodMesh.HasRequestedMesh)
                        {
                            lodMesh.RequestMesh(_heightMap, _meshSettings);
                        }
                    }
                }

                if (wasVisible != visible)
                {
                    SetVisible(visible);
                    OnVisibilityChanged?.Invoke(this, visible);
                }
            }
        }
示例#13
0
        public virtual void SetIsVisible(bool isVisible)
        {
            if (fadeTweener.IsRunning)
            {
                fadeTweener.Stop();
            }

            this.isVisible = isVisible;

            OnVisibilityChanged.SafeInvoke(isVisible);

            if (!CanvasGroup)
            {
                return;
            }

            CanvasGroup.interactable   = isVisible;
            CanvasGroup.blocksRaycasts = isVisible;

            CanvasGroup.alpha = isVisible ? 1f : 0f;
        }
示例#14
0
    public void UpdateChunk()
    {
        if (!heightMapReceived)
        {
            return;
        }
        float viewDistanceFromNearestEdge = Mathf.Sqrt(bounds.SqrDistance(viewerPosition));
        bool  wasVisible = IsVisible();
        bool  visible    = viewDistanceFromNearestEdge <= maxViewDistance;

        if (visible)
        {
            int terrainLODIndex = 0;
            for (; terrainLODIndex < detailLevels.Length - 1; terrainLODIndex++)
            {
                if (detailLevels[terrainLODIndex].visibleDistanceThreshold >= viewDistanceFromNearestEdge)
                {
                    break;
                }
            }
            if (terrainLODIndex != previousLODIndex)
            {
                LODMesh lodMesh = lodMeshes[terrainLODIndex];
                if (lodMesh.hasMesh)
                {
                    previousLODIndex = terrainLODIndex;
                    meshFilter.mesh  = lodMesh.mesh;
                }
                else if (!lodMesh.hasRequestedMesh)
                {
                    lodMesh.RequestMesh(heightMap, meshSettings);
                }
            }
        }
        if (wasVisible != visible)
        {
            SetVisible(visible);
            OnVisibilityChanged?.Invoke(this, visible);
        }
    }
示例#15
0
        //Public Methods:
        public void Update()
        {
            //set visibility:
            if (Hand.HandConfidence > .85f && !Visible)
            {
                Visible = true;
                OnVisibilityChanged?.Invoke(this, true);
            }
            else if (Hand.HandConfidence <= .85f && Visible)
            {
                Visible = false;
                OnVisibilityChanged?.Invoke(this, false);
            }

            Skeleton.Update();
            Gesture.Update();
            Collider.Update(_handInput.palmCollisions);
            if (_handInput != null)
            {
                Collider.Update(_handInput.palmCollisions);
            }
        }
示例#16
0
        //Public Methods:
        public void Update()
        {
            //set visibility:
            if (Hand.HandConfidence > .85f && !Visible)
            {
                Visible = true;
                OnVisibilityChanged?.Invoke(this, true);
            }
            else if (Hand.HandConfidence <= .85f && Visible)
            {
                Visible = false;
                OnVisibilityChanged?.Invoke(this, false);
            }

            Skeleton.Update();
            Gesture.Update();

            // Modified here by prnvcher to not explode if using null hand input
            if (_handInput != null)
            {
                Collider?.Update(_handInput.palmCollisions);
            }
        }
示例#17
0
        //Public Methods:
        public void Update()
        {
            //set visibility:
            if (Hand.HandConfidence > .85f && !Visible)
            {
                Visible = true;
                OnVisibilityChanged?.Invoke(this, true);
            }
            else if (Visible)
            {
                IntentPose pose          = Gesture.Intent;
                var        isPinching    = (pose == IntentPose.Grasping || pose == IntentPose.Pinching);
                float      minConfidence = isPinching ? .80f : .85f;
                if (Hand.HandConfidence <= minConfidence)
                {
                    Visible = false;
                    OnVisibilityChanged?.Invoke(this, false);
                }
            }

            Skeleton.Update();
            Gesture.Update();
        }
示例#18
0
 public void InvokeVisibilityChangedEvent(bool value)
 {
     OnVisibilityChanged?.Invoke(value);
     onVisibilityChanged?.Invoke(value);
 }
示例#19
0
 public void FireLostEvent()
 {
     IsVisible = false;
     OnVisibilityChanged?.Invoke(this, false);
 }
示例#20
0
 //Public Methods:
 public void FireFoundEvent()
 {
     IsVisible = true;
     OnVisibilityChanged?.Invoke(this, true);
 }
示例#21
0
        public void UpdateTerrainChunk()
        {
            if (!_heightMapReceived)
            {
                return;
            }

            var viewerDistanceFromNearestEdge = Mathf.Sqrt(_bounds.SqrDistance(viewerPosition));
            var wasVisible = IsVisible();
            var visible    = viewerDistanceFromNearestEdge <= _maxViewDistance;

            if (visible)
            {
                var lodIndex = 0;
                for (var i = 0; i < _detailLevels.Length - 1; i++)
                {
                    if (viewerDistanceFromNearestEdge > _detailLevels[i].visibleDistanceThreshold)
                    {
                        lodIndex = i + 1;
                    }
                    else
                    {
                        break;
                    }
                }

                if (lodIndex != _prevLODIndex)
                {
                    var lodMesh = _lodMeshes[lodIndex];
                    if (lodMesh.hasMesh)
                    {
                        _prevLODIndex    = lodIndex;
                        _meshFilter.mesh = lodMesh.mesh;

                        if (!_droidsRequested)
                        {
                            CreateInitialDroids(lodMesh.meshVertices);
                        }
                        if (!_meshDatSentForTower)
                        {
                            BuildingAndTowerSpawner.instance
                            .AddTerrainData(lodMesh.meshVertices, _sampleCenter, _meshObject.transform, _bounds);
                            _meshDatSentForTower = true;
                        }
                    }
                    else if (!lodMesh.hasRequestedMesh)
                    {
                        lodMesh.RequestMesh(_heightMap, _meshSettings);
                    }

                    if (lodIndex == 0 && lodMesh.hasMesh)
                    {
                        LOD0ValidStateAvailable(lodMesh);
                    }
                    else if (lodIndex != 0)
                    {
                        _chunkTrees.ClearTrees();
                    }
                }
            }

            if (wasVisible != visible)
            {
                SetVisible(visible);
                OnVisibilityChanged?.Invoke(this, visible);
            }
        }
示例#22
0
 private void TriggerVisibilityChangedEvent()
 {
     OnVisibilityChanged.InvokeSafely(IsVisible, transform.position);
     OnVisibilityChangedEvent.Invoke(IsVisible, transform.position);
 }
示例#23
0
 void HideAction(string[] args)
 {
     OnVisibilityChanged?.Invoke(false);
 }