/// <inheritdoc /> protected override void pointersPressed(IList <Pointer> pointers) { gestureSampler.Begin(); base.pointersPressed(pointers); if (State == GestureState.Idle) { setState(GestureState.Began); } var length = pointers.Count; if (pointerPressedInvoker != null) { for (var i = 0; i < length; i++) { pointerPressedInvoker.InvokeHandleExceptions(this, new MetaGestureEventArgs(pointers[i])); } } if (UseSendMessage && SendMessageTarget != null) { for (var i = 0; i < length; i++) { SendMessageTarget.SendMessage(POINTER_PRESSED_MESSAGE, pointers[i], SendMessageOptions.DontRequireReceiver); } } gestureSampler.End(); }
private void updateInputs() { #if ERROR_001 if (samplerUpdateInputs == null) { samplerUpdateInputs = CustomSampler.Create("[TouchScript] Update Inputs"); } if (samplerUpdateInputs != null) { samplerUpdateInputs.Begin(); for (var i = 0; i < inputCount; i++) { inputs[i].UpdateInput(); } samplerUpdateInputs.End(); } #else samplerUpdateInputs.Begin(); for (var i = 0; i < inputCount; i++) { inputs[i].UpdateInput(); } samplerUpdateInputs.End(); #endif }
/// <inheritdoc /> protected override void pointersPressed(IList <Pointer> pointers) { gestureSampler.Begin(); base.pointersPressed(pointers); if (pointersNumState == PointersNumState.PassedMaxThreshold || pointersNumState == PointersNumState.PassedMinMaxThreshold) { if (State == GestureState.Possible) { setState(GestureState.Failed); } } else if (pointersNumState == PointersNumState.PassedMinThreshold) { // Starting the gesture when it is already active? => we released one finger and pressed again while moving if (isActive) { setState(GestureState.Failed); } else { isActive = true; } } gestureSampler.End(); }
/// <inheritdoc /> protected override void pointersPressed(IList <Pointer> pointers) { #if UNITY_5_6_OR_NEWER gestureSampler.Begin(); #endif base.pointersPressed(pointers); if (pointersNumState == PointersNumState.PassedMinThreshold) { if (State == GestureState.Idle) { setState(GestureState.Possible); } #if UNITY_5_6_OR_NEWER gestureSampler.End(); #endif return; } if (pointersNumState == PointersNumState.PassedMinMaxThreshold) { setState(GestureState.Failed); #if UNITY_5_6_OR_NEWER gestureSampler.End(); #endif return; } #if UNITY_5_6_OR_NEWER gestureSampler.End(); #endif }
/// <inheritdoc /> protected override void pointersPressed(IList <Pointer> pointers) { gestureSampler.Begin(); base.pointersPressed(pointers); gestureSampler.End(); }
private void pointersAddedHandler(object sender, PointerEventArgs e) { #if UNITY_5_6_OR_NEWER cursorSampler.Begin(); #endif updateCursorSize(); var count = e.Pointers.Count; for (var i = 0; i < count; i++) { var pointer = e.Pointers[i]; // Don't show internal pointers if ((pointer.Flags & Pointer.FLAG_INTERNAL) > 0) { continue; } PointerCursor cursor; switch (pointer.Type) { case Pointer.PointerType.Mouse: cursor = mousePool.Get(); break; case Pointer.PointerType.Touch: cursor = touchPool.Get(); break; case Pointer.PointerType.Pen: cursor = penPool.Get(); break; case Pointer.PointerType.Object: cursor = objectPool.Get(); break; default: continue; } cursor.Size = cursorPixelSize; cursor.Init(rect, pointer); cursors.Add(pointer.Id, cursor); } #if UNITY_5_6_OR_NEWER cursorSampler.End(); #endif }
/// <inheritdoc /> protected override void pointersPressed(IList <Pointer> pointers) { gestureSampler.Begin(); base.pointersPressed(pointers); if (NumPointers == pointers.Count) { projectionLayer = activePointers[0].GetPressData().Layer; updateProjectionPlane(); } gestureSampler.End(); }
void Drag(Tap tap, GameObject hitObject) { var ev = tap.pointerEvent; Debug.Assert(ev.dragging); var dragged = ev.pointerDrag; if (dragged == null) // 破棄されちゃった。離したことにする。 { Up(tap, hitObject); } else { var fired = ExecuteEvents.ExecuteHierarchy <IDragHandler>(dragged, ev, (handler, data) => { dragSampler.Begin(); handler.OnDrag((PointerEventData)data); dragSampler.End(); }); if (fired != null) { Log(LogItem.EventType.Drag, ev, dragged); } } }
void EndDrag(Tap tap, GameObject hitObject) { var ev = tap.pointerEvent; // ドラグ中のはず Debug.Assert(ev.dragging); // まずドロップ Drop(tap, hitObject); // 元オブジェクトが生きていればEndDrag発火。 var dragged = ev.pointerDrag; if (dragged != null) { var fired = ExecuteEvents.ExecuteHierarchy <IEndDragHandler>(dragged, ev, (handler, data) => { endDragSampler.Begin(); handler.OnEndDrag((PointerEventData)data); endDragSampler.End(); }); if (fired != null) { Log(LogItem.EventType.EndDrag, ev, dragged); } } ev.dragging = false; ev.pointerDrag = null; ev.useDragThreshold = false; }
/// <summary> /// Graph update thread. /// Async graph updates will be executed by this method in another thread. /// </summary> void ProcessGraphUpdatesAsync() { #if UNITY_2017_3_OR_NEWER Profiler.BeginThreadProfiling("Pathfinding", "Threaded Graph Updates"); #endif var handles = new [] { graphUpdateAsyncEvent, exitAsyncThread }; while (true) { // Wait for the next batch or exit event var handleIndex = WaitHandle.WaitAny(handles); if (handleIndex == 1) { // Exit even was fired // Abort thread and clear queue while (graphUpdateQueueAsync.Count > 0) { var s = graphUpdateQueueAsync.Dequeue(); s.obj.internalStage = GraphUpdateObject.STAGE_ABORTED; } asyncGraphUpdatesComplete.Set(); #if UNITY_2017_3_OR_NEWER Profiler.EndThreadProfiling(); #endif return; } while (graphUpdateQueueAsync.Count > 0) { #if UNITY_2017_3_OR_NEWER asyncUpdateProfilingSampler.Begin(); #endif // Note that no locking is required here because the main thread // cannot access it until asyncGraphUpdatesComplete is signaled GUOSingle aguo = graphUpdateQueueAsync.Dequeue(); try { if (aguo.order == GraphUpdateOrder.GraphUpdate) { aguo.graph.UpdateArea(aguo.obj); graphUpdateQueuePost.Enqueue(aguo); } else { throw new System.NotSupportedException("" + aguo.order); } } catch (System.Exception e) { Debug.LogError("Exception while updating graphs:\n" + e); } #if UNITY_2017_3_OR_NEWER asyncUpdateProfilingSampler.End(); #endif } // Done asyncGraphUpdatesComplete.Set(); } }
void Up(Tap tap, GameObject hitObject) { var ev = tap.pointerEvent; var pressed = ev.rawPointerPress; // 押された時に実際に差していたもの(downイベントが発生したものと違う可能性はある) if (pressed != null) // 押されたものが死んでなければUpを発火。nullになっている可能性がある。 { var fired = ExecuteEvents.ExecuteHierarchy <IPointerUpHandler>(pressed, ev, (handler, data) => { upSampler.Begin(); handler.OnPointerUp((PointerEventData)data); upSampler.End(); }); if (fired != null) { Log(LogItem.EventType.Up, ev, fired); } // 押したものと、今ヒットしているオブジェクトが等しければクリックも発火 if (pressed == hitObject) { Click(tap); } ev.pointerPress = null; ev.rawPointerPress = null; } // ドラグ中ならドラグ終了 if (ev.dragging) { EndDrag(tap, hitObject); } tap.time = float.MaxValue; tap.mark.enabled = false; }
void Sender() { Profiler.BeginThreadProfiling(typeof(OscPortSocket).Name, "Sender"); while (_udp != null) { try { Thread.Sleep(0); if (_willBeSent.Count == 0) { continue; } sampler.Begin(); lock (_willBeSent) { while (_willBeSent.Count > 0) { _willBeSent.Dequeue().Send(_udp); } } sampler.End(); } catch (Exception e) { if (_udp != null) { RaiseError(e); } } } Profiler.EndThreadProfiling(); }
// Protected implementation of Dispose pattern. void Dispose(bool disposing) { if (m_Disposed) { return; } // As this is a struct, it could have been initialized using an empty constructor so we // need to make sure `cmd` isn't null to avoid a crash. Switching to a class would fix // this but will generate garbage on every frame (and this struct is used quite a lot). if (disposing) { if (m_Cmd != null) #if UNITY_USE_RECORDER { if (m_Sampler != null) { m_Cmd.EndSample(m_Sampler); } else { m_Cmd.EndSample(m_Name); } } #else { m_Cmd.EndSample(m_Name); } #endif m_InlineSampler?.End(); } m_Disposed = true; }
/// <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_PendingBlits.Clear(); m_UVs.Clear(); m_Allocator = new UIRAtlasAllocator(64, 4096); m_ForceReblitAll = false; m_ColorSpace = QualitySettings.activeColorSpace; UIRUtility.Destroy(atlas); m_RequiresReset = false; if (ResetPerformed != null) { ResetPerformed(this, EventArgs.Empty); } s_ResetSampler.End(); }
public void InstantiatePlaftorms(int numberOfPlatforms) { sampler = CustomSampler.Create("InstantiatingFunction"); //begining of profiling sampler.Begin(); // InstantiatePlaftorms(numberOfPlatforms, Vector2.zero); for (int i = 0; i < numberOfPlatforms; i++) { //Define the spawn position spawnPos.y += Random.Range(minY, maxY) + player.transform.position.y; spawnPos.x = Random.Range(-levelWidth, levelWidth); //pick a platform to instantiate if (Random.Range(1, 10) == 5) { platformToInstantiate = destructivePlat; } else if (Random.Range(10, 20) == 14) { platformToInstantiate = boostPlatformPrefab; } else { platformToInstantiate = platformPrefab; } //instantiate platforms.Add(Instantiate(platformToInstantiate, spawnPos, Quaternion.identity)); } //end area of the profiler sampler.End(); }
public static void Sync() { #if UNITY_EDITOR || DEVELOPMENT_BUILD ProfilerSampler.Begin(); #endif var toSwap = _updatingCurrentFrame; _updatingCurrentFrame = _updatingNextFrame; _updatingNextFrame = toSwap; while (_updatingCurrentFrame.Count > 0) { var atom = _updatingCurrentFrame.Dequeue(); if (atom.IsActive && !atom.Reaping && atom.State != AtomBase.AtomState.Actual) { atom.Actualize(); } } while (_reaping.Count > 0) { var atom = _reaping.Dequeue(); if (atom.Reaping && atom.Subscribers == null) { atom.Deactivate(); } } #if UNITY_EDITOR || DEVELOPMENT_BUILD ProfilerSampler.End(); #endif }
private void WorkerThread(object o) { AndroidLogcatInternalLog.Log("Worker thread started"); Profiler.BeginThreadProfiling("AndroidLogcat", "Dispatcher"); while (m_AutoResetEvent.WaitOne() && m_Running) { //Debug.Log("Executing"); AsyncTask task = null; lock (m_AsyncTaskQueue) { if (m_AsyncTaskQueue.Count > 0) { task = m_AsyncTaskQueue.Dequeue(); } } if (task != null && task.asyncAction != null) { m_Sampler.Begin(); var result = task.asyncAction.Invoke(task.taskData); m_Sampler.End(); lock (m_IntegrateTaskQueue) { m_IntegrateTaskQueue.Enqueue(new IntegrationTask() { integrateAction = task.integrateAction, result = result }); } } } AndroidLogcatInternalLog.Log("Worker thread exited"); Profiler.EndThreadProfiling(); m_FinishedEvent.Set(); }
private void Awake() { #if UNITY_5_6_OR_NEWER cursorSampler = CustomSampler.Create("[TouchScript] Update Cursors"); cursorSampler.Begin(); #endif 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; } #if UNITY_5_6_OR_NEWER cursorSampler.End(); #endif }
/// <summary> /// Animates the vertices of the procedural mesh analyzing the spectrum data, and updates the /// mesh vertices. /// </summary> private void AnimateVertices() { getSpectrumSampler.Begin(); audioSrc.GetSpectrumData(spectrumManaged, 0, FFTWindow.BlackmanHarris); getSpectrumSampler.End(); copySpectrumSampler.Begin(); spectrum.CopyFrom(spectrumManaged); copySpectrumSampler.End(); JobHandle meansHandle = spectrumAnalyzer.ScheduleSpectrumBandMeans(audioSrc.clip.frequency, spectrum); new AnimateVerticesJob { vertices = vertices, means = spectrumAnalyzer.SmoothedMeans, resolution = resolution, scale = scale, middleCorridorWidth = middleCorridorWidth, mountainNoiseWeight = mountainNoiseWeight, mountainNoiseFreq = mountainNoiseFrequency, mountainEdgeSmoothness = mountainEdgeSmoothness, time = Time.time * noiseTimeSpeed, } .ScheduleParallel(vertices.Length, 64, meansHandle) .Complete(); mesh.SetVertexBufferData(vertices, 0, 0, vertices.Length, 0, ~MeshUpdateFlags.Default); }
/// <summary> /// Updates the mesh by setting its data given the last valid vertex index and the last /// valid triangle index. Be aware that by default the data is set starting from index 0. /// </summary> /// <param name="lastValidVertexIndex"></param> /// <param name="lastValidTriIndex"></param> protected void UpdateMesh(int lastValidVertexIndex, int lastValidTriIndex) { sampler.Begin(); // Note: this might be called in between job completions so it could be moved away. mesh.Clear(false); MeshUpdateFlags updateFlags = ~MeshUpdateFlags.Default; mesh.SetVertices(vertices, 0, lastValidVertexIndex, updateFlags); mesh.SetIndices(tris, 0, lastValidTriIndex, MeshTopology.Triangles, 0, false); if (UseNormals) { mesh.SetNormals(normals, 0, lastValidVertexIndex, updateFlags); } if (UseUvs) { mesh.SetUVs(0, uvs, 0, lastValidVertexIndex, updateFlags); } if (UseVertexColors) { mesh.SetColors(colors, 0, lastValidVertexIndex, updateFlags); } mesh.RecalculateBounds(); sampler.End(); }
private void Run() { Profiler.BeginThreadProfiling("Unitystation", "Electronics"); while (running) { sampler.Begin(); StopWatch.Restart(); try { RunStep(); } catch (Exception e) { Logger.LogError($"Electrical Thread Error! {e.GetStack()}", Category.Electrical); } StopWatch.Stop(); sampler.End(); if (StopWatch.ElapsedMilliseconds < MillieSecondDelay) { Thread.Sleep(MillieSecondDelay - (int)StopWatch.ElapsedMilliseconds); } } Profiler.EndThreadProfiling(); thread.Abort(); }
public static void Sync() { #if UNITY_EDITOR || DEVELOPMENT_BUILD ProfilerSampler.Begin(); #endif SyncTimer.Restart(); var toSwap = _updatingCurrentFrame; _updatingCurrentFrame = _updatingNextFrame; _updatingNextFrame = toSwap; while (_updatingCurrentFrame.Count > 0) { var atom = _updatingCurrentFrame.Dequeue(); if (atom.options.Has(AtomOptions.Active) && atom.state != AtomState.Actual) { atom.Actualize(); } } SyncTimer.Stop(); #if UNITY_EDITOR || DEVELOPMENT_BUILD ProfilerSampler.End(); #endif }
private static void Run() { Profiler.BeginThreadProfiling("Unitystation", "Atmospherics"); while (running) { if (!simulation.IsIdle) { sampler.Begin(); StopWatch.Restart(); RunStep(); StopWatch.Stop(); sampler.End(); if (StopWatch.ElapsedMilliseconds < MillieSecondDelay) { Thread.Sleep(MillieSecondDelay - (int)StopWatch.ElapsedMilliseconds); } } else { lock (lockGetWork) { Monitor.Wait(lockGetWork); } } } Profiler.EndThreadProfiling(); }
public Color[] FillPoly(System.Func <V3, V3> mapper) { CustomSampler createList = CustomSampler.Create("createList"); createList.Begin( ); mappedPoints.Clear( ); foreach (var item in path.pathPoints) { mappedPoints.Add(mapper(item)); } if (path.pathPoints.Count > 0) { // 最初と繋げないと囲まれない mappedPoints.Add(mapper(path.pathPoints[0])); } createList.End( ); CustomSampler fillpoly = CustomSampler.Create("MakeFilledPoly"); fillpoly.Begin( ); // 範囲外のポリゴンを渡さないと形がかわる、 var fill = FilledPoly.MakeFilledPoly( //path.pathPoints mappedPoints ); fillpoly.End( ); //return fill.InsideLine; return(fill.InsideLineColor(TexEditor.Size)); }
public override void Run() { sampler.Begin(); base.Run(); sampler.End(); }
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) => { upSampler.Begin(); handler.OnPointerDown((PointerEventData)data); upSampler.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 Capture() { captureSampler.Begin(); lastRequestIdx = renderTextureBuffer.CaptureScreen(frameIdx); renderTextureBuffer.UpdateAsyncRequest(); ++frameIdx; captureSampler.End(); }
/// <summary> /// Implementation of Update() /// </summary> public void Update() { if (panel == null) { return; } #if UNITY_EDITOR if (enableLiveUpdates && m_TrackedAssetList != null && m_TrackedAssetHashes != null) { for (int i = 0; i < m_TrackedAssetList.Count; ++i) { var asset = m_TrackedAssetList[i]; var hash = EditorUtility.GetDirtyCount(asset); var cachedHash = m_TrackedAssetHashes[i]; if (hash == cachedHash) { continue; } // RecreateUIFromUxml(); return; } } #endif m_UpdateSampler.Begin(); var targetSize = targetTexture == null ? GetActiveRenderTargetSize() : new Vector2(targetTexture.width, targetTexture.height); if (targetTexture != m_TargetTexture) { m_TargetTexture = targetTexture; InternalBridge.SetTargetTexture(panel, targetTexture); } // Temporary: clamp scale to prevent font atlas running out of space // won't be needed when using TextCore var scale = Mathf.Max(0.1f, m_PanelScaler == null ? 1 : m_PanelScaler.ComputeScalingFactor(targetSize)); if (m_Scale != scale || m_TargetSize != targetSize) { InternalBridge.SetScale(panel, scale == 0 ? 0 : 1.0f / scale); visualTree.style.left = 0; visualTree.style.top = 0; visualTree.style.width = targetSize.x * scale; visualTree.style.height = targetSize.y * scale; m_Scale = scale; m_TargetSize = targetSize; } InternalBridge.UpdatePanel(panel); m_UpdateSampler.End(); }
/// <summary> /// Stop timing a block of code, and increment internal counts. /// </summary> public void End() { var elapsed = DateTime.Now.Ticks - m_TickStart; m_TotalTicks += elapsed; m_TickStart = 0; m_NumCalls++; m_Sampler?.End(); }
private void updateInputs() { samplerUpdateInputs.Begin(); for (var i = 0; i < inputCount; i++) { inputs[i].UpdateInput(); } samplerUpdateInputs.End(); }