System.Action.Invoke()

Here are the examples of the csharp api System.Action.Invoke() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

12579 Examples 7

19 Source : HierarchicalResolver.cs
with MIT License
from Abc-Arbitrage

public void Build(IHierarchicalConfiguration config)
        {
            var oldRoot = _root;
            var newRoot = new Node();

            foreach (var loggerWithAppenders in CreateLoggersWithAppenders(config).OrderBy(x => x.logger.Name))
            {
                AddNode(newRoot, loggerWithAppenders.logger, loggerWithAppenders.appenders);
            }

            ApplyEncodingToAllAppenders(newRoot);

            _root = newRoot;

            Updated?.Invoke();

            oldRoot?.Dispose();
        }

19 Source : SimpleLatencyBenchmark.cs
with MIT License
from Abc-Arbitrage

public static LongHistogram Bench(Action action, int count)
        {
            var histogram = new LongHistogram(TimeStamp.Minutes(1), 5);

            for (var i = 0; i < count; i++)
                histogram.Record(() => action());

            return histogram;
        }

19 Source : CallbackOnDispose.cs
with MIT License
from Abdesol

public void Dispose()
		{
			Action a = Interlocked.Exchange(ref action, null);
			if (a != null) {
				a();
			}
		}

19 Source : BaseMixedRealityProfileInspector.cs
with Apache License 2.0
from abist-co-ltd

protected static void RenderFoldout(ref bool currentState, string replacedle, Action renderContent, string preferenceKey = null)
        {
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);

            bool isValidPreferenceKey = !string.IsNullOrEmpty(preferenceKey);
            bool state = currentState;
            if (isValidPreferenceKey)
            {
                state = SessionState.GetBool(preferenceKey, currentState);
            }

            currentState = EditorGUILayout.Foldout(state, replacedle, true, MixedRealityStylesUtility.BoldFoldoutStyle);

            if (isValidPreferenceKey && currentState != state)
            {
                SessionState.SetBool(preferenceKey, currentState);
            }

            if (currentState)
            {
                renderContent();
            }

            EditorGUILayout.EndVertical();
        }

19 Source : AwaiterExtensions.cs
with Apache License 2.0
from abist-co-ltd

private static void RunOnUnityScheduler(Action action)
        {
            if (SynchronizationContext.Current == SyncContextUtility.UnitySynchronizationContext)
            {
                action();
            }
            else
            {
                AsyncCoroutineRunner.Post(action);
            }
        }

19 Source : Interpolator.cs
with Apache License 2.0
from abist-co-ltd

public void SetTargetPosition(Vector3 target)
        {
            bool wasRunning = Running;

            targetPosition = target;

            float magsq = (targetPosition - transform.position).sqrMagnitude;
            if (magsq > Tolerance)
            {
                AnimatingPosition = true;
                enabled = true;

                if (InterpolationStarted != null && !wasRunning)
                {
                    InterpolationStarted();
                }
            }
            else
            {
                // Set immediately to prevent acreplacedulation of error.
                transform.position = target;
                AnimatingPosition = false;
            }
        }

19 Source : Interpolator.cs
with Apache License 2.0
from abist-co-ltd

public void SetTargetLocalRotation(Quaternion target)
        {
            bool wasRunning = Running;

            targetLocalRotation = target;

            if (Quaternion.Dot(transform.localRotation, target) < 1.0f)
            {
                AnimatingLocalRotation = true;
                enabled = true;

                if (InterpolationStarted != null && !wasRunning)
                {
                    InterpolationStarted();
                }
            }
            else
            {
                // Set immediately to prevent acreplacedulation of error.
                transform.localRotation = target;
                AnimatingLocalRotation = false;
            }
        }

19 Source : Interpolator.cs
with Apache License 2.0
from abist-co-ltd

public void SnapToTarget()
        {
            if (enabled)
            {
                transform.position = TargetPosition;
                transform.rotation = TargetRotation;
                transform.localRotation = TargetLocalRotation;
                transform.localScale = TargetLocalScale;

                AnimatingPosition = false;
                AnimatingLocalScale = false;
                AnimatingRotation = false;
                AnimatingLocalRotation = false;
                enabled = false;

                InterpolationDone?.Invoke();
            }
        }

19 Source : Interpolator.cs
with Apache License 2.0
from abist-co-ltd

public void StopInterpolating()
        {
            if (enabled)
            {
                Reset();
                InterpolationDone?.Invoke();
            }
        }

19 Source : WindowsMixedRealityEyeGazeDataProvider.cs
with Apache License 2.0
from abist-co-ltd

private void Post_OnSaccade()
        {
            OnSaccade?.Invoke();
        }

19 Source : WindowsMixedRealityEyeGazeDataProvider.cs
with Apache License 2.0
from abist-co-ltd

private void Post_OnSaccadeHorizontally()
        {
            OnSaccadeX?.Invoke();
        }

19 Source : WindowsMixedRealityEyeGazeDataProvider.cs
with Apache License 2.0
from abist-co-ltd

private void Post_OnSaccadeVertically()
        {
            OnSaccadeY?.Invoke();
        }

19 Source : MixedRealityProfileUtility.cs
with Apache License 2.0
from abist-co-ltd

public static void OnPostprocessAllreplacedets(string[] importedreplacedets, string[] deletedreplacedets, string[] movedreplacedets, string[] movedFromreplacedetPaths)
            {
                if (Application.isPlaying)
                {
                    return;
                }

                OnreplacedetsChanged?.Invoke();
            }

19 Source : AsyncCoroutineRunner.cs
with Apache License 2.0
from abist-co-ltd

private void Update()
        {
            Debug.replacedert(Instance != null);

            int actionCount;

            lock (Actions)
            {
                actionCount = Actions.Count;
            }

            for (int i = 0; i < actionCount; i++)
            {
                Action next;

                lock (Actions)
                {
                    next = Actions.Dequeue();
                }

                next();
            }
        }

19 Source : MixedRealityProjectConfigurator.cs
with Apache License 2.0
from abist-co-ltd

public static void Configure(Configurations config)
        {
            // We use the config getter to check to see if a configuration is valid for the current build target.
            if (ConfigurationGetters.ContainsKey(config))
            {
                var configGetter = ConfigurationGetters[config];
                if (configGetter.IsActiveBuildTargetValid() && ConfigurationSetters.ContainsKey(config))
                {
                    ConfigurationSetters[config].Invoke();
                }
            }
        }

19 Source : Interpolator.cs
with Apache License 2.0
from abist-co-ltd

private void Update()
        {
            float deltaTime = useUnscaledTime
                ? Time.unscaledDeltaTime
                : Time.deltaTime;

            bool interpOccuredThisFrame = false;

            if (AnimatingPosition)
            {
                Vector3 lerpTargetPosition = targetPosition;
                if (SmoothLerpToTarget)
                {
                    lerpTargetPosition = Vector3.Lerp(transform.position, lerpTargetPosition, SmoothPositionLerpRatio);
                }

                Vector3 newPosition = NonLinearInterpolateTo(transform.position, lerpTargetPosition, deltaTime, positionPerSecond);
                if ((targetPosition - newPosition).sqrMagnitude <= Tolerance)
                {
                    // Snap to final position
                    newPosition = targetPosition;
                    AnimatingPosition = false;
                }
                else
                {
                    interpOccuredThisFrame = true;
                }

                transform.position = newPosition;

                // Calculate interpolatedVelocity and store position for next frame
                PositionVelocity = oldPosition - newPosition;
                oldPosition = newPosition;
            }

            // Determine how far we need to rotate
            if (AnimatingRotation)
            {
                Quaternion lerpTargetRotation = targetRotation;
                if (SmoothLerpToTarget)
                {
                    lerpTargetRotation = Quaternion.Lerp(transform.rotation, lerpTargetRotation, SmoothRotationLerpRatio);
                }

                float angleDiff = Quaternion.Angle(transform.rotation, lerpTargetRotation);
                float speedScale = 1.0f + (Mathf.Pow(angleDiff, rotationSpeedScaler) / 180.0f);
                float ratio = Mathf.Clamp01((speedScale * rotationDegreesPerSecond * deltaTime) / angleDiff);

                if (angleDiff < Mathf.Epsilon)
                {
                    AnimatingRotation = false;
                    transform.rotation = targetRotation;
                }
                else
                {
                    // Only lerp rotation here, as ratio is NaN if angleDiff is 0.0f
                    transform.rotation = Quaternion.Slerp(transform.rotation, lerpTargetRotation, ratio);
                    interpOccuredThisFrame = true;
                }
            }

            // Determine how far we need to rotate
            if (AnimatingLocalRotation)
            {
                Quaternion lerpTargetLocalRotation = targetLocalRotation;
                if (SmoothLerpToTarget)
                {
                    lerpTargetLocalRotation = Quaternion.Lerp(transform.localRotation, lerpTargetLocalRotation, SmoothRotationLerpRatio);
                }

                float angleDiff = Quaternion.Angle(transform.localRotation, lerpTargetLocalRotation);
                float speedScale = 1.0f + (Mathf.Pow(angleDiff, rotationSpeedScaler) / 180.0f);
                float ratio = Mathf.Clamp01((speedScale * rotationDegreesPerSecond * deltaTime) / angleDiff);

                if (angleDiff < Mathf.Epsilon)
                {
                    AnimatingLocalRotation = false;
                    transform.localRotation = targetLocalRotation;
                }
                else
                {
                    // Only lerp rotation here, as ratio is NaN if angleDiff is 0.0f
                    transform.localRotation = Quaternion.Slerp(transform.localRotation, lerpTargetLocalRotation, ratio);
                    interpOccuredThisFrame = true;
                }
            }

            if (AnimatingLocalScale)
            {
                Vector3 lerpTargetLocalScale = targetLocalScale;
                if (SmoothLerpToTarget)
                {
                    lerpTargetLocalScale = Vector3.Lerp(transform.localScale, lerpTargetLocalScale, SmoothScaleLerpRatio);
                }

                Vector3 newScale = NonLinearInterpolateTo(transform.localScale, lerpTargetLocalScale, deltaTime, scalePerSecond);
                if ((targetLocalScale - newScale).sqrMagnitude <= Tolerance)
                {
                    // Snap to final scale
                    newScale = targetLocalScale;
                    AnimatingLocalScale = false;
                }
                else
                {
                    interpOccuredThisFrame = true;
                }

                transform.localScale = newScale;
            }

            // If all interpolations have completed, stop updating
            if (!interpOccuredThisFrame)
            {
                InterpolationDone?.Invoke();
                enabled = false;
            }
        }

19 Source : Interpolator.cs
with Apache License 2.0
from abist-co-ltd

public void SetTargetRotation(Quaternion target)
        {
            bool wasRunning = Running;

            targetRotation = target;

            if (Quaternion.Dot(transform.rotation, target) < 1.0f)
            {
                AnimatingRotation = true;
                enabled = true;

                if (InterpolationStarted != null && !wasRunning)
                {
                    InterpolationStarted();
                }
            }
            else
            {
                // Set immediately to prevent acreplacedulation of error.
                transform.rotation = target;
                AnimatingRotation = false;
            }
        }

19 Source : Interpolator.cs
with Apache License 2.0
from abist-co-ltd

public void SetTargetLocalScale(Vector3 target)
        {
            bool wasRunning = Running;

            targetLocalScale = target;

            float magsq = (targetLocalScale - transform.localScale).sqrMagnitude;
            if (magsq > Mathf.Epsilon)
            {
                AnimatingLocalScale = true;
                enabled = true;

                if (InterpolationStarted != null && !wasRunning)
                {
                    InterpolationStarted();
                }
            }
            else
            {
                // set immediately to prevent acreplacedulation of error
                transform.localScale = target;
                AnimatingLocalScale = false;
            }
        }

19 Source : InputRecordingService.cs
with Apache License 2.0
from abist-co-ltd

public void StartRecording()
        {
            IsRecording = true;
            if (UseBufferTimeLimit)
            {
                PruneBuffer();
            }
            if (!unlimitedRecordingStartTime.HasValue)
            {
                unlimitedRecordingStartTime = Time.time;
            }

            OnRecordingStarted?.Invoke();
        }

19 Source : InputRecordingService.cs
with Apache License 2.0
from abist-co-ltd

public void StopRecording()
        {
            IsRecording = false;

            OnRecordingStopped?.Invoke();
        }

19 Source : InputSimulationWindow.cs
with Apache License 2.0
from abist-co-ltd

private void DrawHandGUI(string name,
            bool isAlwaysVisible, Action<bool> setAlwaysVisible,
            Vector3 position, Action<Vector3> setPosition,
            Vector3 rotation, Action<Vector3> setRotation,
            Action reset)
        {
            using (new GUILayout.VerticalScope(EditorStyles.helpBox))
            {
                GUILayout.Label($"{name} Hand:");

                bool newIsAlwaysVisible = EditorGUILayout.Toggle("Always Visible", isAlwaysVisible);
                Vector3 newPosition = EditorGUILayout.Vector3Field("Position", position);
                Vector3 newRotation = DrawRotationGUI("Rotation", rotation);
                bool resetHand = GUILayout.Button("Reset");

                if (newIsAlwaysVisible != isAlwaysVisible)
                {
                    setAlwaysVisible(newIsAlwaysVisible);
                }
                if (newPosition != position)
                {
                    setPosition(newPosition);
                }
                if (newRotation != rotation)
                {
                    setRotation(newRotation);
                }
                if (resetHand)
                {
                    reset();
                }
            }
        }

19 Source : GuardianBoundaryEnforcer.cs
with MIT License
from absurd-joy

private void Update()
    {
        // Hack: the recenter doesn't kick in for 1-2 frames, so stall.
        // We can remove this hack once the bug is resolved.
        if (m_framecount >= 0)
        {
            m_framecount++;
            if(m_framecount > 2)
            {
                // Implementation of AllowRecenterYaw is a bit complicated. There's no way in our Unity integration to prevent the yaw
                // recenter. So we transform the trackingSpace node, and hence all of its child cameras, to "undo" the rotation done
                // to the tracking space.
                Quaternion newTrackerOri = OVRPlugin.GetNodePose(OVRPlugin.Node.TrackerZero, OVRPlugin.Step.Render).ToOVRPose().orientation;
                float diff = newTrackerOri.eulerAngles.y - m_originalTrackerOrientation.eulerAngles.y;
                m_orientToOriginalForward = Quaternion.Euler(0.0f, -diff, 0.0f);
                if (!m_AllowRecenter)
                {
                    m_mainCamera.trackingSpace.transform.rotation = m_orientToOriginalForward;
                }

                m_framecount = -1;
                if (TrackingChanged != null)
                {
                    TrackingChanged();
                }
            }
        }
    }

19 Source : LocomotionTeleport.cs
with MIT License
from absurd-joy

protected IEnumerator ReadyStateCoroutine()
	{
		LogState("ReadyState: Start");

		// yield once so that all the components will have time to process their OnEnable message before this 
		// does work that relies on the events being hooked up.
		yield return null;

		LogState("ReadyState: Ready");

		CurrentState = States.Ready;
		EnableMotion(EnableMovementDuringReady, EnableRotationDuringReady);

		if (EnterStateReady != null)
		{
			EnterStateReady();
		}

		// Wait until a teleport is requested.
		while (CurrentIntention != TeleportIntentions.Aim)
		{
			yield return null;
		}
		LogState("ReadyState: End");

		// Wait until the next frame to proceed to the next state's coroutine.
		yield return null;

		StartCoroutine(AimStateCoroutine());
	}

19 Source : LocomotionTeleport.cs
with MIT License
from absurd-joy

protected IEnumerator AimStateCoroutine()
	{
		LogState("AimState: Start");
		CurrentState = States.Aim;
		EnableMotion(EnableMovementDuringAim, EnableRotationDuringAim);
		if (EnterStateAim != null)
		{
			EnterStateAim();
		}
		_teleportDestination.gameObject.SetActive(true);

		// Wait until the user is done aiming. The input system will turn this off when the button that triggered aiming is released.
		while (CurrentIntention == TeleportIntentions.Aim) 
		{
			yield return null;
		}

		LogState("AimState: End. Intention: " + CurrentIntention);
		if (ExitStateAim != null)
		{
			ExitStateAim();
		}

		// Wait until the next frame to proceed to the next state's coroutine.
		yield return null;

		// If target is valid, enter pre-teleport otherwise cancel the teleport.
		LogState("AimState: Switch state. Intention: " + CurrentIntention);
		if ((CurrentIntention == TeleportIntentions.PreTeleport || CurrentIntention == TeleportIntentions.Teleport) && _teleportDestination.IsValidDestination)
		{
			StartCoroutine(PreTeleportStateCoroutine());
		}
		else
		{
			StartCoroutine(CancelAimStateCoroutine());
		}
	}

19 Source : LocomotionTeleport.cs
with MIT License
from absurd-joy

protected IEnumerator CancelAimStateCoroutine()
	{
		LogState("CancelAimState: Start");
		CurrentState = States.CancelAim;
		if (EnterStateCancelAim != null)
		{
			EnterStateCancelAim();
		}
		LogState("CancelAimState: End");

		DeactivateDestination();

		// Wait until the next frame to proceed to the next state's coroutine.
		yield return null;

		StartCoroutine(ReadyStateCoroutine());
	}

19 Source : LocomotionTeleport.cs
with MIT License
from absurd-joy

protected IEnumerator PreTeleportStateCoroutine()
	{
		LogState("PreTeleportState: Start");
		CurrentState = States.PreTeleport;
		EnableMotion(EnableMovementDuringPreTeleport, EnableRotationDuringPreTeleport);
		if (EnterStatePreTeleport != null)
		{
			EnterStatePreTeleport();
		}

		while (CurrentIntention == TeleportIntentions.PreTeleport || IsPreTeleportRequested)
		{
			yield return null;
		}

		LogState("PreTeleportState: End");

		// Most of the state coroutines will wait until the next frame to proceed to the next state's coroutine,
		// however the PreTeleportState may need to be processed quickly for situations where the teleport needs
		// to occur on the downpress of a button (AvatarTouch capactive touch for aim and teleport, for instance).

		if (_teleportDestination.IsValidDestination)
		{
			StartCoroutine(TeleportingStateCoroutine());
		}
		else
		{
			StartCoroutine(CancelTeleportStateCoroutine());
		}
	}

19 Source : LocomotionTeleport.cs
with MIT License
from absurd-joy

protected IEnumerator CancelTeleportStateCoroutine()
	{
		LogState("CancelTeleportState: Start");
		CurrentState = States.CancelTeleport;
		if (EnterStateCancelTeleport != null)
		{
			EnterStateCancelTeleport();
		}
		LogState("CancelTeleportState: End");

		// Teleport was cancelled, notify the teleport destination.
		DeactivateDestination();

		// Wait until the next frame to proceed to the next state's coroutine.
		yield return null;

		StartCoroutine(ReadyStateCoroutine());
	}

19 Source : LocomotionTeleport.cs
with MIT License
from absurd-joy

protected IEnumerator TeleportingStateCoroutine()
	{
		LogState("TeleportingState: Start");
		CurrentState = States.Teleporting;
		EnableMotion(false, false); // movement is always disabled during teleport.
		if (EnterStateTeleporting != null)
		{
			EnterStateTeleporting();
		}

		// If a handler sets this, it needs to clear it when the transition completes.
		while (IsTransitioning)
		{
			yield return null;
		}

		LogState("TeleportingState: End");

		// Wait until the next frame to proceed to the next state's coroutine.
		yield return null;

		StartCoroutine(PostTeleportStateCoroutine());
	}

19 Source : LocomotionTeleport.cs
with MIT License
from absurd-joy

protected IEnumerator PostTeleportStateCoroutine()
	{
		LogState("PostTeleportState: Start");
		CurrentState = States.PostTeleport;
		EnableMotion(EnableMovementDuringPostTeleport, EnableRotationDuringPostTeleport);
		if (EnterStatePostTeleport != null)
		{
			EnterStatePostTeleport();
		}

		while (IsPostTeleportRequested)
		{
			yield return null;
		}

		LogState("PostTeleportState: End");

		DeactivateDestination();

		// Wait until the next frame to proceed to the next state's coroutine.
		yield return null;

		StartCoroutine(ReadyStateCoroutine());
	}

19 Source : SimpleCapsuleWithStickMovement.cs
with MIT License
from absurd-joy

private void FixedUpdate()
	{
        if (CameraUpdated != null) CameraUpdated();
        if (PreCharacterMove != null) PreCharacterMove();

        if (HMDRotatesPlayer) RotatePlayerToHMD();
		if (EnableLinearMovement) StickMovement();
		if (EnableRotation) SnapTurn();
	}

19 Source : ButtonDownListener.cs
with MIT License
from absurd-joy

public void OnPointerDown(PointerEventData eventData)
    {
        if (onButtonDown != null)
        {
            onButtonDown.Invoke();
        }
    }

19 Source : SoundEmitter.cs
with MIT License
from absurd-joy

public void Stop() {
		// overrides everything
		state = FadeState.Null;
		StopAllCoroutines();
		if ( audioSource != null ) {
			audioSource.Stop();
		}
		if ( onFinished != null ) {
			onFinished();
			onFinished = null;
		}
		if ( onFinishedObject != null ) {
			onFinishedObject( onFinishedParam );
			onFinishedObject = null;
		}
		if ( playingSoundGroup != null ) {
			playingSoundGroup.DecrementPlayCount();
			playingSoundGroup = null;
		}
	}

19 Source : EntitlementCheck.cs
with MIT License
from absurd-joy

void HandleEnreplacedlementCheckResult(bool result)
    {
      if (result) // User preplaceded enreplacedlement check
      {
        Debug.Log("Oculus user enreplacedlement check successful.");

        try
        {
          // Raise the user preplaceded enreplacedlement check event if the app subscribed a handler to it.
          if (UserPreplacededEnreplacedlementCheck != null)
          {
            UserPreplacededEnreplacedlementCheck();
          }
        }
        catch
        {
          // Suppressing any exceptions to avoid potential exceptions in the app-provided event handler.
          Debug.LogError("Suppressed exception in app-provided UserPreplacededEnreplacedlementCheck() event handler.");
        }
      }
      else // User failed enreplacedlement check
      {
        try
        {
          // Raise the user failed enreplacedlement check event if the app subscribed a handler to it.
          if (UserFailedEnreplacedlementCheck != null)
          {
            UserFailedEnreplacedlementCheck();
          }
        }
        catch
        {
          // Suppressing any exceptions to avoid potential exceptions in the app-provided event handler.
          // Ensures the default enreplacedlement check behavior will still execute, if enabled.
          Debug.LogError("Suppressed exception in app-provided UserFailedEnreplacedlementCheck() event handler.");
        }

        if (exitAppOnFailure)
        {
          // Implements a default behavior for an enreplacedlement check failure -- log the failure and exit the app.
          Debug.LogError("Oculus user enreplacedlement check failed. Exiting now.");
#if UNITY_EDITOR
          UnityEditor.EditorApplication.isPlaying = false;
#else
          UnityEngine.Application.Quit();
#endif
        }
        else
        {
          Debug.LogError("Oculus user enreplacedlement check failed.");
        }
      }
    }

19 Source : OvrAvatarMaterialManager.cs
with MIT License
from absurd-joy

private IEnumerator RunLoadingAnimation(Action callBack)
    {
        // Set the material to single component while the avatar loads
        CombinedShader = TargetRenderer.sharedMaterial.shader;

        // Save shader properties
        int srcBlend = TargetRenderer.sharedMaterial.GetInt("_SrcBlend");
        int dstBlend = TargetRenderer.sharedMaterial.GetInt("_DstBlend");
        string lightModeTag = TargetRenderer.sharedMaterial.GetTag("LightMode", false);
        string renderTypeTag = TargetRenderer.sharedMaterial.GetTag("RenderType", false);
        string renderQueueTag = TargetRenderer.sharedMaterial.GetTag("Queue", false);
        string ignoreProjectorTag = TargetRenderer.sharedMaterial.GetTag("IgnoreProjector", false);
        int renderQueue = TargetRenderer.sharedMaterial.renderQueue;
        bool transparentQueue = TargetRenderer.sharedMaterial.IsKeywordEnabled("_ALPHATEST_ON");

        // Swap in loading shader
        TargetRenderer.sharedMaterial.shader = Shader.Find(AVATAR_SHADER_LOADER);
        TargetRenderer.sharedMaterial.SetColor(AVATAR_SHADER_COLOR, Color.white);

        while (OvrAvatarSDKManager.Instance.GetTextureCopyManager().GetTextureCount() > 0)
        {
            float distance = (LOADING_ANIMATION_AMPLITUDE * Mathf.Sin(Time.timeSinceLevelLoad / LOADING_ANIMATION_PERIOD) +
                LOADING_ANIMATION_AMPLITUDE) * (LOADING_ANIMATION_CURVE_SCALE) + LOADING_ANIMATION_DIMMER_MIN;
            TargetRenderer.sharedMaterial.SetFloat(AVATAR_SHADER_LOADING_DIMMER, distance);
            yield return null;
        }
        // Swap back main shader
        TargetRenderer.sharedMaterial.SetFloat(AVATAR_SHADER_LOADING_DIMMER, 1f);
        TargetRenderer.sharedMaterial.shader = CombinedShader;

        // Restore shader properties
        TargetRenderer.sharedMaterial.SetInt("_SrcBlend", srcBlend);
        TargetRenderer.sharedMaterial.SetInt("_DstBlend", dstBlend);
        TargetRenderer.sharedMaterial.SetOverrideTag("LightMode", lightModeTag);
        TargetRenderer.sharedMaterial.SetOverrideTag("RenderType", renderTypeTag);
        TargetRenderer.sharedMaterial.SetOverrideTag("Queue", renderQueueTag);
        TargetRenderer.sharedMaterial.SetOverrideTag("IgnoreProjector", ignoreProjectorTag);
        if (transparentQueue)
        {
            TargetRenderer.sharedMaterial.EnableKeyword("_ALPHATEST_ON");
            TargetRenderer.sharedMaterial.EnableKeyword("_ALPHABLEND_ON");
            TargetRenderer.sharedMaterial.EnableKeyword("_ALPHAPREMULTIPLY_ON");
        }
        else
        {
            TargetRenderer.sharedMaterial.DisableKeyword("_ALPHATEST_ON");
            TargetRenderer.sharedMaterial.DisableKeyword("_ALPHABLEND_ON");
            TargetRenderer.sharedMaterial.DisableKeyword("_ALPHAPREMULTIPLY_ON");
        }
        TargetRenderer.sharedMaterial.renderQueue = renderQueue;

        ApplyMaterialPropertyBlock();

        if (callBack != null)
        {
            callBack();
        }
    }

19 Source : OVRDisplay.cs
with MIT License
from absurd-joy

public void Update()
	{
		UpdateTextures();

		if (recenterRequested && Time.frameCount > recenterRequestedFrameCount)
		{
			Debug.Log("Recenter event detected");
			if (RecenteredPose != null)
			{
				RecenteredPose();
			}
			recenterRequested = false;
			recenterRequestedFrameCount = int.MaxValue;
		}

		if (OVRPlugin.GetSystemHeadsetType() >= OVRPlugin.SystemHeadset.Oculus_Quest &&
			OVRPlugin.GetSystemHeadsetType() < OVRPlugin.SystemHeadset.Rift_DK1) // all Oculus Standalone headsets
		{
			int recenterCount = OVRPlugin.GetLocalTrackingSpaceRecenterCount();
			if (localTrackingSpaceRecenterCount != recenterCount)
			{
				Debug.Log("Recenter event detected");
				if (RecenteredPose != null)
				{
					RecenteredPose();
				}
				localTrackingSpaceRecenterCount = recenterCount;
			}
		}
	}

19 Source : OVRNetwork.cs
with MIT License
from absurd-joy

public void Connect(int listeningPort)
		{
			if (tcpClient == null)
			{
				receivedBufferIndex = 0;
				receivedBufferDataSize = 0;
				readyReceiveDataEvent.Set();

				string remoteAddress = "127.0.0.1";
				tcpClient = new TcpClient(AddressFamily.InterNetwork);
				tcpClient.BeginConnect(remoteAddress, listeningPort, new AsyncCallback(ConnectCallback), tcpClient);

				if (connectionStateChangedCallback != null)
				{
					connectionStateChangedCallback();
				}
			}
			else
			{
				Debug.LogWarning("[OVRNetworkTcpClient] already connected");
			}
		}

19 Source : OVRNetwork.cs
with MIT License
from absurd-joy

void ConnectCallback(IAsyncResult ar)
		{
			try
			{
				TcpClient client = ar.AsyncState as TcpClient;
				client.EndConnect(ar);
				Debug.LogFormat("[OVRNetworkTcpClient] connected to {0}", client.ToString());
			}
			catch (Exception e)
			{
				Debug.LogWarningFormat("[OVRNetworkTcpClient] connect error {0}", e.Message);
			}

			if (connectionStateChangedCallback != null)
			{
				connectionStateChangedCallback();
			}
		}

19 Source : OVRNetwork.cs
with MIT License
from absurd-joy

public void Disconnect()
		{
			if (tcpClient != null)
			{
				if (!readyReceiveDataEvent.WaitOne(5))
				{
					Debug.LogWarning("[OVRNetworkTcpClient] readyReceiveDataEvent not signaled. data receiving timeout?");
				}

				Debug.Log("[OVRNetworkTcpClient] close tcpClient");
				try
				{
					tcpClient.GetStream().Close();
					tcpClient.Close();
				}
				catch (Exception e)
				{
					Debug.LogWarning("[OVRNetworkTcpClient] " + e.Message);
				}
				tcpClient = null;

				if (connectionStateChangedCallback != null)
				{
					connectionStateChangedCallback();
				}
			}
			else
			{
				Debug.LogWarning("[OVRNetworkTcpClient] not connected");
			}
		}

19 Source : OVRPlayerController.cs
with MIT License
from absurd-joy

protected virtual void UpdateController()
	{
		if (useProfileData)
		{
			if (InitialPose == null)
			{
				// Save the initial pose so it can be recovered if useProfileData
				// is turned off later.
				InitialPose = new OVRPose()
				{
					position = CameraRig.transform.localPosition,
					orientation = CameraRig.transform.localRotation
				};
			}

			var p = CameraRig.transform.localPosition;
			if (OVRManager.instance.trackingOriginType == OVRManager.TrackingOrigin.EyeLevel)
			{
				p.y = OVRManager.profile.eyeHeight - (0.5f * Controller.height) + Controller.center.y;
			}
			else if (OVRManager.instance.trackingOriginType == OVRManager.TrackingOrigin.FloorLevel)
			{
				p.y = -(0.5f * Controller.height) + Controller.center.y;
			}
			CameraRig.transform.localPosition = p;
		}
		else if (InitialPose != null)
		{
			// Return to the initial pose if useProfileData was turned off at runtime
			CameraRig.transform.localPosition = InitialPose.Value.position;
			CameraRig.transform.localRotation = InitialPose.Value.orientation;
			InitialPose = null;
		}

		CameraHeight = CameraRig.centerEyeAnchor.localPosition.y;

		if (CameraUpdated != null)
		{
			CameraUpdated();
		}

		UpdateMovement();

		Vector3 moveDirection = Vector3.zero;

		float motorDamp = (1.0f + (Damping * SimulationRate * Time.deltaTime));

		MoveThrottle.x /= motorDamp;
		MoveThrottle.y = (MoveThrottle.y > 0.0f) ? (MoveThrottle.y / motorDamp) : MoveThrottle.y;
		MoveThrottle.z /= motorDamp;

		moveDirection += MoveThrottle * SimulationRate * Time.deltaTime;

		// Gravity
		if (Controller.isGrounded && FallSpeed <= 0)
			FallSpeed = ((Physics.gravity.y * (GravityModifier * 0.002f)));
		else
			FallSpeed += ((Physics.gravity.y * (GravityModifier * 0.002f)) * SimulationRate * Time.deltaTime);

		moveDirection.y += FallSpeed * SimulationRate * Time.deltaTime;


		if (Controller.isGrounded && MoveThrottle.y <= transform.lossyScale.y * 0.001f)
		{
			// Offset correction for uneven ground
			float bumpUpOffset = Mathf.Max(Controller.stepOffset, new Vector3(moveDirection.x, 0, moveDirection.z).magnitude);
			moveDirection -= bumpUpOffset * Vector3.up;
		}

		if (PreCharacterMove != null)
		{
			PreCharacterMove();
			Teleported = false;
		}

		Vector3 predictedXZ = Vector3.Scale((Controller.transform.localPosition + moveDirection), new Vector3(1, 0, 1));

		// Move contoller
		Controller.Move(moveDirection);
		Vector3 actualXZ = Vector3.Scale(Controller.transform.localPosition, new Vector3(1, 0, 1));

		if (predictedXZ != actualXZ)
			MoveThrottle += (actualXZ - predictedXZ) / (SimulationRate * Time.deltaTime);
	}

19 Source : ExamplesFrame.cs
with MIT License
from ABTSoftware

private void AddHandler()
        {
            NavigatedEventHandler successHandler = null;
            NavigationFailedEventHandler failureHandler = null;
            NavigatingCancelEventHandler beforeHandler = null;

            successHandler = (s, e) =>
            {
                Frame.Navigated -= successHandler;
                Frame.NavigationFailed -= failureHandler;

                AfterNavigation(null, e.Content as UserControl);
            };

            failureHandler = (s, e) =>
            {
                Frame.Navigated -= successHandler;
                Frame.NavigationFailed -= failureHandler;

                AfterNavigation(e.Exception, null);
            };

            beforeHandler = (s, e) =>
            {
                Frame.Navigating -= beforeHandler;

                BeforeNavigation();
            };

            Frame.Navigated += successHandler;
            Frame.NavigationFailed += failureHandler;
            Frame.Navigating += beforeHandler;
        }

19 Source : MainFrame.cs
with MIT License
from ABTSoftware

private void AddHandler()
        {
            NavigatedEventHandler successHandler = null;
            NavigationFailedEventHandler failureHandler = null;

            successHandler = (s, e) =>
            {
                Frame.Navigated -= successHandler;
                Frame.NavigationFailed -= failureHandler;

                AfterNavigation();
            };

            failureHandler = (s, e) =>
            {
                Frame.Navigated -= successHandler;
                Frame.NavigationFailed -= failureHandler;

                AfterNavigation();
            };

            Frame.Navigated += successHandler;
            Frame.NavigationFailed += failureHandler;
        }

19 Source : AnimatedDataSeriesFilter.cs
with MIT License
from ABTSoftware

public override void FilterAll()
        {
            _filteredDataSeries.Clear();

            int index = 0;
            double animationStepMillisconds = 1;

            Action appendPoint = null;

            Action onAppendCallback = () =>
            {
                // 2.) Append the point
                _filteredDataSeries.Append(_originalDataSeries.XValues[index], _originalDataSeries.YValues[index]);
                _filteredDataSeries.InvalidateParentSurface(RangeMode.ZoomToFit);

                // 3.) Schedule another until complete
                if (++index < _originalDataSeries.Count)
                {
                    // Achieve some rudimentary easing 
                    animationStepMillisconds *= 1.05;
                    animationStepMillisconds = Math.Min(animationStepMillisconds, 10);

                    // Next point 
                    appendPoint();                    
                }
            };

            appendPoint = () =>
            {                
                TimedMethod.Invoke(onAppendCallback).After((int)animationStepMillisconds).Go();
            };

            // 1.) Schedule one point to be appended
            appendPoint();
        }

19 Source : SciChartTestRunner.cs
with MIT License
from ABTSoftware

private void RunNext(TimeSpan duration, Action testCallback, Action<double> completedCallback)
        {
            if (_stopWatch.ElapsedMilliseconds > duration.TotalMilliseconds)
            {
                _stopWatch.Stop();

                double fps = _frameCount/_stopWatch.Elapsed.TotalSeconds;
                completedCallback(fps);
                return;
            }

            _frameCount++;
            testCallback();
        }

19 Source : TimerRunner.cs
with MIT License
from ABTSoftware

public virtual void Run()
        {
            timer = new Timer();
            timer.Interval = 10; // 100Hz
            //timer.Interval = 1; // 100Hz

            ElapsedEventHandler tickHandler = null;
            tickHandler = (s, e) =>
                {
                    _testCallback();

                    lock (this)
                    {
                        if (_stopped) return;
                        if (_stopWatch.ElapsedMilliseconds > _duration.TotalMilliseconds)
                        {
                            _stopWatch.Stop();
                            _stopped = true;
                            timer.Elapsed -= tickHandler;
                            timer.Stop();
                            double fps = _frameCount/_stopWatch.Elapsed.TotalSeconds;
                            Application.Current.Dispatcher.BeginInvoke(new Action(() => _completedCallback(fps)));
                        }
                    }
                };

            timer.Elapsed += tickHandler;
            _stopWatch = Stopwatch.StartNew();
            timer.Start();
        }

19 Source : AsyncLocker.cs
with MIT License
from Accelerider

public void Await(Action action, bool executeAfterUnlocked = true)
        {
            if (!IsLocked)
            {
                try
                {
                    IsLocked = true;
                    action?.Invoke();
                }
                finally
                {
                    IsLocked = false;
                }
            }
            else if (executeAfterUnlocked)
            {
                Unlocked += OnUnlocked;
            }

            void OnUnlocked()
            {
                Unlocked -= OnUnlocked;
                Await(action, executeAfterUnlocked);
            }
        }

19 Source : RelayCommand.cs
with MIT License
from Accelerider

public void Execute()
        {
            _execute?.Invoke();
        }

19 Source : PropertyObserverNode.cs
with MIT License
from Accelerider

private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e?.PropertyName == PropertyName || e?.PropertyName == null)
            {
                _action?.Invoke();
            }
        }

19 Source : ApiExceptionResolverExtension.cs
with MIT License
from Accelerider

public async Task RunApiInternal(Task task, Action onSuccessCallback)
            {
                try
                {
                    await task;
                    onSuccessCallback?.Invoke();
                }
                catch (ApiException e)
                {
                    _snackbarMessageQueue.Enqueue(JObject.Parse(e.Content).Value<string>("status"));
                }
                catch (HttpRequestException httpRequestException)
                {
                    _snackbarMessageQueue.Enqueue(httpRequestException.InnerException?.Message);
                }
            }

19 Source : PropertyObserverNode.cs
with MIT License
from Accelerider

private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            // Invoke action when e.PropertyName == null in order to satisfy:
            //  - DelegateCommandFixture.GenericDelegateCommandObservingPropertyShouldRaiseOnEmptyPropertyName
            //  - DelegateCommandFixture.NonGenericDelegateCommandObservingPropertyShouldRaiseOnEmptyPropertyName
            if (e?.PropertyName == PropertyName || e?.PropertyName == null)
            {
                _action?.Invoke();
            }
        }

19 Source : AccessTokenProvider.cs
with Apache License 2.0
from acblog

public async Task SetToken(string token)
        {
            await JSRuntime.InvokeVoidAsync("localStorage.sereplacedem", "access_token", token);

            TokenChanged?.Invoke();
        }

See More Examples