void FadePreview() { EditorGUILayout.Space(); Lines(); EditorGUILayout.LabelField("<b>Preview:</b>", style); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Fade In"); float lastFadeIn = currentFadeIn; currentFadeIn = GUILayout.HorizontalSlider(currentFadeIn, 0, 1); GUILayout.Label(Mathf.RoundToInt(currentFadeIn * 100f) + "%", GUILayout.Width(50)); EditorGUILayout.EndHorizontal(); if (currentFadeIn != lastFadeIn || currentFadeIn > 0) { currentFadeOut = 0; dn.SetFadeIn(currentFadeIn); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Fade Out"); float lastFadeOut = currentFadeOut; currentFadeOut = GUILayout.HorizontalSlider(currentFadeOut, 0, 1); GUILayout.Label(Mathf.RoundToInt(currentFadeOut * 100f) + "%", GUILayout.Width(50)); EditorGUILayout.EndHorizontal(); if (currentFadeOut != lastFadeOut || currentFadeOut > 0) { currentFadeIn = 0; dn.SetFadeOut(1 - currentFadeOut); } Lines(); }
/// <summary> /// Use this function to prewarm the pool at the start of your game. /// It will generate enough damage numbers to fill the pool size. /// </summary> public void PrewarmPool() { if (enablePooling) { int instanceId = GetInstanceID(); //Initialize Dictionary: if (pools == null) { pools = new Dictionary <int, HashSet <DamageNumber> >(); } //Initialize Pool: if (!pools.ContainsKey(instanceId)) { pools.Add(instanceId, new HashSet <DamageNumber>()); } //Fill Pool: HashSet <DamageNumber> pool = pools[instanceId]; for (int n = 0; n < poolSize - pool.Count; n++) { DamageNumber dn = CreateNew(123, Vector3.zero); dn.destroyOnStart = true; dn.GetReferences(); dn.SetFadeIn(0); } } }
void OnEnable() { dn = (DamageNumber)target; try { if (!Application.isPlaying || dn.GetTextA() == false) { dn.GetReferences(); } }catch { return; } if (!Application.isPlaying) { currentFadeIn = currentFadeOut = 0; dn.SetFadeIn(1); } textA = dn.GetTextA(); textB = dn.GetTextB(); }