Beispiel #1
0
        /// <summary>
        /// Profiling Scope constructor
        /// </summary>
        /// <param name="cmd">Command buffer used to add markers and compute execution timings.</param>
        /// <param name="sampler">Profiling Sampler to be used for this scope.</param>
        public ProfilingScope(CommandBuffer cmd, ProfilingSampler sampler)
        {
            m_Cmd      = cmd;
            m_Disposed = false;
            if (sampler != null)
            {
                m_Name          = sampler.name; // Don't use CustomSampler.name because it causes garbage
                m_Sampler       = sampler.sampler;
                m_InlineSampler = sampler.inlineSampler;
            }
            else
            {
                m_Name          = "NullProfilingSampler"; // Don't use CustomSampler.name because it causes garbage
                m_Sampler       = null;
                m_InlineSampler = null;
            }

            if (cmd != null)
#if UNITY_USE_RECORDER
            { if (m_Sampler != null)
              {
                  cmd.BeginSample(m_Sampler);
              }
              else
              {
                  cmd.BeginSample(m_Name);
              } }
#else
            { cmd.BeginSample(m_Name); }
#endif
            m_InlineSampler?.Begin();
        }
 public ProfilingSample(CommandBuffer cmd, string name, CustomSampler sampler = null)
 {
     m_Cmd      = cmd;
     m_Name     = name;
     m_Disposed = false;
     cmd?.BeginSample(name);
     m_Sampler = sampler;
     m_Sampler?.Begin();
 }
Beispiel #3
0
        /// <summary>
        ///     Execute the manager immediately.
        /// </summary>
        public void Update()
        {
#if UNITY_EDITOR
            m_Sampler?.Begin();
#endif
            InternalUpdate();

#if UNITY_EDITOR
            m_Sampler?.End();
#endif
        }
        /// <summary>
        /// Execute the manager immediately.
        /// </summary>
        public void Update()
        {
#if UNITY_EDITOR
            sampler?.Begin();
#endif
            if (Enabled)
            {
                InternalUpdate();
            }
#if UNITY_EDITOR
            sampler?.End();
#endif
        }
Beispiel #5
0
        private void MarkProfiler()
        {
            this.UIDetectSampler.Begin();

            for (int i = 0; i < m_LayoutRebuildQueue.Count; ++i)
            {
                var obj = m_LayoutRebuildQueue[i].transform;
                if (obj != null)
                {
                    LayoutRebuildSampler.Begin(obj);
                    LayoutRebuildSampler.End();
                }
            }
            for (int i = 0; i < m_GraphicRebuildQueue.Count; ++i)
            {
                var obj = m_GraphicRebuildQueue[i].transform;
                if (obj != null)
                {
                    GraphicRebuildSampler.Begin(obj);
                    GraphicRebuildSampler.End();
                }
            }
            this.UIDetectSampler.End();
        }
Beispiel #6
0
        /// <inheritdoc />
        protected override void pointersPressed(IList <Pointer> pointers)
        {
            gestureSampler.Begin();

            base.pointersPressed(pointers);

            if (pointersNumState == PointersNumState.PassedMinThreshold)
            {
                if (State == GestureState.Idle)
                {
                    setState(GestureState.Possible);
                }
                gestureSampler.End();
                return;
            }
            if (pointersNumState == PointersNumState.PassedMinMaxThreshold)
            {
                setState(GestureState.Failed);
                gestureSampler.End();
                return;
            }

            gestureSampler.End();
        }
        void Click(Tap tap)
        {
            var ev      = tap.pointerEvent;
            var pressed = ev.rawPointerPress;             // 押された時に実際に差していたもの(downイベントが発生したものと違う可能性はある)
            var fired   = ExecuteEvents.ExecuteHierarchy <IPointerClickHandler>(pressed, ev, (handler, data) =>
            {
                clickSampler.Begin();
                handler.OnPointerClick((PointerEventData)data);
                clickSampler.End();
            });

            if (fired != null)
            {
                Log(LogItem.EventType.Click, ev, fired);
            }
        }
Beispiel #8
0
    // Update is called once per frame
    void Update()
    {
        _samplerTC1.Begin();
        for (var i = 0; i < 10000; ++i)
        {
            var s = string.Empty;
        }
        _samplerTC1.End();

        _samplerTC2.Begin();
        for (var i = 0; i < 10000; ++i)
        {
            var s = string.Empty;
        }
        _samplerTC2.End();
    }
Beispiel #9
0
 private static void Run()
 {
     Profiler.BeginThreadProfiling("Unitystation", "Atmospherics");
     while (running)
     {
         sampler.Begin();
         StopWatch.Restart();
         RunStep();
         StopWatch.Stop();
         sampler.End();
         if (StopWatch.ElapsedMilliseconds < MillieSecondDelay)
         {
             Thread.Sleep(MillieSecondDelay - (int)StopWatch.ElapsedMilliseconds);
         }
     }
     Profiler.EndThreadProfiling();
 }
Beispiel #10
0
    void OnTriggerEnter2D(Collider2D other)
    {
        Debug.LogError(offset);
        playerLastPos = GetComponentInParent <Player>().transform.position;

        //margin between the distances
        offset = other.transform.position.y - transform.position.y;

        //the position to instantiate at
        Vector2 posToInstantiate = new Vector2(Random.Range(-levelWidth, levelWidth), offset + GetComponentInParent <Player>().transform.position.y + 2);

        Debug.LogError("POZITIA ESTE: " + posToInstantiate);

        //Starting the profiling
        sampler = CustomSampler.Create("Collision Instantiating");
        sampler.Begin();

        if (other.tag == "Ledge")
        {
            other.transform.position = posToInstantiate;
        }

        if (other.tag == "DestructiveLedge")
        {
            Debug.Log("ELSE");
            Destroy(other.gameObject);
            //    Instantiate(destructivePlatformPrefab, posToInstantiate, Quaternion.identity);
        }
        if (Random.Range(1, 50) == 5)
        {
            instantiatedObj = Instantiate(boostPlatformPrefab, posToInstantiate, Quaternion.identity);

            if (x == 0)
            {
                Instantiate(destructivePlatformPrefab, posToInstantiate, Quaternion.identity);
                x = 1;
            }
        }
        if (other.tag == "BoostLedge")
        {
            Destroy(other.gameObject);
        }

        //end zone of profiling
        sampler.End();
    }
Beispiel #11
0
        void Down(Tap tap, GameObject hitObject)
        {
            var ev = tap.pointerEvent;

            Debug.Assert(hitObject != null);
            Debug.Assert(ev.rawPointerPress == null);

            ev.delta               = Vector2.zero;
            ev.dragging            = false;
            ev.useDragThreshold    = true;
            ev.pressPosition       = ev.position;
            ev.pointerPressRaycast = ev.pointerCurrentRaycast;
            ev.rawPointerPress     = hitObject;

            var fired = ExecuteEvents.ExecuteHierarchy <IPointerDownHandler>(hitObject, ev, (handler, data) =>
            {
                downSampler.Begin();
                handler.OnPointerDown((PointerEventData)data);
                downSampler.End();
            });

            if (fired != null)
            {
                ev.pointerPress = fired;
                Log(LogItem.EventType.Down, ev, fired);
            }
            else             // Downが見つからなかい場合もClickを持っているものがあれば、clickCountの処理を行う
            {
                fired = ExecuteEvents.GetEventHandler <IPointerClickHandler>(hitObject);
            }
            // 同じ物にdownが連続した場合の処理
            var time          = Time.unscaledTime;
            int newClickCount = 1;

            if (fired == ev.lastPress)
            {
                var diffTime = time - ev.clickTime;
                if (diffTime < doubleClickThreshold)
                {
                    newClickCount = ev.clickCount + 1;
                }
            }
            ev.clickTime  = time;
            ev.clickCount = newClickCount;
            tap.time      = 0f;
        }
        private void ProcessTextRegen(bool timeSliced)
        {
            if ((timeSliced && m_DirtyTextRemaining == 0) || m_TextElementCount == 0)
            {
                return;
            }

            s_TextRegenSampler.Begin();
            if (m_TextUpdatePainter == null)
            {
                m_TextUpdatePainter = new Implementation.UIRTextUpdatePainter();
            }

            var dirty = m_FirstTextElement;

            m_DirtyTextStartIndex = timeSliced ? m_DirtyTextStartIndex % m_TextElementCount : 0;
            for (int i = 0; i < m_DirtyTextStartIndex; i++)
            {
                dirty = dirty.renderChainData.nextText;
            }
            if (dirty == null)
            {
                dirty = m_FirstTextElement;
            }

            int maxCount = timeSliced ? Math.Min(50, m_DirtyTextRemaining) : m_TextElementCount;

            for (int i = 0; i < maxCount; i++)
            {
                Implementation.RenderEvents.ProcessRegenText(this, dirty, m_TextUpdatePainter, device, ref m_Stats);
                dirty = dirty.renderChainData.nextText;
                m_DirtyTextStartIndex++;
                if (dirty == null)
                {
                    dirty = m_FirstTextElement;
                    m_DirtyTextStartIndex = 0;
                }
            }

            m_DirtyTextRemaining = Math.Max(0, m_DirtyTextRemaining - maxCount);
            if (m_DirtyTextRemaining > 0)
            {
                (panel as BaseVisualElementPanel)?.OnVersionChanged(m_FirstTextElement, VersionChangeType.Transform); // Force a window refresh
            }
            s_TextRegenSampler.End();
        }
Beispiel #13
0
        public void ReadBackSyncAtIdx(int idx)
        {
            if (idx < 0 || idx >= FRAME_NUM)
            {
                return;
            }
            var rt = frames[idx].renderTexture;

            if (rt == null)
            {
                return;
            }
            if (syncUpdateSampler == null)
            {
                this.syncUpdateSampler = CustomSampler.Create("SyncUpdate");
            }

            syncUpdateSampler.Begin();
            if (syncTexCache != null &&
                (syncTexCache.width != rt.width || syncTexCache.height != rt.height))
            {
                Object.Destroy(syncTexCache);
                syncTexCache = null;
            }

            Texture2D tex2d = syncTexCache;

            if (tex2d == null)
            {
                tex2d = new Texture2D(rt.width, rt.height, TextureFormat.RGBA32, false);
            }
            RenderTexture.active = rt;
            tex2d.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);
            tex2d.Apply();
            var bytes = tex2d.GetRawTextureData <byte>();

            Profiler.EmitFrameMetaData(ScreenShotToProfiler.MetadataGuid,
                                       frames[idx].id, bytes);

            syncTexCache = tex2d;

            frames[idx].isRequest = false;
            frames[idx].fromEnd   = 0;
            syncUpdateSampler.End();
        }
    void Update()
    {
        // TMP DEBUG hack
        if (Input.GetKeyDown(KeyCode.G))
        {
            m_ShowDebugUI = !m_ShowDebugUI;
        }

        m_Sampler.Begin();
        var camera = Camera.main;

        if (camera != null && camera.cameraType == CameraType.Game)
        {
            UpdateCommandBuffer(camera);
            Graphics.ExecuteCommandBuffer(m_CmdBuffer);
        }
        m_Sampler.End();
    }
Beispiel #15
0
    // Update is called once per frame
    void Update()
    {
        if (!_TileMap.IsGridInitalised())
        {
            return;
        }
#if UNITY_EDITOR
        _UpdateCoolDown = 1.0f / _UpdateRate;
#endif
#if UNITY_EDITOR
        Samples.Begin();
#endif
        if (!_TileMap.IsSimulating())
        {
            EditorSimulate();
#if UNITY_EDITOR
            Samples.End();
#endif
            return;
        }
        TileVisiblityThreshold = TileVisiblityThreshold_Proxy;
        TileFillTime           = FillTime_Proxy;
        _CurrentCooldown      -= Time.deltaTime;
        if (_CurrentCooldown > 0.0f)
        {
#if UNITY_EDITOR
            Samples.End();
#endif
            return;
        }
        _CurrentCooldown = _UpdateCoolDown;
        for (int i = 0; i < _SolverIterations; i++)
        {
            Simulate();
        }
        if (DEBUG_ADDFLuid)
        {
            Test();
        }
#if UNITY_EDITOR
        Samples.End();
#endif
    }
Beispiel #16
0
        /// <remarks>
        /// When textures that have been previously allowed into the atlas manager change, or if the project color
        /// space changes, this method MUST be called. Textures that had been previously accepted into the atlas may
        /// now be refused, and previously refused textures may now be accepted.
        /// </remarks>
        public void Reset()
        {
            if (disposed)
            {
                LogDisposeError();
                return;
            }

            s_ResetSampler.Begin();

            m_Blitter.Reset();
            m_UVs.Clear();
            m_Allocator      = new UIRAtlasAllocator(m_InitialSize, 4096, m_1SidePadding);
            m_ForceReblitAll = false;
            m_ColorSpace     = QualitySettings.activeColorSpace;
            UIRUtility.Destroy(atlas);

            s_ResetSampler.End();

            m_ResetVersion = s_GlobalResetVersion;
        }
Beispiel #17
0
        void BeginDrag(Tap tap)
        {
            var ev = tap.pointerEvent;

            // ドラグ中でないはず
            Debug.Assert(!ev.dragging);
            Debug.Assert(ev.pointerDrag == null);
            var pressed = ev.rawPointerPress;

            if (pressed == null)             // すでに破棄されている場合、代わりにdownが発生したオブジェクトを使う
            {
                pressed = ev.pointerPress;   // これがそもそもない場合や死んでいる場合もありうる
            }

            if (pressed != null)
            {
                ev.dragging         = true;
                ev.useDragThreshold = true;
                var fired = ExecuteEvents.ExecuteHierarchy <IBeginDragHandler>(pressed, ev, (handler, data) =>
                {
                    beginDragSampler.Begin();
                    handler.OnBeginDrag((PointerEventData)data);
                    beginDragSampler.End();
                });
                if (fired != null)
                {
                    Log(LogItem.EventType.BeginDrag, ev, fired);
                }
                else                 // BeginDragを受け取らなくても、Drag,EndDragを受け取る場合にはpointerDragに受け取り手を入れておく
                {
                    fired = ExecuteEvents.GetEventHandler <IDragHandler>(pressed);
                    if (fired == null)
                    {
                        fired = ExecuteEvents.GetEventHandler <IEndDragHandler>(pressed);
                    }
                }
                ev.pointerDrag = fired;
            }
        }
Beispiel #18
0
        private void Awake()
        {
            cursorSampler = CustomSampler.Create("[TouchScript] Update Cursors");

            cursorSampler.Begin();

            mousePool  = new ObjectPool <PointerCursor>(2, instantiateMouseProxy, null, clearProxy);
            touchPool  = new ObjectPool <PointerCursor>(10, instantiateTouchProxy, null, clearProxy);
            penPool    = new ObjectPool <PointerCursor>(2, instantiatePenProxy, null, clearProxy);
            objectPool = new ObjectPool <PointerCursor>(2, instantiateObjectProxy, null, clearProxy);

            updateCursorSize();

            rect = transform as RectTransform;
            if (rect == null)
            {
                Debug.LogError("CursorManager must be on an UI element!");
                enabled = false;
            }

            cursorSampler.End();
        }
Beispiel #19
0
    public FilledPoly MakeFilledPoly(List <Vector3> poly)
    {
        FilledRegion.Clear( );

        CustomSampler edgeTablesampler = CustomSampler.Create("initEdgeTable");
        CustomSampler drawDinoSampler  = CustomSampler.Create("drawDino");
        CustomSampler scanFillSampler  = CustomSampler.Create("scanFillSampler");

        edgeTablesampler.Begin( );
        initEdgeTable( );
        edgeTablesampler.End( );

        drawDinoSampler.Begin( );
        drawPolyDino(poly);
        drawDinoSampler.End( );
        //printf( "\nTable" );
        //printTable( );
        scanFillSampler.Begin( );
        ScanlineFill( );//actual calling of scanline filling..
        scanFillSampler.End( );
        return(FilledRegion);
    }
        private object DoRender()
        {
            var currentState = _currentState;

            if (currentState == null)
            {
                return(null);
            }

            using (_renderScope.Enter(this))
            {
                _children.Clear();

#if UNITY_EDITOR || DEVELOPMENT_BUILD
                if (_renderSampler == null)
                {
                    _renderSampler = CustomSampler.Create($"Render {name}");
                }

                _renderSampler.Begin();
#endif

                try
                {
                    Render();
                    OnAfterRender();
                }
                catch (Exception ex)
                {
                    Zone.Current.HandleUncaughtException(ex);
                }
#if UNITY_EDITOR || DEVELOPMENT_BUILD
                _renderSampler.End();
#endif
            }

            return(null);
        }
        private static void MakeVectorGraphics9SliceBackground(Vertex[] svgVertices, UInt16[] svgIndices, float svgWidth, float svgHeight, Rect targetRect, Vector4 sliceLTRB, bool stretch, Color tint, int settingIndexOffset, AllocMeshData meshAlloc)
        {
            var mwd = meshAlloc.alloc((uint)svgVertices.Length, (uint)svgIndices.Length, ref meshAlloc);

            mwd.SetAllIndices(svgIndices);

            if (!stretch)
            {
                throw new NotImplementedException("Support for repeating 9-slices is not done yet");
            }

            k_VectorGraphics9Slice.Begin();

            var     uvRegion      = mwd.uvRegion;
            int     vertsCount    = svgVertices.Length;
            Vector2 sliceInvSize  = new Vector2(1.0f / (svgWidth - sliceLTRB.z - sliceLTRB.x), 1.0f / (svgHeight - sliceLTRB.w - sliceLTRB.y));
            Vector2 stretchAmount = new Vector2(targetRect.width - svgWidth, targetRect.height - svgHeight);

            for (int i = 0; i < vertsCount; i++)
            {
                var     v = svgVertices[i];
                Vector2 skinWeight;
                skinWeight.x = Mathf.Clamp01((v.position.x - sliceLTRB.x) * sliceInvSize.x);
                skinWeight.y = Mathf.Clamp01((v.position.y - sliceLTRB.y) * sliceInvSize.y);

                v.position.x += skinWeight.x * stretchAmount.x;
                v.position.y += skinWeight.y * stretchAmount.y;
                v.uv.x        = v.uv.x * uvRegion.width + uvRegion.xMin;
                v.uv.y        = v.uv.y * uvRegion.height + uvRegion.yMin;
                v.tint       *= tint;
                uint settingIndex = (uint)(((v.opacityPageSVGSettingIndex.b << 8) | v.opacityPageSVGSettingIndex.a) + settingIndexOffset);
                v.opacityPageSVGSettingIndex.b = (byte)(settingIndex >> 8);
                v.opacityPageSVGSettingIndex.a = (byte)settingIndex;
                mwd.SetNextVertex(v);
            }

            k_VectorGraphics9Slice.End();
        }
Beispiel #22
0
        void Unregister(VectorImage vi, VectorImageRenderInfo renderInfo)
        {
            k_UnregisterSampler.Begin();

            if (renderInfo.gradientSettingsAlloc.size > 0)
            {
                m_GradientSettingsAtlas.Remove(renderInfo.gradientSettingsAlloc);
            }

            GradientRemap remap = renderInfo.firstGradientRemap;

            while (remap != null)
            {
                GradientRemap next = remap.next;
                m_GradientRemapPool.Return(remap);
                remap = next;
            }

            m_Registered.Remove(vi);
            m_RenderInfoPool.Return(renderInfo);

            k_UnregisterSampler.End();
        }
        public void Commit(RenderTexture dst)
        {
            if (disposed)
            {
                DisposeHelper.NotifyDisposedUsed(this);
                return;
            }

            if (m_PendingBlits.Count == 0)
            {
                return;
            }

            s_CommitSampler.Begin();
            BeginBlit(dst);
            for (int i = 0; i < m_PendingBlits.Count; i += k_TextureSlotCount)
            {
                DoBlit(m_PendingBlits, i);
            }
            EndBlit();
            s_CommitSampler.End();

            m_PendingBlits.Clear();
        }
Beispiel #24
0
            public virtual void ProcessAdded(object sender, PointerEventArgs pointerEventArgs)
            {
#if UNITY_5_6_OR_NEWER
                uiSampler.Begin();
#endif

                var pointers = pointerEventArgs.Pointers;
                var raycast  = new RaycastResult();
                var count    = pointers.Count;
                for (var i = 0; i < count; i++)
                {
                    var pointer = pointers[i];
                    var over    = pointer.GetOverData();

                    // Don't update the pointer if it is not over an UI element
                    if (over.Type != HitData.HitType.UI)
                    {
                        continue;
                    }

                    PointerEventData data;
                    GetPointerData(pointer.Id, out data, true);
                    data.Reset();
                    var target        = over.Target;
                    var currentOverGo = target == null ? null : target.gameObject;

                    data.position = pointer.Position;
                    data.delta    = Vector2.zero;
                    convertRaycast(over.RaycastHitUI, ref raycast);
                    raycast.screenPosition     = data.position;
                    data.pointerCurrentRaycast = raycast;

                    input.HandlePointerExitAndEnter(data, currentOverGo);
                }

#if UNITY_5_6_OR_NEWER
                uiSampler.End();
#endif
            }
        private void updatePressed(IList <Pointer> pointers)
        {
            gestureSampler.Begin();

            var activeTargets       = transformListPool.Get();
            var gesturesInHierarchy = gestureListPool.Get();
            var startedGestures     = gestureListPool.Get();

            // Arrange pointers by target.
            var count = pointers.Count;

            for (var i = 0; i < count; i++)
            {
                var pointer = pointers[i];
                var target  = pointer.GetPressData().Target;
                if (target == null)
                {
                    continue;
                }

                List <Pointer> list;
                if (!pointersOnTarget.TryGetValue(target, out list))
                {
                    list = pointerListPool.Get();
                    pointersOnTarget.Add(target, list);
                    activeTargets.Add(target);
                }
                list.Add(pointer);
            }

            // Process all targets - get and sort all gestures on targets in hierarchy.
            count = activeTargets.Count;
            for (var i = 0; i < count; i++)
            {
                var target = activeTargets[i];

                // Pointers that hit <target>.
                var targetPointers      = pointersOnTarget[target];
                var targetPointersCount = targetPointers.Count;

                // Gestures on objects in the hierarchy from "root" to target.
                var gesturesOnParentsAndMe = getHierarchyEndingWith(target);

                // Gestures in the target's hierarchy which might affect gestures on the target.
                // Gestures on all parents and all children.
                gesturesInHierarchy.AddRange(gesturesOnParentsAndMe);
                gesturesInHierarchy.AddRange(getHierarchyBeginningWith(target));
                var gesturesInHierarchyCount = gesturesInHierarchy.Count;

                for (var j = 0; j < gesturesInHierarchyCount; j++)
                {
                    var gesture = gesturesInHierarchy[j];
                    if (gesture.State == Gesture.GestureState.Began || gesture.State == Gesture.GestureState.Changed)
                    {
                        startedGestures.Add(gesture);
                    }
                }

                var startedCount         = startedGestures.Count;
                var possibleGestureCount = gesturesOnParentsAndMe.Count;
                for (var j = 0; j < possibleGestureCount; j++)
                {
                    // WARNING! Gesture state might change during this loop.
                    // For example when one of them recognizes.

                    var possibleGesture = gesturesOnParentsAndMe[j];

                    // If the gesture is not active it can't start or recognize.
                    if (!gestureIsActive(possibleGesture))
                    {
                        continue;
                    }

                    var canReceivePointers = true;

                    // For every possible gesture in gesturesInHierarchy we need to check if it prevents gestureOnParentOrMe from getting pointers.
                    for (var k = 0; k < startedCount; k++)
                    {
                        var startedGesture = startedGestures[k];

                        if (possibleGesture == startedGesture)
                        {
                            continue;
                        }

                        // This gesture has started. Is gestureOnParentOrMe allowed to work in parallel?
                        if (canPreventGesture(startedGesture, possibleGesture))
                        {
                            // activeGesture has already began and prevents gestureOnParentOrMe from getting pointers.
                            canReceivePointers = false;
                            break;
                        }
                    }

                    if (!canReceivePointers)
                    {
                        continue;
                    }

                    // Filter incoming pointers for gesture.
                    var pointersSentToGesture = pointerListPool.Get();
                    for (var k = 0; k < targetPointersCount; k++)
                    {
                        var pointer = targetPointers[k];
                        if (shouldReceivePointer(possibleGesture, pointer))
                        {
                            pointersSentToGesture.Add(pointer);
                        }
                    }

                    // If there are any pointers to send.
                    if (pointersSentToGesture.Count > 0)
                    {
                        if (pointersToDispatchForGesture.ContainsKey(possibleGesture))
                        {
                            pointersToDispatchForGesture[possibleGesture].AddRange(pointersSentToGesture);
                            pointerListPool.Release(pointersSentToGesture);
                        }
                        else
                        {
                            // Add gesture to the list of active gestures this update.
                            activeGesturesThisUpdate.Add(possibleGesture);
                            pointersToDispatchForGesture.Add(possibleGesture, pointersSentToGesture);
                        }
                    }
                    else
                    {
                        pointerListPool.Release(pointersSentToGesture);
                    }
                }

                gesturesInHierarchy.Clear();
                startedGestures.Clear();
                pointerListPool.Release(targetPointers);
            }

            gestureListPool.Release(gesturesInHierarchy);
            gestureListPool.Release(startedGestures);
            transformListPool.Release(activeTargets);

            // Dispatch gesture events with pointers assigned to them.
            count = activeGesturesThisUpdate.Count;
            for (var i = 0; i < count; i++)
            {
                var gesture = activeGesturesThisUpdate[i];
                var list    = pointersToDispatchForGesture[gesture];
                if (!gestureIsActive(gesture))
                {
                    pointerListPool.Release(list);
                    continue;
                }

                var numPointers = list.Count;
                for (var j = 0; j < numPointers; j++)
                {
                    var            pointer = list[j];
                    List <Gesture> gestureList;
                    if (!pointerToGestures.TryGetValue(pointer.Id, out gestureList))
                    {
                        gestureList = gestureListPool.Get();
                        pointerToGestures.Add(pointer.Id, gestureList);
                    }
                    gestureList.Add(gesture);
                }

                gesture.INTERNAL_PointersPressed(list);
                pointerListPool.Release(list);
            }

            pointersOnTarget.Clear();
            activeGesturesThisUpdate.Clear();
            pointersToDispatchForGesture.Clear();

            gestureSampler.End();
        }
        public void Render(Rect topRect, Matrix4x4 projection)
        {
            s_RenderSampler.Begin();
            m_Stats = new ChainBuilderStats();
            m_Stats.elementsAdded        += m_StatsElementsAdded;
            m_Stats.elementsRemoved      += m_StatsElementsRemoved;
            m_Stats.clipListCleanup      += m_StatsClipListCleanup;
            m_Stats.transformListCleanup += m_StatsTransformListCleanup;
            m_Stats.visualListCleanup    += m_StatsVisualListCleanup;
            m_StatsElementsAdded          = m_StatsElementsRemoved = 0;
            m_StatsClipListCleanup        = m_StatsTransformListCleanup = m_StatsVisualListCleanup = 0;

            if (atlasManager?.RequiresReset() == true)
            {
                atlasManager.Reset(); // May cause a dirty repaint
            }
            m_DirtyID++;
            var           clearDirty = ~(RenderDataDirtyTypes.Clipping | RenderDataDirtyTypes.ClippingHierarchy);
            VisualElement dirty      = m_FirstDirtyClipping;

            s_ClipProcessingSampler.Begin();
            while (dirty != null)
            {
                if (dirty.renderChainData.isInChain && dirty.renderChainData.dirtyID != m_DirtyID)
                {
                    Implementation.RenderEvents.ProcessOnClippingChanged(this, dirty, m_DirtyID, device, ref m_Stats);
                }
                dirty.renderChainData.dirtiedValues &= clearDirty;
                var old = dirty;
                dirty = dirty.renderChainData.nextDirtyClipping;
                old.renderChainData.nextDirtyClipping = null;
            }
            s_ClipProcessingSampler.End();
            m_FirstDirtyClipping = m_LastDirtyClipping = null;

            m_DirtyID++;
            clearDirty = ~(RenderDataDirtyTypes.Transform | RenderDataDirtyTypes.Size);
            dirty      = m_FirstDirtyTransformOrSize;
            s_TransformProcessingSampler.Begin();
            while (dirty != null)
            {
                if (dirty.renderChainData.isInChain && dirty.renderChainData.dirtyID != m_DirtyID)
                {
                    Implementation.RenderEvents.ProcessOnTransformOrSizeChanged(this, dirty, m_DirtyID, device, ref m_Stats);
                }
                dirty.renderChainData.dirtiedValues &= clearDirty;
                var old = dirty;
                dirty = dirty.renderChainData.nextDirtyTransformOrSize;
                old.renderChainData.nextDirtyTransformOrSize = null;
            }
            s_TransformProcessingSampler.End();
            m_FirstDirtyTransformOrSize = m_LastDirtyTransformOrSize = null;

            m_DirtyID++;
            clearDirty = ~(RenderDataDirtyTypes.Visuals | RenderDataDirtyTypes.VisualsHierarchy);
            dirty      = m_FirstDirtyVisuals;
            s_VisualsProcessingSampler.Begin();
            while (dirty != null)
            {
                if (dirty.renderChainData.isInChain && dirty.renderChainData.dirtyID != m_DirtyID)
                {
                    Implementation.RenderEvents.ProcessOnVisualsChanged(this, dirty, m_DirtyID, ref m_Stats);
                }
                dirty.renderChainData.dirtiedValues &= clearDirty;
                var old = dirty;
                dirty = dirty.renderChainData.nextDirtyVisuals;
                old.renderChainData.nextDirtyVisuals = null;
            }
            s_VisualsProcessingSampler.End();
            m_FirstDirtyVisuals = m_LastDirtyVisuals = null;

            ProcessTextRegen(true);

            if (m_FontWasReset)
            {
                // We regenerate the text when the font texture was reset since we don't have any guarantees
                // the the glyphs are going to end up at the same spot in the texture.
                // Up to two passes may be necessary with time-slicing turned off to fully update the text.
                const int kMaxTextPasses = 2;
                for (int i = 0; i < kMaxTextPasses; ++i)
                {
                    if (!m_FontWasReset)
                    {
                        break;
                    }
                    m_FontWasReset = false;
                    ProcessTextRegen(false);
                }
            }


            atlasManager?.Update(); // Commit new requests if any

            if (BeforeDrawChain != null)
            {
                BeforeDrawChain(device);
            }

            Exception immediateException = null;

            device.DrawChain(m_FirstCommand, topRect, projection, atlasManager?.atlas, ref immediateException);

            s_RenderSampler.End();

            if (immediateException != null)
            {
                throw immediateException;
            }

            if (drawStats)
            {
                DrawStats();
            }
        }
Beispiel #27
0
 /// <summary>
 /// Start timing a block of code.
 /// </summary>
 public void Begin()
 {
     m_Sampler?.Begin();
     m_TickStart = DateTime.Now.Ticks;
 }
Beispiel #28
0
 public CustomSamplerScope(string name)
 {
     m_sampler = CustomSampler.Create(name);
     m_sampler.Begin();
 }
Beispiel #29
0
 public CustomSamplerScope(string name, UnityEngine.Object targetObject)
 {
     m_sampler = CustomSampler.Create(name);
     m_sampler.Begin(targetObject);
 }
    private void Update()
    {
        Transform currTravelPoint = travelPoints[currTravelPointIndex];

        Vector3 newPos = Vector3.MoveTowards(transform.position, currTravelPoint.position, speed * Time.deltaTime);

        transform.position = newPos;

        if (Vector3.Distance(newPos, currTravelPoint.position) <= speed * Time.deltaTime)
        {
            currTravelPointIndex++;
            currTravelPointIndex %= travelPoints.Length;
        }

        if (target == null)
        {
            return;
        }

        sampler.Begin();

        Pathfinder.FindPath(transform.position, target.position, pathResult);

        sampler.End();

        // Debug
        float   sideFactor = Graphs.GridMaster.Instance.NodeRadius * 0.6f;
        Vector3 upFactor   = Vector3.up * 0.04f;

        for (int i = 0; i < Pathfinder.OpenSet.Elements.Length; i++)
        {
            GridNode n = Pathfinder.OpenSet.Elements[i];

            if (n == null)
            {
                continue;
            }

            Vector3 v4 = n.Pos + upFactor + (Vector3.right + Vector3.forward) * sideFactor;
            Vector3 v2 = n.Pos + upFactor + (Vector3.right - Vector3.forward) * sideFactor;
            Vector3 v1 = n.Pos + upFactor + (Vector3.left - Vector3.forward) * sideFactor;
            Vector3 v3 = n.Pos + upFactor + (Vector3.left + Vector3.forward) * sideFactor;

            DebugRenderer.Instance.DrawQuad(v1, v2, v3, v4, new Color(90.0f / 255.0f, 176.0f / 255.0f, 1.0f, 1.0f), DebugRenderChannel.GridGraph);
        }

        foreach (GridNode n in Pathfinder.ClosedSet)
        {
            Vector3 v4 = n.Pos + upFactor + (Vector3.right + Vector3.forward) * sideFactor;
            Vector3 v2 = n.Pos + upFactor + (Vector3.right - Vector3.forward) * sideFactor;
            Vector3 v1 = n.Pos + upFactor + (Vector3.left - Vector3.forward) * sideFactor;
            Vector3 v3 = n.Pos + upFactor + (Vector3.left + Vector3.forward) * sideFactor;

            DebugRenderer.Instance.DrawQuad(v1, v2, v3, v4, new Color(1.0f, 147.0f / 255.0f, 61.0f / 255.0f, 1.0f), DebugRenderChannel.GridGraph);
        }

        sideFactor *= 0.9f;
        upFactor    = Vector3.up * 0.05f;

        for (int i = 0; i < pathResult.Count; i++)
        {
            GridNode n  = pathResult[i];
            Vector3  v4 = n.Pos + upFactor + (Vector3.right + Vector3.forward) * sideFactor;
            Vector3  v2 = n.Pos + upFactor + (Vector3.right - Vector3.forward) * sideFactor;
            Vector3  v1 = n.Pos + upFactor + (Vector3.left - Vector3.forward) * sideFactor;
            Vector3  v3 = n.Pos + upFactor + (Vector3.left + Vector3.forward) * sideFactor;

            DebugRenderer.Instance.DrawQuad(v1, v2, v3, v4, new Color(109.0f / 255.0f, 1.0f, 107.0f / 255.0f, 1.0f), DebugRenderChannel.GridGraph);
        }
    }