public static void WorldSpawn(string text, Vector3 start, Color color) { if (string.IsNullOrEmpty(text)) { return; } _msgChecker.Add(text, UIRoot.Misc.Get().transform); UIFloatingText spawn = ItemPool.SpawnUIPrefab <UIFloatingText>("UI/UIFloatingTextStandard", UIRoot.Misc.Get().transform); spawn.transform.position = RectTransformUtility.WorldToScreenPoint(Player.Cam, start); var end = RectTransformUtility.WorldToScreenPoint(Player.Cam, start + new Vector3(0, 1, 0)); spawn.RectTransform.SetAsLastSibling(); TimeManager.StartUnscaled(spawn.SetTargetText(text, 2f, end, color)); }
public void LookDown() { if (_resetView != null) { TimeManager.Cancel(_resetView); _resetView = null; } if (_currentStatus == Status.LookingDown) { ResetView(); return; } var target = Quaternion.Euler(_lookDownTarget); _resetView = TimeManager.StartUnscaled(ChangeViewLerp(target, Status.LookingDown)); }
private void CheckCooldown() { if (_animatingCooldown || _cooldownImage == null) { return; } if (_entity.Get <CooldownComponent>().Cooldown?.Percent > 1.15f) { _cooldownImage.fillAmount = 1; return; } if (System.Math.Abs(_cooldownImage.fillAmount - _entity.Get <CooldownComponent>().Cooldown?.Percent ?? 0) > 0.1f) { TimeManager.StartUnscaled(UpdateCooldown()); } }
public static void SpawnIcon(Sprite icon, string text, RectTransform start, Color color) { var startPosition = start.position; UIFloatingText spawn = ItemPool.SpawnUIPrefab <UIFloatingText>("UI/UIFloatingTextIcon", start); spawn.RectTransform.SetParent(UIRoot.Misc.Get().transform); spawn.RectTransform.SetAsLastSibling(); if (_iconTimer.IsActive) { startPosition = start.position + new Vector3(_negative ? -Offset : Offset, 0, 0); spawn.RectTransform.position = startPosition; _negative = !_negative; } _iconTimer.StartTimer(); spawn._icon.sprite = icon; TimeManager.StartUnscaled(spawn.SetTargetText(text, 2f, startPosition + new Vector3(0, 150, 0), color)); }
public void Test() { for (int i = 0; i < _animators.Length; i++) { var animator = _animators[i] as TweenAnimator; if (animator == null) { var group = _animators[i] as TargetAnimatorGroup; if (group != null) { group.Test(); } continue; } TimeManager.StartUnscaled(animator.PlayAnimation()); } }
public override void PlayFrame(float normalized) { if (!_triggered) { if (_animator != null) { _animator.SetTrigger(_trigger); } _triggered = true; TimeManager.StartUnscaled(PauseForTrigger(normalized)); return; } if (_state < 0) { _state = _animator.GetCurrentAnimatorStateInfo(0).shortNameHash; } _animator.Play(_state, -1, normalized); _animator.speed = 0; }
public void Show(string message, Color color, float speed) { if (_currentTask != null) { TimeManager.Cancel(_currentTask); } if (_group == null) { Debug.LogErrorFormat("{0} has a null group {1}", name, _group == null); } else { _group.alpha = 0; } _text.color = color; _text.text = message; _text.maxVisibleCharacters = 0; TimeManager.StartUnscaled(FadeIn()); //TimeManager.StartUnscaled(RevealText(message.Length, speed), ()=> { _currentTask = null; }); TimeManager.StartUnscaled(RevealWords(_text), () => { _currentTask = null; }); }
public void OpenMenu() { if (_animating != null) { return; } bool inGame = Game.GameActive; var bgColor = Color.black; bgColor.a = inGame ? 155 : 255; _background.color = bgColor; _animating = _canvasGroup.FadeTo(1, _transitionLength * 0.5f, EasingTypes.SinusoidalOut, true, Tween.TweenRepeat.Once, () => _animating = null); _canvasGroup.interactable = _canvasGroup.blocksRaycasts = true; Game.PauseAndUnlockCursor("UIMainMenu"); LoadMainMenu(0); EventSystem.current.SetSelectedGameObject(_layoutGroups[IndexMain].transform.GetChild(1).gameObject); if (!inGame && _menuMusic != null) { TimeManager.StartUnscaled(FadeMusic(true, 0.5f)); } }
[UnityEngine.ContextMenu("Test")] private void TestLight() { _light = GetComponent <Light>(); _lightColor = _light.color; TimeManager.StartUnscaled(LightTester()); }
public static void StartCharge(float lerpTime) { TimeManager.StartUnscaled(main.Charge(lerpTime)); }
public static void StopCharge() { TimeManager.StartUnscaled(main.Fade()); }
public static void StartFx(Entity entity, CollisionEvent collisionEvent, SpriteRenderer sprite, float amt) { TimeManager.StartUnscaled(main.DissolveFx(entity, collisionEvent, sprite, amt)); }
public static void TestTimers() { TimeManager.StartUnscaled(RunTimerTest(1)); }
public void ShakeOneShot(float intensity) { TimeManager.StartUnscaled(StartShake(.2f, intensity)); }
[UnityEngine.ContextMenu("Test FadeOut")] public void TestFadeOut() { TimeManager.StartUnscaled(FadeOut()); }
public void StartCloseRadial() { TimeManager.StartUnscaled(CloseRadial()); }
private void TestBounds() { _spriteAnimator = new SpriteAnimationController(true); _looping = true; TimeManager.StartUnscaled(TestAnimationRunnerBounds()); }
public void TestScripting() { TimeManager.StartUnscaled(ScriptingTest()); }
private void TestAnimation() { TimeManager.StartUnscaled(PainAnimation()); }
public void TestAnimation() { _looping = true; TimeManager.StartUnscaled(TestAnimationRunner()); }
private void WeaponBobTest() { TimeManager.StartUnscaled(RunWeaponBobTest()); }
private void TestReload() { TimeManager.StartUnscaled(RunTestReload()); }
public Task Play() { return(TimeManager.StartUnscaled(Animate())); }
public void Hide() { TimeManager.StartUnscaled(Despawn(_hideLength)); }
public static void Download(System.Action <string, char> del, string docId, string sheetId, bool saveAsset = false, string assetName = null) { TimeManager.StartUnscaled(DownloadCsv(del, docId, sheetId, saveAsset, assetName)); }
public Task Play(System.Action <Vector3> set, System.Action onComplete) { return(TimeManager.StartUnscaled(Animate(() => { set(Get()); }, onComplete))); }
public override void OnInspectorGUI() { _script = (ClipAnimator)target; if (_script.Animator == null) { _script.Animator = _script.gameObject.GetComponent <Animator>(); if (_script.Animator == null) { EditorGUILayout.LabelField("No Valid Animator"); DrawDefaultInspector(); return; } } EditorGUIUtility.labelWidth *= 0.5f; EditorGUI.BeginChangeCheck(); var normal = new GUIStyle("Box"); var selected = new GUIStyle("Box"); selected.normal.background = SelectedBackground; var animationLabels = PlayerAnimationIds.GetNames().ToArray(); var events = AnimationEvents.GetNames().ToArray(); for (int i = 0; i < _script.Clips.Length; i++) { var state = _script.Clips[i]; if (state.Clip != null) { state.ClipName = state.Clip.name; } EditorGUILayout.BeginVertical(_currentAnimation == state ? selected : normal); EditorGUILayout.BeginHorizontal(); var newClip = EditorGUILayout.ObjectField(state.Clip, typeof(AnimationClip), false); if (newClip != null && newClip is AnimationClip newAnimationClip && newAnimationClip != state.Clip) { state.Clip = newAnimationClip; } //EditorGUILayout.LabelField(state.Clip.name, EditorStyles.boldLabel); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); var index = System.Array.IndexOf(animationLabels, state.Id); //var index = labels.IndexOf(state.Id); var newIndex = EditorGUILayout.Popup(index, animationLabels); if (newIndex >= 0) { state.Id = animationLabels[newIndex]; } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Fps:"); state.Fps = EditorGUILayout.IntSlider((int)state.Fps, 1, 60); EditorGUILayout.EndHorizontal(); //EditorGUILayout.BeginHorizontal(); //EditorGUILayout.LabelField("Event:"); //state.PercentEvent = EditorGUILayout.Slider(state.PercentEvent, 0, 1); //EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Length Multi:"); state.PlaySpeedMultiplier = EditorGUILayout.Slider(state.PlaySpeedMultiplier, 0.1f, 5); EditorGUILayout.LabelField((state.ClipLength / state.PlaySpeedMultiplier).ToString("F1")); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Loop: " + state.Clip?.isLooping); if (GUILayout.Button("Delete")) { if (EditorUtility.DisplayDialog("", "Are you sure?", "Yes", "No")) { var list = _script.Clips.ToList(); list.RemoveAt(i); _script.Clips = list.ToArray(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); break; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (_currentAnimation == null) { if (GUILayout.Button("Play")) { TimeManager.StartUnscaled(PlayAnimation(_script, state)); } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Events: " + state.EventTotal()); } else if (_currentAnimation == state) { if (GUILayout.Button("Stop")) { Stop(); } var inputEvent = Event.current; if (inputEvent.type == EventType.KeyDown && inputEvent.shift) { switch (inputEvent.keyCode) { case KeyCode.Alpha1: _playType = (PlayType)0; KeyUsed(inputEvent); break; case KeyCode.Alpha2: _playType = (PlayType)1; KeyUsed(inputEvent); break; case KeyCode.Alpha3: _playType = (PlayType)2; KeyUsed(inputEvent); break; case KeyCode.Alpha4: _playType = (PlayType)3; KeyUsed(inputEvent); break; } } _playType = (PlayType)EditorGUILayout.EnumPopup(_playType); switch (_playType) { case PlayType.Percent: _forceTime = EditorGUILayout.Slider(_forceTime, 0, state.ClipLength); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Frame " + _currentFrame); break; case PlayType.Frame: state.CheckArraysLength(); _forceFrame = EditorGUILayout.IntSlider(_forceFrame, 0, state.RenderFrames.Length - 1); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); var width = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = width * 0.2f; var frameLayoutOptions = new GUILayoutOption[] { GUILayout.ExpandWidth(false), GUILayout.Width(50) }; state.RenderFrames[_forceFrame] = EditorGUILayout.Toggle("R: ", state.RenderFrames[_forceFrame], frameLayoutOptions); state.FrameLengths[_forceFrame] = EditorGUILayout.FloatField("L: ", state.FrameLengths[_forceFrame], frameLayoutOptions); EditorGUIUtility.labelWidth = width; var eventIndex = System.Array.IndexOf(events, state.Events[_forceFrame]); var newEventIndex = EditorGUILayout.Popup(eventIndex, events); if (eventIndex != newEventIndex) { state.Events[_forceFrame] = events[newEventIndex]; } var textBg = new GUIStyle(); if (!string.IsNullOrEmpty(state.Events[_forceFrame])) { textBg.normal.background = ErrorBackground; } state.Events[_forceFrame] = EditorGUILayout.TextArea(state.Events[_forceFrame], textBg); break; default: EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Frame " + _currentFrame); break; } if (inputEvent.type == EventType.KeyDown && _playType == PlayType.Frame) { switch (inputEvent.keyCode) { case KeyCode.F: state.RenderFrames[_forceFrame] = !state.RenderFrames[_forceFrame]; KeyUsed(inputEvent); break; case KeyCode.W: _forceFrame++; if (_forceFrame > state.RenderFrames.Length - 1) { _forceFrame = 0; } KeyUsed(inputEvent); break; case KeyCode.S: _forceFrame--; if (_forceFrame < 0) { _forceFrame = state.RenderFrames.Length - 1; } KeyUsed(inputEvent); break; case KeyCode.D: state.FrameLengths[_forceFrame] += 0.25f; KeyUsed(inputEvent); break; case KeyCode.A: state.FrameLengths[_forceFrame] -= 0.25f; KeyUsed(inputEvent); break; case KeyCode.X: state.FrameLengths[_forceFrame] = 1; KeyUsed(inputEvent); break; } } //EditorGUILayout.LabelField(_displayTime.ToString("F1")); } else { if (GUILayout.Button("Play")) { Stop(); TimeManager.StartUnscaled(PlayAnimation(_script, state)); } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Playing " + _currentAnimation?.ClipName); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); //EditorGUILayout.Space(); //EditorGUILayout.Space(); } //if (GUILayout.Button("Add Animation State")) { // _script.AnimationStates.Add(new AnimationState()); //} //EditorGUILayout.Space(); DropAreaGUI(); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(_script, _script.name); EditorUtility.SetDirty(_script); } EditorGUIUtility.labelWidth *= 2; if (GUILayout.Button("Save")) { var saveLocation = Application.dataPath + "/GameData"; var path = EditorUtility.SaveFilePanel("Save", saveLocation, "Layout", "json"); if (!string.IsNullOrEmpty(path) && path.Length > 0) { SaveFile(path); } } if (GUILayout.Button("Load")) { var saveLocation = Application.dataPath + "/GameData"; var path = EditorUtility.OpenFilePanel("Load", saveLocation, "json"); if (!string.IsNullOrEmpty(path) && path.Length > 0) { LoadFile(path); } } if (GUILayout.Button("Clear")) { if (EditorUtility.DisplayDialog("Are you sure?", "", "Yes", "No")) { _script.Clips = new AnimationClipState[0]; } } DrawDefaultInspector(); if (AnimationMode.InAnimationMode()) { if (GUILayout.Button("End Animation Mode")) { AnimationMode.StopAnimationMode(); _canPlay = false; } } }
public void Trigger(ActionStateEvent stateEvent) { TimeManager.StartUnscaled(AdvanceSequence(stateEvent)); }