DamageNumberEditor.cs 108 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317
  1. #if UNITY_EDITOR
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEditor;
  6. using TMPro;
  7. using UnityEngine.Rendering;
  8. using DamageNumbersPro.Internal;
  9. using UnityEditor.SceneManagement;
  10. namespace DamageNumbersPro
  11. {
  12. [CustomEditor(typeof(DamageNumber), true), CanEditMultipleObjects]
  13. public class DamageNumberEditor : Editor
  14. {
  15. public static string version = "4.49";
  16. void OnEnable()
  17. {
  18. DNPEditorInternal.PrepareInspector(this);
  19. }
  20. public override void OnInspectorGUI()
  21. {
  22. // For some operations
  23. bool isMesh = DNPEditorInternal.damageNumbers[0].IsMesh();
  24. // Internal
  25. DNPEditorInternal.OnInspectorGUI(this);
  26. DNPEditorInternal.BeginInspector();
  27. DNPEditorInternal.DrawInspectorTop(isMesh);
  28. // Structure
  29. if (DNPEditorInternal.CheckStructure(this))
  30. {
  31. DNPEditorInternal.EndInspector();
  32. return;
  33. }
  34. // Detect and warn about common mistakes
  35. WarningCheck(isMesh);
  36. // Update
  37. serializedObject.Update();
  38. switch(DNPEditorInternal.currentTab)
  39. {
  40. case (0): // Main
  41. DisplayMainSettings();
  42. DisplayFeature("enable3DGame", "3D Game");
  43. break;
  44. case (1): // Text
  45. DisplayTextMain(isMesh);
  46. DisplayFeature("enableNumber", "Number");
  47. DisplayFeature("enableLeftText", "Left Text");
  48. DisplayFeature("enableRightText", "Right Text");
  49. DisplayFeature("enableTopText", "Top Text");
  50. DisplayFeature("enableBottomText", "Bottom Text");
  51. DisplayFeature("enableColorByNumber", "Color By Number");
  52. break;
  53. case (2): // Fade In
  54. DisplayFadeMain("In");
  55. DisplayFeature("enableOffsetFadeIn", "Offset In", "Offset");
  56. DisplayFeature("enableScaleFadeIn", "Scale In", "Scale");
  57. DisplayFeature("enableShakeFadeIn", "Shake In", "Shake");
  58. DisplayFeature("enableCrossScaleFadeIn", "Cross Scale In", "Cross Scale");
  59. break;
  60. case (3): // Fade Out
  61. DisplayFadeMain("Out");
  62. DisplayFeature("enableOffsetFadeOut", "Offset Out", "Offset");
  63. DisplayFeature("enableScaleFadeOut", "Scale Out", "Scale");
  64. DisplayFeature("enableShakeFadeOut", "Shake Out", "Shake");
  65. DisplayFeature("enableCrossScaleFadeOut", "Cross Scale Out", "Cross Scale");
  66. break;
  67. case (4): // Movement
  68. DisplayFeature("enableLerp", "Lerp");
  69. DisplayFeature("enableVelocity", "Velocity");
  70. DisplayFeature("enableShaking", "Shaking");
  71. DisplayFeature("enableFollowing", "Following");
  72. DisplayMovementHints(isMesh);
  73. break;
  74. case (5): // Scale
  75. DisplayFeature("enableStartRotation", "Start Rotation");
  76. DisplayFeature("enableRotateOverTime", "Rotate Over Time");
  77. DisplayFeature("enableScaleByNumber", "Scale By Number");
  78. DisplayFeature("enableScaleOverTime", "Scale Over Time");
  79. DisplayFeature("enableOrthographicScaling", "Orthographic Scaling");
  80. break;
  81. case (6): // Spam Control
  82. DisplaySpamControlMain(isMesh);
  83. DisplayFeature("enableCombination", "Combination");
  84. DisplayFeature("enableDestruction", "Destruction");
  85. DisplayFeature("enableCollision", "Collision");
  86. DisplayFeature("enablePush", "Push");
  87. DisplaySpamControlHints(isMesh);
  88. break;
  89. case (7): // Performance
  90. DisplayPerformanceMain();
  91. DisplayFeature("enablePooling", "Pooling");
  92. DisplayPerformanceHints();
  93. break;
  94. }
  95. // Fix Variables
  96. foreach(DamageNumber dn in DNPEditorInternal.damageNumbers)
  97. {
  98. FixAllVariables(dn);
  99. }
  100. // Apply Properties
  101. serializedObject.ApplyModifiedProperties();
  102. // Update Text
  103. if (Application.isPlaying == false)
  104. {
  105. foreach (DamageNumber damageNumber in DNPEditorInternal.damageNumbers)
  106. {
  107. if(damageNumber.gameObject.activeInHierarchy)
  108. {
  109. if (isMesh)
  110. {
  111. DNPEditorInternal.FixTextMeshPro();
  112. }
  113. try
  114. {
  115. damageNumber.UpdateText();
  116. damageNumber.UpdateAlpha(1);
  117. }
  118. catch
  119. {
  120. }
  121. if (isMesh)
  122. {
  123. damageNumber.GetTextMesh().gameObject.SetActive(true);
  124. }
  125. }
  126. }
  127. }
  128. // External Editors
  129. DNPEditorInternal.Externalnspectors(isMesh, target);
  130. DNPEditorInternal.FinalInformation();
  131. DNPEditorInternal.EndInspector();
  132. }
  133. #region Editor Menus
  134. [MenuItem("GameObject/Damage Numbers Pro/Damage Number (Mesh)", priority = 1)]
  135. public static void CreateDamageNumberMesh(MenuCommand menuCommand)
  136. {
  137. // Create GameObject
  138. GameObject newDN = new GameObject("Damage Number (Mesh)");
  139. GameObjectUtility.SetParentAndAlign(newDN, menuCommand.context as GameObject);
  140. Undo.RegisterCreatedObjectUndo(newDN, "Create " + newDN.name);
  141. Selection.activeObject = newDN;
  142. // Add damage number component
  143. newDN.AddComponent<DamageNumberMesh>();
  144. // Prepare Structure
  145. DNPEditorInternal.PrepareMeshStructure(newDN);
  146. // Position
  147. if(Camera.main != null)
  148. {
  149. // Position in front of the camera
  150. Vector3 position = Camera.main.transform.position + Camera.main.transform.forward * 10;
  151. // Set Z to 0 for 2D Games
  152. if(Camera.main.orthographic)
  153. {
  154. position.z = 0;
  155. }
  156. newDN.transform.position = position;
  157. }
  158. }
  159. [MenuItem("GameObject/Damage Numbers Pro/Damage Number (GUI)", priority = 2)]
  160. public static void CreateDamageNumberGUI(MenuCommand menuCommand)
  161. {
  162. // Create GameObject
  163. GameObject newDN = new GameObject("Damage Number (GUI)");
  164. GameObjectUtility.SetParentAndAlign(newDN, menuCommand.context as GameObject);
  165. Undo.RegisterCreatedObjectUndo(newDN, "Create " + newDN.name);
  166. Selection.activeObject = newDN;
  167. // Add damage number component
  168. newDN.AddComponent<DamageNumberGUI>();
  169. // Prepare Structure
  170. DNPEditorInternal.PrepareGUIStructure(newDN);
  171. // Position
  172. if (Camera.main != null)
  173. {
  174. // Position in front of the camera
  175. Vector3 position = Camera.main.transform.position + Camera.main.transform.forward * 10;
  176. // Set Z to 0 for 2D Games
  177. if (Camera.main.orthographic)
  178. {
  179. position.z = 0;
  180. }
  181. newDN.transform.position = position;
  182. }
  183. }
  184. [MenuItem("CONTEXT/DamageNumberMesh/Switch to GUI (experimental)")]
  185. public static void SwitchToGUI(MenuCommand menuCommand)
  186. {
  187. foreach(GameObject selected in Selection.gameObjects)
  188. {
  189. DamageNumberMesh oldComponent = selected.GetComponent<DamageNumberMesh>();
  190. Undo.RecordObject(oldComponent.gameObject, "Switched " + oldComponent.name);
  191. if (oldComponent != null)
  192. {
  193. // Get TMP Settings
  194. TMP_FontAsset fontAsset = oldComponent.GetFontMaterial();
  195. Color tmpColor = oldComponent.GetTextMesh().color;
  196. VertexGradient colorGradient = oldComponent.GetTextMesh().colorGradient;
  197. bool enableGradient = oldComponent.GetTextMesh().enableVertexGradient;
  198. // Clear Children
  199. while (oldComponent.transform.childCount > 0)
  200. {
  201. Object.DestroyImmediate(oldComponent.transform.GetChild(0).gameObject);
  202. }
  203. // Add GUI Component
  204. DamageNumberGUI newComponent = oldComponent.gameObject.AddComponent<DamageNumberGUI>();
  205. UnityEditorInternal.ComponentUtility.MoveComponentUp(newComponent);
  206. UnityEditorInternal.ComponentUtility.MoveComponentUp(newComponent);
  207. UnityEditorInternal.ComponentUtility.MoveComponentUp(newComponent);
  208. UnityEditorInternal.ComponentUtility.MoveComponentUp(newComponent);
  209. UnityEditorInternal.ComponentUtility.MoveComponentUp(newComponent);
  210. DNPEditorInternal.PrepareGUIStructure(selected);
  211. // TMP Settings
  212. newComponent.SetFontMaterial(fontAsset);
  213. foreach(TMP_Text tmp in newComponent.GetTextMeshs())
  214. {
  215. tmp.color = tmpColor;
  216. tmp.enableVertexGradient = enableGradient;
  217. tmp.colorGradient = colorGradient;
  218. }
  219. // Settings
  220. foreach (System.Reflection.FieldInfo propA in oldComponent.GetType().GetFields())
  221. {
  222. System.Reflection.FieldInfo propB = newComponent.GetType().GetField(propA.Name);
  223. if(propB.IsPublic && propB.IsPublic)
  224. {
  225. propB.SetValue(newComponent, propA.GetValue(oldComponent));
  226. }
  227. }
  228. // 3D
  229. newComponent.enable3DGame = false;
  230. // Remove old component
  231. DestroyImmediate(oldComponent);
  232. }
  233. }
  234. }
  235. [MenuItem("CONTEXT/DamageNumberGUI/Switch to Mesh (experimental)")]
  236. public static void SwitchToMesh(MenuCommand menuCommand)
  237. {
  238. foreach (GameObject selected in Selection.gameObjects)
  239. {
  240. DamageNumberGUI previousComponent = selected.GetComponent<DamageNumberGUI>();
  241. Undo.RecordObject(previousComponent.gameObject, "Switched " + previousComponent.name);
  242. if (previousComponent != null)
  243. {
  244. // Get TMP Settings
  245. TMP_FontAsset fontAsset = previousComponent.GetFontMaterial();
  246. Color tmpColor = previousComponent.GetTextMesh().color;
  247. VertexGradient colorGradient = previousComponent.GetTextMesh().colorGradient;
  248. bool enableGradient = previousComponent.GetTextMesh().enableVertexGradient;
  249. // Clear Children
  250. while (previousComponent.transform.childCount > 0)
  251. {
  252. Object.DestroyImmediate(previousComponent.transform.GetChild(0).gameObject);
  253. }
  254. // Add GUI Component
  255. DamageNumberMesh newComponent = previousComponent.gameObject.AddComponent<DamageNumberMesh>();
  256. UnityEditorInternal.ComponentUtility.MoveComponentUp(newComponent);
  257. UnityEditorInternal.ComponentUtility.MoveComponentUp(newComponent);
  258. UnityEditorInternal.ComponentUtility.MoveComponentUp(newComponent);
  259. UnityEditorInternal.ComponentUtility.MoveComponentUp(newComponent);
  260. UnityEditorInternal.ComponentUtility.MoveComponentUp(newComponent);
  261. DNPEditorInternal.PrepareMeshStructure(selected);
  262. // TMP Settings
  263. newComponent.SetFontMaterial(fontAsset);
  264. foreach (TMP_Text tmp in newComponent.GetTextMeshs())
  265. {
  266. tmp.color = tmpColor;
  267. tmp.enableVertexGradient = enableGradient;
  268. tmp.colorGradient = colorGradient;
  269. }
  270. // Settings
  271. foreach (System.Reflection.FieldInfo propA in previousComponent.GetType().GetFields())
  272. {
  273. System.Reflection.FieldInfo propB = newComponent.GetType().GetField(propA.Name);
  274. if (propB.IsPublic && propB.IsPublic)
  275. {
  276. propB.SetValue(newComponent, propA.GetValue(previousComponent));
  277. }
  278. }
  279. // 3D
  280. newComponent.CheckAndEnable3D();
  281. // Remove old components
  282. DestroyImmediate(previousComponent);
  283. RectTransform rectComponent = selected.GetComponent<RectTransform>();
  284. if(rectComponent != null)
  285. {
  286. Debug.Log("Please rightclick on the RectTransform component and select 'Remove Component'.");
  287. }
  288. }
  289. }
  290. }
  291. #endregion
  292. #region Fixing Variables
  293. void FixAllVariables(DamageNumber dn)
  294. {
  295. // Performance
  296. dn.updateDelay = Mathf.Max(0, dn.updateDelay);
  297. // Main
  298. dn.lifetime = Mathf.Max(0, dn.lifetime);
  299. dn.distanceScalingSettings.baseDistance = Mathf.Max(1, dn.distanceScalingSettings.baseDistance);
  300. // Text
  301. dn.numberSettings = FixTextSettings(dn.numberSettings);
  302. dn.leftTextSettings = FixTextSettings(dn.leftTextSettings);
  303. dn.rightTextSettings = FixTextSettings(dn.rightTextSettings);
  304. // Fade
  305. dn.durationFadeIn = Mathf.Max(0, dn.durationFadeIn);
  306. dn.durationFadeOut = Mathf.Max(0, dn.durationFadeOut);
  307. // Digit
  308. dn.digitSettings.decimals = Mathf.Max(0, dn.digitSettings.decimals);
  309. dn.digitSettings.dotDistance = Mathf.Max(0, dn.digitSettings.dotDistance);
  310. // Text Shader
  311. TMP_FontAsset font = dn.GetFontMaterial();
  312. string is3D = dn.enable3DGame ? "3D" : "";
  313. if(dn.enable3DGame && dn.IsMesh() && font != null && font.name + is3D != dn.editorLastFont)
  314. {
  315. dn.editorLastFont = font.name + is3D;
  316. Object[] objects = new Object[2];
  317. objects[0] = dn;
  318. objects[1] = font;
  319. Undo.RecordObjects(objects, "Swiched shader to distance field overlay.");
  320. // Fixing the text shader
  321. if(GraphicsSettings.currentRenderPipeline != null)
  322. {
  323. string pipeline = GraphicsSettings.currentRenderPipeline.GetType().ToString();
  324. if(pipeline.Contains("High") || pipeline.Contains("HD"))
  325. {
  326. }
  327. else
  328. {
  329. ChangeShaderToOverlay(dn);
  330. }
  331. }
  332. else
  333. {
  334. ChangeShaderToOverlay(dn);
  335. }
  336. // Fixing the sprite shader
  337. TMP_Text tmp = dn.GetTextMesh();
  338. if (tmp.spriteAsset != null && tmp.spriteAsset.material != null)
  339. {
  340. // Sprite Shader
  341. if (tmp.spriteAsset.material.shader.name != "TextMeshPro/Sprite Overlay")
  342. {
  343. Shader spriteOverlay = Shader.Find("TextMeshPro/Sprite Overlay");
  344. if (spriteOverlay != null)
  345. {
  346. tmp.spriteAsset.material.shader = spriteOverlay;
  347. }
  348. }
  349. }
  350. else
  351. {
  352. // Default Sprite Shader
  353. if (TMP_Settings.defaultSpriteAsset != null && TMP_Settings.defaultSpriteAsset.material != null && TMP_Settings.defaultSpriteAsset.material.shader.name != "TextMeshPro/Sprite Overlay")
  354. {
  355. Shader spriteOverlay = Shader.Find("TextMeshPro/Sprite Overlay");
  356. if (spriteOverlay != null)
  357. {
  358. TMP_Settings.defaultSpriteAsset.material.shader = spriteOverlay;
  359. }
  360. }
  361. }
  362. }
  363. }
  364. TextSettings FixTextSettings(TextSettings ts)
  365. {
  366. ts.horizontal = Mathf.Max(0, ts.horizontal);
  367. return ts;
  368. }
  369. #endregion
  370. #region Warnings
  371. void WarningCheck(bool isMesh)
  372. {
  373. // 3D Game and no 3D enabled
  374. bool gameIs3DWarning = false;
  375. if(isMesh)
  376. {
  377. Camera camera = Camera.main;
  378. if (camera != null)
  379. {
  380. if (camera.orthographic == false)
  381. {
  382. foreach (DamageNumber dn in DNPEditorInternal.damageNumbers)
  383. {
  384. if (!dn.enable3DGame)
  385. {
  386. gameIs3DWarning = true;
  387. break;
  388. }
  389. }
  390. }
  391. }
  392. }
  393. if(gameIs3DWarning)
  394. {
  395. EditorGUILayout.Space(2);
  396. DNPEditorInternal.StartBox(new Color(1, 1f, 0.8f));
  397. GUI.color = new Color(1, 1, 0.8f, 0.7f);
  398. DNPEditorInternal.ScalingLabel("Your main camera seems to be perspective <i>(3D)</i>.",298);
  399. DNPEditorInternal.ScalingLabel("Go to the <b>Main</b> tab and enable <b>3D Game</b>.",256);
  400. DNPEditorInternal.CloseBox(new Color(1, 1f, 0.7f));
  401. }
  402. // 3D but UI Warning
  403. if(isMesh == false)
  404. {
  405. foreach(DamageNumber dn in DNPEditorInternal.damageNumbers)
  406. {
  407. if(dn.enable3DGame)
  408. {
  409. EditorGUILayout.Space(2);
  410. DNPEditorInternal.StartBox(new Color(1, 1f, 0.8f));
  411. GUI.color = new Color(1, 1, 0.8f, 0.7f);
  412. DNPEditorInternal.ScalingLabel("You have <b>3D Game</b> enabled on the <b>GUI</b> version.", 298);
  413. DNPEditorInternal.ScalingLabel("This component is for spawning prefabs in a <b>GUI</b> canvas.", 298);
  414. DNPEditorInternal.CloseBox(new Color(1, 1f, 0.7f));
  415. }
  416. }
  417. }
  418. // Pooling and Runtime Prefab Edits
  419. bool runtimePoolingWarning = false;
  420. if (Application.isPlaying)
  421. {
  422. foreach (DamageNumber dn in DNPEditorInternal.damageNumbers)
  423. {
  424. if (dn.enablePooling)
  425. {
  426. runtimePoolingWarning = true;
  427. break;
  428. }
  429. }
  430. }
  431. if (runtimePoolingWarning)
  432. {
  433. EditorGUILayout.Space(2);
  434. DNPEditorInternal.StartBox(new Color(1, 1f, 0.8f));
  435. GUI.color = new Color(1, 1, 0.8f, 0.7f);
  436. DNPEditorInternal.ScalingLabel("You are editing this prefab at <b>runtime</b> with <b>pooling</b> enabled.",361);
  437. DNPEditorInternal.ScalingLabel("Prefab <b>changes</b> will not affect <b>pooled</b> damage numbers.",343);
  438. DNPEditorInternal.CloseBox(new Color(1, 1f, 0.7f));
  439. }
  440. // Scale By Number but no Numbers
  441. bool scaleByNumbersWarning = false;
  442. foreach (DamageNumber dn in DNPEditorInternal.damageNumbers)
  443. {
  444. if (dn.enableScaleByNumber && !dn.enableNumber)
  445. {
  446. scaleByNumbersWarning = true;
  447. break;
  448. }
  449. }
  450. if (scaleByNumbersWarning)
  451. {
  452. EditorGUILayout.Space(2);
  453. DNPEditorInternal.StartBox(new Color(1, 1f, 0.8f));
  454. GUI.color = new Color(1, 1, 0.8f, 0.7f);
  455. DNPEditorInternal.ScalingLabel("<b>Scale By Number</b> will not work if <b>Number</b> is disabled.",327);
  456. DNPEditorInternal.CloseBox(new Color(1, 1f, 0.7f));
  457. }
  458. // Color By Number but no Numbers
  459. bool colorByNumbersWarning = false;
  460. foreach (DamageNumber dn in DNPEditorInternal.damageNumbers)
  461. {
  462. if (dn.enableColorByNumber && !dn.enableNumber)
  463. {
  464. colorByNumbersWarning = true;
  465. break;
  466. }
  467. }
  468. if (colorByNumbersWarning)
  469. {
  470. EditorGUILayout.Space(2);
  471. DNPEditorInternal.StartBox(new Color(1, 1f, 0.8f));
  472. GUI.color = new Color(1, 1, 0.8f, 0.7f);
  473. DNPEditorInternal.ScalingLabel("<b>Color By Number</b> will not work if <b>Number</b> is disabled.", 327);
  474. DNPEditorInternal.CloseBox(new Color(1, 1f, 0.7f));
  475. }
  476. // Collision but no Lerp
  477. bool collisionWarning = false;
  478. foreach (DamageNumber dn in DNPEditorInternal.damageNumbers)
  479. {
  480. if (dn.enableCollision && !dn.enableLerp)
  481. {
  482. collisionWarning = true;
  483. break;
  484. }
  485. }
  486. if (collisionWarning)
  487. {
  488. EditorGUILayout.Space(2);
  489. DNPEditorInternal.StartBox(new Color(1, 1f, 0.8f));
  490. GUI.color = new Color(1, 1, 0.8f, 0.7f);
  491. DNPEditorInternal.ScalingLabel("<b>Collision</b> will not work if <b>Lerp</b> movement is disabled.",317);
  492. DNPEditorInternal.CloseBox(new Color(1, 1f, 0.7f));
  493. }
  494. // Push but no Lerp
  495. bool pushWarning = false;
  496. foreach (DamageNumber dn in DNPEditorInternal.damageNumbers)
  497. {
  498. if (dn.enablePush && !dn.enableLerp)
  499. {
  500. pushWarning = true;
  501. break;
  502. }
  503. }
  504. if (pushWarning)
  505. {
  506. EditorGUILayout.Space(2);
  507. DNPEditorInternal.StartBox(new Color(1, 1f, 0.8f));
  508. GUI.color = new Color(1, 1, 0.8f, 0.7f);
  509. DNPEditorInternal.ScalingLabel("<b>Push</b> will not work if <b>Lerp</b> movement is disabled.",298);
  510. DNPEditorInternal.CloseBox(new Color(1, 1f, 0.7f));
  511. }
  512. }
  513. #endregion
  514. #region Properties
  515. void DisplayFeature(string togglePropertyName, string featureTitle = "", string displayedTitle = "")
  516. {
  517. // Create title if needed
  518. if (featureTitle == "")
  519. {
  520. featureTitle = togglePropertyName.Replace("enable", "");
  521. }
  522. if(displayedTitle == "")
  523. {
  524. displayedTitle = featureTitle;
  525. }
  526. EditorGUILayout.Space(2);
  527. // Get Toggle Property
  528. SerializedProperty toggleProperty = serializedObject.FindProperty(togglePropertyName);
  529. // Start Box
  530. DNPEditorInternal.StartBox(toggleProperty.hasMultipleDifferentValues || toggleProperty.boolValue);
  531. // Top
  532. EditorGUILayout.BeginHorizontal();
  533. bool showProperties = FeatureButton(toggleProperty, displayedTitle);
  534. EditorGUILayout.LabelField("", GUILayout.MinWidth(0));
  535. // Extra Buttons
  536. #region Text Position
  537. if(showProperties)
  538. {
  539. switch (togglePropertyName)
  540. {
  541. case ("enableLeftText"):
  542. int leftTextPosition = TextPosition(0);
  543. if (leftTextPosition != 0)
  544. {
  545. EditorGUIUtility.keyboardControl = EditorGUIUtility.hotControl = 0; // Unselect Fields
  546. foreach (DamageNumber dn in DNPEditorInternal.damageNumbers)
  547. {
  548. bool originalTextEnabled = dn.enableLeftText;
  549. string originalTextString = dn.leftText;
  550. TextSettings originalTextSettings = dn.leftTextSettings;
  551. switch (leftTextPosition)
  552. {
  553. case (1):
  554. dn.enableLeftText = dn.enableRightText;
  555. dn.leftText = dn.rightText;
  556. dn.leftTextSettings = dn.rightTextSettings;
  557. dn.enableRightText = originalTextEnabled;
  558. dn.rightText = originalTextString;
  559. dn.rightTextSettings = originalTextSettings;
  560. break;
  561. case (2):
  562. dn.enableLeftText = dn.enableTopText;
  563. dn.leftText = dn.topText;
  564. dn.leftTextSettings = dn.topTextSettings;
  565. dn.enableTopText = originalTextEnabled;
  566. dn.topText = originalTextString;
  567. dn.topTextSettings = originalTextSettings;
  568. break;
  569. case (3):
  570. dn.enableLeftText = dn.enableBottomText;
  571. dn.leftText = dn.bottomText;
  572. dn.leftTextSettings = dn.bottomTextSettings;
  573. dn.enableBottomText = originalTextEnabled;
  574. dn.bottomText = originalTextString;
  575. dn.bottomTextSettings = originalTextSettings;
  576. break;
  577. }
  578. }
  579. }
  580. break;
  581. case ("enableRightText"):
  582. int rightTextPosition = TextPosition(1);
  583. if (rightTextPosition != 1)
  584. {
  585. EditorGUIUtility.keyboardControl = EditorGUIUtility.hotControl = 0; // Unselect Fields
  586. foreach (DamageNumber dn in DNPEditorInternal.damageNumbers)
  587. {
  588. bool originalTextEnabled = dn.enableRightText;
  589. string originalTextString = dn.rightText;
  590. TextSettings originalTextSettings = dn.rightTextSettings;
  591. switch (rightTextPosition)
  592. {
  593. case (0):
  594. dn.enableRightText = dn.enableLeftText;
  595. dn.rightText = dn.leftText;
  596. dn.rightTextSettings = dn.leftTextSettings;
  597. dn.enableLeftText = originalTextEnabled;
  598. dn.leftText = originalTextString;
  599. dn.leftTextSettings = originalTextSettings;
  600. break;
  601. case (2):
  602. dn.enableRightText = dn.enableTopText;
  603. dn.rightText = dn.topText;
  604. dn.rightTextSettings = dn.topTextSettings;
  605. dn.enableTopText = originalTextEnabled;
  606. dn.topText = originalTextString;
  607. dn.topTextSettings = originalTextSettings;
  608. break;
  609. case (3):
  610. dn.enableRightText = dn.enableBottomText;
  611. dn.rightText = dn.bottomText;
  612. dn.rightTextSettings = dn.bottomTextSettings;
  613. dn.enableBottomText = originalTextEnabled;
  614. dn.bottomText = originalTextString;
  615. dn.bottomTextSettings = originalTextSettings;
  616. break;
  617. }
  618. }
  619. }
  620. break;
  621. case ("enableTopText"):
  622. int topTextPosition = TextPosition(2);
  623. if (topTextPosition != 2)
  624. {
  625. EditorGUIUtility.keyboardControl = EditorGUIUtility.hotControl = 0; // Unselect Fields
  626. foreach (DamageNumber dn in DNPEditorInternal.damageNumbers)
  627. {
  628. bool originalTextEnabled = dn.enableTopText;
  629. string originalTextString = dn.topText;
  630. TextSettings originalTextSettings = dn.topTextSettings;
  631. switch (topTextPosition)
  632. {
  633. case (0):
  634. dn.enableTopText = dn.enableLeftText;
  635. dn.topText = dn.leftText;
  636. dn.topTextSettings = dn.leftTextSettings;
  637. dn.enableLeftText = originalTextEnabled;
  638. dn.leftText = originalTextString;
  639. dn.leftTextSettings = originalTextSettings;
  640. break;
  641. case (1):
  642. dn.enableTopText = dn.enableRightText;
  643. dn.topText = dn.rightText;
  644. dn.topTextSettings = dn.rightTextSettings;
  645. dn.enableRightText = originalTextEnabled;
  646. dn.rightText = originalTextString;
  647. dn.rightTextSettings = originalTextSettings;
  648. break;
  649. case (3):
  650. dn.enableTopText = dn.enableBottomText;
  651. dn.topText = dn.bottomText;
  652. dn.topTextSettings = dn.bottomTextSettings;
  653. dn.enableBottomText = originalTextEnabled;
  654. dn.bottomText = originalTextString;
  655. dn.bottomTextSettings = originalTextSettings;
  656. break;
  657. }
  658. }
  659. }
  660. break;
  661. case ("enableBottomText"):
  662. int bottomTextPosition = TextPosition(3);
  663. if (bottomTextPosition != 3)
  664. {
  665. EditorGUIUtility.keyboardControl = EditorGUIUtility.hotControl = 0; // Unselect Fields
  666. foreach (DamageNumber dn in DNPEditorInternal.damageNumbers)
  667. {
  668. bool originalTextEnabled = dn.enableBottomText;
  669. string originalTextString = dn.bottomText;
  670. TextSettings originalTextSettings = dn.bottomTextSettings;
  671. switch (bottomTextPosition)
  672. {
  673. case (0):
  674. dn.enableBottomText = dn.enableLeftText;
  675. dn.bottomText = dn.leftText;
  676. dn.bottomTextSettings = dn.leftTextSettings;
  677. dn.enableLeftText = originalTextEnabled;
  678. dn.leftText = originalTextString;
  679. dn.leftTextSettings = originalTextSettings;
  680. break;
  681. case (1):
  682. dn.enableBottomText = dn.enableRightText;
  683. dn.bottomText = dn.rightText;
  684. dn.bottomTextSettings = dn.rightTextSettings;
  685. dn.enableRightText = originalTextEnabled;
  686. dn.rightText = originalTextString;
  687. dn.rightTextSettings = originalTextSettings;
  688. break;
  689. case (2):
  690. dn.enableBottomText = dn.enableTopText;
  691. dn.bottomText = dn.topText;
  692. dn.bottomTextSettings = dn.topTextSettings;
  693. dn.enableTopText = originalTextEnabled;
  694. dn.topText = originalTextString;
  695. dn.topTextSettings = originalTextSettings;
  696. break;
  697. }
  698. }
  699. }
  700. break;
  701. }
  702. }
  703. #endregion
  704. if (showProperties)
  705. {
  706. ResetButton(featureTitle);
  707. }
  708. bool showHints = DNPEditorInternal.HintButton(featureTitle);
  709. EditorGUILayout.EndHorizontal();
  710. // Hints
  711. if(showHints)
  712. {
  713. DNPEditorInternal.Lines();
  714. GUI.color = new Color(1, 1, 1, 0.7f);
  715. switch(featureTitle)
  716. {
  717. // Main
  718. case ("3D Game"):
  719. DNPEditorInternal.Label("<b>Function:</b>");
  720. DNPEditorInternal.Label("- Handles <b>facing</b> the camera.");
  721. DNPEditorInternal.Label("- Handles <b>screen size</b> over distance.");
  722. DNPEditorInternal.Label("- Can handle rendering <b>through walls</b>.");
  723. DNPEditorInternal.Label("");
  724. DNPEditorInternal.Label("<b>Information:</b>");
  725. DNPEditorInternal.Label("- Enable this feature in <b>3D</b> projects.");
  726. break;
  727. // Text Content
  728. case ("Number"):
  729. DNPEditorInternal.Label("<b>Function:</b>");
  730. DNPEditorInternal.Label("- Displays a <b>number</b>.");
  731. DNPEditorInternal.Label("- Has several <b>text formatting</b> options.");
  732. DNPEditorInternal.Label("- Number can be displayed as an <b>integer</b> or in <b>decimals</b>.");
  733. DNPEditorInternal.Label("- Large numbers can be <b>dot separated</b> or <b>suffix shortened</b>.");
  734. DNPEditorInternal.Label("");
  735. DNPEditorInternal.Label("<b>Information:</b>");
  736. DNPEditorInternal.Label("- If you want <b>text-only</b> simply disable this and enable <b>Left Text</b>.");
  737. DNPEditorInternal.Label("- Text positions are <b>relative</b> to the number.");
  738. DNPEditorInternal.Label("- Numbers will be added up if <b>Combination</b> is enabled.");
  739. DNPEditorInternal.Label("- Numbers will be used by <b>Scale by Number</b>.");
  740. break;
  741. case ("Left Text"):
  742. DNPEditorInternal.Label("<b>Function:</b>");
  743. DNPEditorInternal.Label("- Displays <b>text</b> on the left side.");
  744. DNPEditorInternal.Label("- Has several <b>text formatting</b> options.");
  745. DNPEditorInternal.Label("");
  746. DNPEditorInternal.Label("<b>Information:</b>");
  747. DNPEditorInternal.Label("- If <b>number</b> is disabled this will be <b>centered</b>.");
  748. DNPEditorInternal.Label("- You can use the <b>arrow</b> buttons to swap the position.");
  749. DNPEditorInternal.Label("- The <b>Spawn(...)</b> function has overrides which set this text.");
  750. break;
  751. case ("Right Text"):
  752. DNPEditorInternal.Label("<b>Function:</b>");
  753. DNPEditorInternal.Label("- Displays <b>text</b> on the right side.");
  754. DNPEditorInternal.Label("- Has several <b>text formatting</b> options.");
  755. DNPEditorInternal.Label("");
  756. DNPEditorInternal.Label("<b>Information:</b>");
  757. DNPEditorInternal.Label("- If <b>number</b> is disabled this will be <b>centered</b>.");
  758. DNPEditorInternal.Label("- You can use the <b>arrow</b> buttons to swap the position.");
  759. break;
  760. case ("Top Text"):
  761. DNPEditorInternal.Label("<b>Function:</b>");
  762. DNPEditorInternal.Label("- Displays <b>text</b> on the top side.");
  763. DNPEditorInternal.Label("- Has several <b>text formatting</b> options.");
  764. DNPEditorInternal.Label("");
  765. DNPEditorInternal.Label("<b>Information:</b>");
  766. DNPEditorInternal.Label("- You can use the <b>arrow</b> buttons to swap the position.");
  767. break;
  768. case ("Bottom Text"):
  769. DNPEditorInternal.Label("<b>Function:</b>");
  770. DNPEditorInternal.Label("- Displays <b>text</b> on the bottom side.");
  771. DNPEditorInternal.Label("- Has several <b>text formatting</b> options.");
  772. DNPEditorInternal.Label("");
  773. DNPEditorInternal.Label("<b>Information:</b>");
  774. DNPEditorInternal.Label("- You can use the <b>arrow</b> buttons to swap the position.");
  775. break;
  776. case ("Color By Number"):
  777. DNPEditorInternal.Label("<b>Function:</b>");
  778. DNPEditorInternal.Label("- Changes the <b>color</b> based on the <b>number</b>.");
  779. DNPEditorInternal.Label("- <b>Larger</b> and <b>smaller</b> numbers can have different <b>tints</b>.");
  780. break;
  781. // Movement
  782. case ("Lerp"):
  783. DNPEditorInternal.Label("<b>Function:</b>");
  784. DNPEditorInternal.Label("- Moves towards a random <b>offset</b>.");
  785. DNPEditorInternal.Label("- <b>Slows</b> down as it gets closer to it's target position.");
  786. DNPEditorInternal.Label("");
  787. DNPEditorInternal.Label("<b>Information:</b>");
  788. DNPEditorInternal.Label("- This is the most <b>popular</b> and <b>readable</b> option.");
  789. DNPEditorInternal.Label("- Some features require this and warn you if <b>Lerp</b> is disabled.");
  790. DNPEditorInternal.Label("- Offset is relative to <b>view</b> direction.");
  791. break;
  792. case ("Velocity"):
  793. DNPEditorInternal.Label("<b>Function:</b>");
  794. DNPEditorInternal.Label("- Moves at a random <b>velocity</b>.");
  795. DNPEditorInternal.Label("- Has <b>drag</b> and <b>gravity</b> options.");
  796. DNPEditorInternal.Label("");
  797. DNPEditorInternal.Label("<b>Information:</b>");
  798. DNPEditorInternal.Label("- Movement is relative to <b>view</b> direction.");
  799. break;
  800. case ("Shaking"):
  801. DNPEditorInternal.Label("<b>Function:</b>");
  802. DNPEditorInternal.Label("- Moves <b>back</b> and <b>forth</b>.");
  803. DNPEditorInternal.Label("");
  804. DNPEditorInternal.Label("<b>Information:</b>");
  805. DNPEditorInternal.Label("- Can be used for <b>shaking</b> or <b>vibration</b> effects.");
  806. break;
  807. case ("Following"):
  808. DNPEditorInternal.Label("<b>Function:</b>");
  809. DNPEditorInternal.Label("- Follows the <b>target</b> transform.");
  810. DNPEditorInternal.Label("- Maintains <b>relative position</b> to target.");
  811. DNPEditorInternal.Label("");
  812. DNPEditorInternal.Label("<b>Information:</b>");
  813. DNPEditorInternal.Label("- Lower speeds are more <b>smooth</b>.");
  814. DNPEditorInternal.Label("- Higher speeds are more <b>static</b>.");
  815. DNPEditorInternal.Label("- Drag can be used to <b>fade out</b> the following.");
  816. break;
  817. // Fade In
  818. case ("Offset In"):
  819. DNPEditorInternal.Label("<b>Function:</b>");
  820. DNPEditorInternal.Label("- Moves 2 meshs <b>together</b> from a <b>offset</b>.");
  821. DNPEditorInternal.Label("");
  822. DNPEditorInternal.Label("<b>Information:</b>");
  823. DNPEditorInternal.Label("- Creates a <b>fusion-like</b> effect.");
  824. break;
  825. case ("Scale In"):
  826. DNPEditorInternal.Label("<b>Function:</b>");
  827. DNPEditorInternal.Label("- Fades in from a customizable <b>scale</b>.");
  828. DNPEditorInternal.Label("");
  829. DNPEditorInternal.Label("<b>Information:</b>");
  830. DNPEditorInternal.Label("- Is used for <b>shrinking</b> or <b>growing</b> when fading in.");
  831. break;
  832. case ("Cross Scale In"):
  833. DNPEditorInternal.Label("<b>Function:</b>");
  834. DNPEditorInternal.Label("- <b>Scales</b> one mesh and <b>divides</b> the scale of the other.");
  835. DNPEditorInternal.Label("");
  836. DNPEditorInternal.Label("<b>Information:</b>");
  837. DNPEditorInternal.Label("- <b>Inverse</b> scales one mesh and <b>normally</b> scales the other.");
  838. break;
  839. case ("Shake In"):
  840. DNPEditorInternal.Label("<b>Function:</b>");
  841. DNPEditorInternal.Label("- <b>Shakes</b> as it fades in.");
  842. DNPEditorInternal.Label("");
  843. DNPEditorInternal.Label("<b>Information:</b>");
  844. DNPEditorInternal.Label("- Used for <b>vibration</b> or <b>motion</b> when fading in.");
  845. break;
  846. // Fade Out
  847. case ("Offset Out"):
  848. DNPEditorInternal.Label("<b>Function:</b>");
  849. DNPEditorInternal.Label("- Moves 2 meshs <b>apart</b> to a <b>offset</b>.");
  850. DNPEditorInternal.Label("");
  851. DNPEditorInternal.Label("<b>Information:</b>");
  852. DNPEditorInternal.Label("- Creates a <b>diffusion-like</b> effect.");
  853. break;
  854. case ("Scale Out"):
  855. DNPEditorInternal.Label("<b>Function:</b>");
  856. DNPEditorInternal.Label("- Fades out to a customizable <b>scale</b>.");
  857. DNPEditorInternal.Label("");
  858. DNPEditorInternal.Label("<b>Information:</b>");
  859. DNPEditorInternal.Label("- Is used for <b>shrinking</b> or <b>growing</b> when fading out.");
  860. break;
  861. case ("Cross Scale Out"):
  862. DNPEditorInternal.Label("<b>Function:</b>");
  863. DNPEditorInternal.Label("- <b>Scales</b> one mesh and <b>divides</b> the scale of the other.");
  864. DNPEditorInternal.Label("");
  865. DNPEditorInternal.Label("<b>Information:</b>");
  866. DNPEditorInternal.Label("- <b>Inverse</b> scales one mesh and <b>normally</b> scales the other.");
  867. break;
  868. case ("Shake Out"):
  869. DNPEditorInternal.Label("<b>Function:</b>");
  870. DNPEditorInternal.Label("- <b>Shakes</b> as it fades out.");
  871. DNPEditorInternal.Label("");
  872. DNPEditorInternal.Label("<b>Information:</b>");
  873. DNPEditorInternal.Label("- Used for <b>vibration</b> or <b>motion</b> when fading out.");
  874. break;
  875. // Rotation & Scale
  876. case ("Start Rotation"):
  877. DNPEditorInternal.Label("<b>Function:</b>");
  878. DNPEditorInternal.Label("- Spawns at a random <b>rotation</b>.");
  879. break;
  880. case ("Rotate Over Time"):
  881. DNPEditorInternal.Label("<b>Function:</b>");
  882. DNPEditorInternal.Label("- Rotates at a random <b>rotation speed</b> over time.");
  883. DNPEditorInternal.Label("");
  884. DNPEditorInternal.Label("<b>Information:</b>");
  885. DNPEditorInternal.Label("- Speed over time can be customized in a <b>curve</b>.");
  886. break;
  887. case ("Scale By Number"):
  888. DNPEditorInternal.Label("<b>Function:</b>");
  889. DNPEditorInternal.Label("- Scales based on the <b>number's size</b>.");
  890. DNPEditorInternal.Label("");
  891. DNPEditorInternal.Label("<b>Information:</b>");
  892. DNPEditorInternal.Label("- Bigger numbers are <b>larger</b>.");
  893. DNPEditorInternal.Label("- Will also work with <b>Combination</b>.");
  894. break;
  895. case ("Scale Over Time"):
  896. DNPEditorInternal.Label("<b>Function:</b>");
  897. DNPEditorInternal.Label("- Changes scale over <b>time</b>.");
  898. DNPEditorInternal.Label("");
  899. DNPEditorInternal.Label("<b>Information:</b>");
  900. DNPEditorInternal.Label("- Scale over time can be customized in a <b>curve</b>.");
  901. break;
  902. case ("Orthographic Scaling"):
  903. DNPEditorInternal.Label("<b>Function:</b>");
  904. DNPEditorInternal.Label("- Scales the popup to keep it's screen size consistent, when zooming in <b>2D projects</b>.");
  905. DNPEditorInternal.Label("");
  906. DNPEditorInternal.Label("<b>Information:</b>");
  907. DNPEditorInternal.Label("- Scale is based on the camera's orthographic size.");
  908. break;
  909. // Spam Control
  910. case ("Combination"):
  911. DNPEditorInternal.Label("<b>Function:</b>");
  912. DNPEditorInternal.Label("- <b>Combines</b> with other damage numbers within range.");
  913. DNPEditorInternal.Label("- <b>Adds up</b> the combined numbers.");
  914. DNPEditorInternal.Label("");
  915. DNPEditorInternal.Label("<b>Information:</b>");
  916. DNPEditorInternal.Label("- <b>ABSORB_NEW</b> makes the oldest damage number absorb new ones.");
  917. DNPEditorInternal.Label("- <b>REPLACE_OLD</b> makes the newest damage number absorb older ones.");
  918. DNPEditorInternal.Label("- Animation can be customized using <b>curves</b>.");
  919. DNPEditorInternal.Label("- Absorber can get a <b>scale up</b> upon absorbing a damage number.");
  920. break;
  921. case ("Destruction"):
  922. DNPEditorInternal.Label("<b>Function:</b>");
  923. DNPEditorInternal.Label("- <b>Destroys</b> older damage numbers.");
  924. DNPEditorInternal.Label("");
  925. DNPEditorInternal.Label("<b>Information:</b>");
  926. DNPEditorInternal.Label("- Has a custom <b>fade out</b> animation for destroyed damage numbers.");
  927. break;
  928. case ("Collision"):
  929. DNPEditorInternal.Label("<b>Function:</b>");
  930. DNPEditorInternal.Label("- Collides with other damage numbers to <b>spread</b> out.");
  931. DNPEditorInternal.Label("");
  932. DNPEditorInternal.Label("<b>Information:</b>");
  933. DNPEditorInternal.Label("- If desired direction is set to something like <b>(0,10,0)</b> they will spread up.");
  934. break;
  935. case ("Push"):
  936. DNPEditorInternal.Label("<b>Function:</b>");
  937. DNPEditorInternal.Label("- Simply <b>moves</b> damage numbers by a custom offset within range.");
  938. DNPEditorInternal.Label("");
  939. DNPEditorInternal.Label("<b>Information:</b>");
  940. DNPEditorInternal.Label("- This is a more efficient version of <b>Collision</b>.");
  941. DNPEditorInternal.Label("- Use this on <b>closely spawned</b> damage numbers only.");
  942. break;
  943. // Performance
  944. case ("Pooling"):
  945. DNPEditorInternal.Label("<b>Function:</b>");
  946. DNPEditorInternal.Label("- Improves <b>spawn performance</b> by recycling damage numbers.");
  947. DNPEditorInternal.Label("");
  948. DNPEditorInternal.Label("<b>Information:</b>");
  949. DNPEditorInternal.Label("- Pool size should be <b>higher</b> if you spawn more damage numbers per second.");
  950. DNPEditorInternal.Label("- New damage numbers are <b>added to the pool</b> if it's not full yet.");
  951. DNPEditorInternal.Label("- Each prefab has it's <b>own</b> pool.");
  952. DNPEditorInternal.Label("- Use <b>PrewarmPool()</b> on a prefab to prepare it's pool.");
  953. break;
  954. }
  955. GUI.color = Color.white;
  956. }
  957. // Properties
  958. if(showProperties)
  959. {
  960. DNPEditorInternal.Lines();
  961. switch (featureTitle)
  962. {
  963. // Main
  964. case ("3D Game"):
  965. SerializedProperty faceCameraView = serializedObject.FindProperty("faceCameraView");
  966. EditorGUILayout.PropertyField(faceCameraView);
  967. if(faceCameraView.boolValue || faceCameraView.hasMultipleDifferentValues)
  968. {
  969. SerializedProperty lookAtCamera = serializedObject.FindProperty("lookAtCamera");
  970. EditorGUILayout.PropertyField(lookAtCamera, new GUIContent("Look At (For VR)"));
  971. if(lookAtCamera.boolValue || lookAtCamera.hasMultipleDifferentValues)
  972. {
  973. GUI.color = new Color(1, 1, 1, 0.7f);
  974. DNPEditorInternal.Label("- Costs <b>more performance</b> and should only be used in <b>VR</b>.");
  975. GUI.color = Color.white;
  976. }
  977. }
  978. DNPEditorInternal.Lines();
  979. // Check Materials
  980. bool hasOverlayMaterials = false;
  981. bool hasBadMaterials = false;
  982. foreach (DamageNumber dn in DNPEditorInternal.damageNumbers)
  983. {
  984. dn.GetReferencesIfNecessary();
  985. Material[] materials = dn.GetSharedMaterials();
  986. if(materials != null)
  987. {
  988. foreach (Material mat in materials)
  989. {
  990. if(mat != null && mat.shader.name.EndsWith("verlay"))
  991. {
  992. hasOverlayMaterials = true;
  993. }
  994. else
  995. {
  996. hasBadMaterials = true;
  997. }
  998. }
  999. }
  1000. }
  1001. if(hasOverlayMaterials && !hasBadMaterials)
  1002. {
  1003. GUI.enabled = false;
  1004. }
  1005. SerializedProperty renderThroughWalls = serializedObject.FindProperty("renderThroughWalls");
  1006. EditorGUILayout.PropertyField(renderThroughWalls);
  1007. if (hasOverlayMaterials && !hasBadMaterials)
  1008. {
  1009. GUI.enabled = true;
  1010. renderThroughWalls.boolValue = false;
  1011. PropertyOverlay(DNPEditorInternal.CheckmarkString(true) + " Overlay Shader.");
  1012. }else
  1013. {
  1014. if(DNPEditorInternal.currentWidth < 344)
  1015. {
  1016. if (DNPEditorInternal.currentWidth < 277)
  1017. {
  1018. PropertyOverlay(DNPEditorInternal.CheckmarkString(false) + " Shader");
  1019. }
  1020. else
  1021. {
  1022. PropertyOverlay(DNPEditorInternal.CheckmarkString(false) + " Overlay Shader");
  1023. }
  1024. }
  1025. else
  1026. {
  1027. PropertyOverlay(DNPEditorInternal.CheckmarkString(false) + " Not using overlay shader.");
  1028. }
  1029. }
  1030. if(renderThroughWalls.boolValue || renderThroughWalls.hasMultipleDifferentValues)
  1031. {
  1032. GUI.color = new Color(1, 1, 1, 0.7f);
  1033. EditorGUILayout.Space();
  1034. DNPEditorInternal.ScalingLabel("This option exists in-case the overlay shader does <b>not work</b>.", 371);
  1035. DNPEditorInternal.ScalingLabel("Make sure to try the <b>'Distance Field Overlay'</b> shader first.",354);
  1036. DNPEditorInternal.ScalingLabel("It's better for <b>performance</b> to use the shader instead.",330);
  1037. EditorGUILayout.Space();
  1038. EditorGUILayout.BeginHorizontal();
  1039. DNPEditorInternal.ScalingLabel("Go to the material or use the button.",333);
  1040. GUI.color = Color.white;
  1041. bool buttonPressed = false;
  1042. if(DNPEditorInternal.currentWidth < 283)
  1043. {
  1044. buttonPressed = GUILayout.Button("Try");
  1045. }
  1046. else
  1047. {
  1048. buttonPressed = GUILayout.Button("Try Shader");
  1049. }
  1050. if (buttonPressed)
  1051. {
  1052. foreach (DamageNumber dn in DNPEditorInternal.damageNumbers)
  1053. {
  1054. ChangeShaderToOverlay(dn);
  1055. }
  1056. }
  1057. EditorGUILayout.EndHorizontal();
  1058. }
  1059. DNPEditorInternal.Lines();
  1060. SerializedProperty consistentScale = serializedObject.FindProperty("consistentScreenSize");
  1061. EditorGUILayout.PropertyField(consistentScale);
  1062. GUI.enabled = consistentScale.boolValue || consistentScale.hasMultipleDifferentValues;
  1063. EditorGUILayout.BeginHorizontal();
  1064. EditorGUILayout.LabelField("", GUILayout.Width(9));
  1065. EditorGUILayout.PropertyField(serializedObject.FindProperty("distanceScalingSettings"));
  1066. EditorGUILayout.EndHorizontal();
  1067. GUI.enabled = true;
  1068. DNPEditorInternal.Lines();
  1069. SerializedProperty scaleWithFOV = serializedObject.FindProperty("scaleWithFov");
  1070. EditorGUILayout.PropertyField(scaleWithFOV);
  1071. if (scaleWithFOV.boolValue || scaleWithFOV.hasMultipleDifferentValues)
  1072. {
  1073. EditorGUILayout.PropertyField(serializedObject.FindProperty("defaultFov"));
  1074. EditorGUILayout.PropertyField(serializedObject.FindProperty("fovCamera"));
  1075. bool noFovCameraOverride = true;
  1076. foreach (DamageNumber dn in DNPEditorInternal.damageNumbers)
  1077. {
  1078. if (dn.fovCamera != null)
  1079. {
  1080. noFovCameraOverride = false;
  1081. break;
  1082. }
  1083. }
  1084. if (noFovCameraOverride)
  1085. {
  1086. string overlayString = "Main Camera";
  1087. if (DNPEditorInternal.currentWidth < 404)
  1088. {
  1089. overlayString = "<size=11>Main Camera</size>";
  1090. if (DNPEditorInternal.currentWidth < 389)
  1091. {
  1092. overlayString = "";
  1093. }
  1094. }
  1095. if (DNPEditorInternal.currentWidth > 293)
  1096. {
  1097. PropertyOverlay(DNPEditorInternal.CheckmarkString(true) + " " + overlayString + " ");
  1098. }
  1099. }
  1100. else
  1101. {
  1102. GUI.color = new Color(1, 1, 1, 0.7f);
  1103. DNPEditorInternal.ScalingLabel("Only required if your <b>main camera</b> is not the FOV camera.", 362);
  1104. GUI.color = Color.white;
  1105. }
  1106. }
  1107. DNPEditorInternal.Lines();
  1108. EditorGUILayout.PropertyField(serializedObject.FindProperty("cameraOverride"));
  1109. bool noCameraOverride = true;
  1110. foreach(DamageNumber dn in DNPEditorInternal.damageNumbers)
  1111. {
  1112. if(dn.cameraOverride != null)
  1113. {
  1114. noCameraOverride = false;
  1115. break;
  1116. }
  1117. }
  1118. if(noCameraOverride)
  1119. {
  1120. string overlayString = "Main Camera";
  1121. if (DNPEditorInternal.currentWidth < 404)
  1122. {
  1123. overlayString = "<size=11>Main Camera</size>";
  1124. if(DNPEditorInternal.currentWidth < 389)
  1125. {
  1126. overlayString = "";
  1127. }
  1128. }
  1129. if(DNPEditorInternal.currentWidth > 293)
  1130. {
  1131. PropertyOverlay(DNPEditorInternal.CheckmarkString(true) + " " + overlayString + " ");
  1132. }
  1133. }
  1134. else
  1135. {
  1136. GUI.color = new Color(1, 1, 1, 0.7f);
  1137. DNPEditorInternal.ScalingLabel("Only required if your <b>main camera</b> is not the target camera.", 362);
  1138. GUI.color = Color.white;
  1139. }
  1140. break;
  1141. // Text Content
  1142. case ("Number"):
  1143. EditorGUILayout.PropertyField(serializedObject.FindProperty("number"));
  1144. EditorGUILayout.BeginHorizontal();
  1145. EditorGUILayout.LabelField("", GUILayout.Width(9));
  1146. EditorGUILayout.PropertyField(serializedObject.FindProperty("numberSettings"));
  1147. EditorGUILayout.EndHorizontal();
  1148. EditorGUILayout.BeginHorizontal();
  1149. EditorGUILayout.LabelField("", GUILayout.Width(9));
  1150. EditorGUILayout.PropertyField(serializedObject.FindProperty("digitSettings"));
  1151. EditorGUILayout.EndHorizontal();
  1152. break;
  1153. case ("Left Text"):
  1154. HandleTextProperty(serializedObject.FindProperty("leftText"));
  1155. EditorGUILayout.BeginHorizontal();
  1156. EditorGUILayout.LabelField("", GUILayout.Width(9));
  1157. EditorGUILayout.PropertyField(serializedObject.FindProperty("leftTextSettings"));
  1158. EditorGUILayout.EndHorizontal();
  1159. break;
  1160. case ("Right Text"):
  1161. HandleTextProperty(serializedObject.FindProperty("rightText"));
  1162. EditorGUILayout.BeginHorizontal();
  1163. EditorGUILayout.LabelField("", GUILayout.Width(9));
  1164. EditorGUILayout.PropertyField(serializedObject.FindProperty("rightTextSettings"));
  1165. EditorGUILayout.EndHorizontal();
  1166. break;
  1167. case ("Top Text"):
  1168. HandleTextProperty(serializedObject.FindProperty("topText"));
  1169. EditorGUILayout.BeginHorizontal();
  1170. EditorGUILayout.LabelField("", GUILayout.Width(9));
  1171. EditorGUILayout.PropertyField(serializedObject.FindProperty("topTextSettings"));
  1172. EditorGUILayout.EndHorizontal();
  1173. break;
  1174. case ("Bottom Text"):
  1175. HandleTextProperty(serializedObject.FindProperty("bottomText"));
  1176. EditorGUILayout.BeginHorizontal();
  1177. EditorGUILayout.LabelField("", GUILayout.Width(9));
  1178. EditorGUILayout.PropertyField(serializedObject.FindProperty("bottomTextSettings"));
  1179. EditorGUILayout.EndHorizontal();
  1180. break;
  1181. case ("Color By Number"):
  1182. EditorGUILayout.BeginHorizontal();
  1183. EditorGUILayout.LabelField("", GUILayout.Width(9));
  1184. EditorGUILayout.PropertyField(serializedObject.FindProperty("colorByNumberSettings"));
  1185. EditorGUILayout.EndHorizontal();
  1186. break;
  1187. // Movement
  1188. case ("Lerp"):
  1189. EditorGUILayout.BeginHorizontal();
  1190. EditorGUILayout.LabelField("", GUILayout.Width(9));
  1191. EditorGUILayout.PropertyField(serializedObject.FindProperty("lerpSettings"));
  1192. EditorGUILayout.EndHorizontal();
  1193. break;
  1194. case ("Velocity"):
  1195. EditorGUILayout.BeginHorizontal();
  1196. EditorGUILayout.LabelField("", GUILayout.Width(9));
  1197. EditorGUILayout.PropertyField(serializedObject.FindProperty("velocitySettings"));
  1198. EditorGUILayout.EndHorizontal();
  1199. break;
  1200. case ("Shaking"):
  1201. EditorGUILayout.BeginHorizontal();
  1202. EditorGUILayout.LabelField("", GUILayout.Width(9));
  1203. EditorGUILayout.PropertyField(serializedObject.FindProperty("shakeSettings"));
  1204. EditorGUILayout.EndHorizontal();
  1205. break;
  1206. case ("Following"):
  1207. EditorGUILayout.PropertyField(serializedObject.FindProperty("followedTarget"));
  1208. EditorGUILayout.BeginHorizontal();
  1209. EditorGUILayout.LabelField("", GUILayout.Width(9));
  1210. EditorGUILayout.PropertyField(serializedObject.FindProperty("followSettings"));
  1211. EditorGUILayout.EndHorizontal();
  1212. break;
  1213. // Fade In
  1214. case ("Offset In"):
  1215. EditorGUILayout.PropertyField(serializedObject.FindProperty("offsetFadeIn"), new GUIContent("Offset"));
  1216. break;
  1217. case ("Scale In"):
  1218. EditorGUILayout.PropertyField(serializedObject.FindProperty("scaleFadeIn"), new GUIContent("Scale"));
  1219. break;
  1220. case ("Cross Scale In"):
  1221. EditorGUILayout.PropertyField(serializedObject.FindProperty("crossScaleFadeIn"), new GUIContent("Cross Scale"));
  1222. break;
  1223. case ("Shake In"):
  1224. EditorGUILayout.PropertyField(serializedObject.FindProperty("shakeOffsetFadeIn"), new GUIContent("Shake Offset"));
  1225. EditorGUILayout.PropertyField(serializedObject.FindProperty("shakeFrequencyFadeIn"), new GUIContent("Shake Frequency"));
  1226. break;
  1227. // Fade Out
  1228. case ("Offset Out"):
  1229. EditorGUILayout.PropertyField(serializedObject.FindProperty("offsetFadeOut"), new GUIContent("Offset"));
  1230. break;
  1231. case ("Scale Out"):
  1232. EditorGUILayout.PropertyField(serializedObject.FindProperty("scaleFadeOut"), new GUIContent("Scale"));
  1233. break;
  1234. case ("Cross Scale Out"):
  1235. EditorGUILayout.PropertyField(serializedObject.FindProperty("crossScaleFadeOut"), new GUIContent("Cross Scale"));
  1236. break;
  1237. case ("Shake Out"):
  1238. EditorGUILayout.PropertyField(serializedObject.FindProperty("shakeOffsetFadeOut"), new GUIContent("Shake Offset"));
  1239. EditorGUILayout.PropertyField(serializedObject.FindProperty("shakeFrequencyFadeOut"), new GUIContent("Shake Frequency"));
  1240. break;
  1241. // Rotation & Scale
  1242. case ("Start Rotation"):
  1243. EditorGUILayout.PropertyField(serializedObject.FindProperty("minRotation"));
  1244. EditorGUILayout.PropertyField(serializedObject.FindProperty("maxRotation"));
  1245. EditorGUILayout.PropertyField(serializedObject.FindProperty("rotationRandomFlip"), new GUIContent("Random Flip", "Randomly flips the Rotation.\nUseful for avoiding small rotations.\nSet Min and Max to a positive value."));
  1246. break;
  1247. case ("Rotate Over Time"):
  1248. EditorGUILayout.PropertyField(serializedObject.FindProperty("minRotationSpeed"));
  1249. EditorGUILayout.PropertyField(serializedObject.FindProperty("maxRotationSpeed"));
  1250. EditorGUILayout.PropertyField(serializedObject.FindProperty("rotationSpeedRandomFlip"), new GUIContent("Random Flip", "Randomly flips the Rotation Speed.\nUseful for avoiding small rotation speeds.\nSet Min and Max to a positive value."));
  1251. SerializedProperty rotateOverTimeProperty = serializedObject.FindProperty("rotateOverTime");
  1252. Color rotateOverTimeColor = Color.Lerp(Color.red, Color.green, rotateOverTimeProperty.animationCurveValue.Evaluate(1));
  1253. EditorGUILayout.CurveField(rotateOverTimeProperty, rotateOverTimeColor, new Rect(0, 0, 1, 1));
  1254. break;
  1255. case ("Scale By Number"):
  1256. EditorGUILayout.BeginHorizontal();
  1257. EditorGUILayout.LabelField("", GUILayout.Width(9));
  1258. EditorGUILayout.PropertyField(serializedObject.FindProperty("scaleByNumberSettings"));
  1259. EditorGUILayout.EndHorizontal();
  1260. break;
  1261. case ("Scale Over Time"):
  1262. SerializedProperty scaleOverTimeProperty = serializedObject.FindProperty("scaleOverTime");
  1263. Color scaleOverTimeColor = Color.Lerp(Color.red, Color.green, scaleOverTimeProperty.animationCurveValue.Evaluate(1));
  1264. EditorGUILayout.CurveField(scaleOverTimeProperty, scaleOverTimeColor, new Rect(0, 0, 1, 5f));
  1265. break;
  1266. case ("Orthographic Scaling"):
  1267. EditorGUILayout.PropertyField(serializedObject.FindProperty("defaultOrthographicSize"));
  1268. EditorGUILayout.PropertyField(serializedObject.FindProperty("maxOrthographicSize"));
  1269. EditorGUILayout.PropertyField(serializedObject.FindProperty("orthographicCamera"));
  1270. bool noOrthographicCameraOverride = true;
  1271. foreach (DamageNumber dn in DNPEditorInternal.damageNumbers)
  1272. {
  1273. if (dn.orthographicCamera != null)
  1274. {
  1275. noOrthographicCameraOverride = false;
  1276. break;
  1277. }
  1278. }
  1279. if (noOrthographicCameraOverride)
  1280. {
  1281. string overlayString = "Main Camera";
  1282. if (DNPEditorInternal.currentWidth < 404)
  1283. {
  1284. overlayString = "<size=11>Main Camera</size>";
  1285. if (DNPEditorInternal.currentWidth < 389)
  1286. {
  1287. overlayString = "";
  1288. }
  1289. }
  1290. if (DNPEditorInternal.currentWidth > 293)
  1291. {
  1292. PropertyOverlay(DNPEditorInternal.CheckmarkString(true) + " " + overlayString + " ");
  1293. }
  1294. }
  1295. else
  1296. {
  1297. GUI.color = new Color(1, 1, 1, 0.7f);
  1298. DNPEditorInternal.ScalingLabel("Only required if your <b>main camera</b> is not the orthographic camera.", 362);
  1299. GUI.color = Color.white;
  1300. }
  1301. break;
  1302. // Spam Control
  1303. case ("Combination"):
  1304. EditorGUILayout.BeginHorizontal();
  1305. EditorGUILayout.LabelField(" ", GUILayout.Width(9));
  1306. EditorGUILayout.PropertyField(serializedObject.FindProperty("combinationSettings"));
  1307. EditorGUILayout.EndHorizontal();
  1308. break;
  1309. case ("Destruction"):
  1310. EditorGUILayout.BeginHorizontal();
  1311. EditorGUILayout.LabelField(" ", GUILayout.Width(9));
  1312. EditorGUILayout.PropertyField(serializedObject.FindProperty("destructionSettings"));
  1313. EditorGUILayout.EndHorizontal();
  1314. break;
  1315. case ("Collision"):
  1316. EditorGUILayout.BeginHorizontal();
  1317. EditorGUILayout.LabelField(" ", GUILayout.Width(9));
  1318. EditorGUILayout.PropertyField(serializedObject.FindProperty("collisionSettings"));
  1319. EditorGUILayout.EndHorizontal();
  1320. break;
  1321. case ("Push"):
  1322. EditorGUILayout.BeginHorizontal();
  1323. EditorGUILayout.LabelField(" ", GUILayout.Width(9));
  1324. EditorGUILayout.PropertyField(serializedObject.FindProperty("pushSettings"));
  1325. EditorGUILayout.EndHorizontal();
  1326. break;
  1327. // Performance
  1328. case ("Pooling"):
  1329. EditorGUILayout.PropertyField(serializedObject.FindProperty("poolSize"));
  1330. EditorGUILayout.PropertyField(serializedObject.FindProperty("disableOnSceneLoad"));
  1331. break;
  1332. }
  1333. }
  1334. // Close Box
  1335. DNPEditorInternal.CloseBox(showProperties);
  1336. }
  1337. void HandleTextProperty(SerializedProperty textField)
  1338. {
  1339. EditorGUI.BeginChangeCheck();
  1340. EditorGUILayout.BeginHorizontal();
  1341. EditorGUILayout.PropertyField(textField);
  1342. if (textField.stringValue.Length > 5)
  1343. {
  1344. char[] chars = textField.stringValue.ToCharArray();
  1345. bool unicodeCheck = false;
  1346. int unicodeIndex = 0;
  1347. for (int i = 0; i < chars.Length; i++)
  1348. {
  1349. char c = chars[i];
  1350. if (c == '\\')
  1351. {
  1352. // Check if there is a unicode sequence
  1353. unicodeCheck = true;
  1354. unicodeIndex = i;
  1355. }
  1356. else
  1357. {
  1358. if (unicodeCheck)
  1359. {
  1360. if (i == unicodeIndex + 1)
  1361. {
  1362. if (char.ToLower(c) != 'u')
  1363. {
  1364. unicodeCheck = false;
  1365. }
  1366. }
  1367. else if (i < unicodeIndex + 6)
  1368. {
  1369. int cInt = (int)c;
  1370. if (!char.IsNumber(c) && !(cInt > 96 && cInt < 103))
  1371. {
  1372. unicodeCheck = false;
  1373. }
  1374. }
  1375. }
  1376. }
  1377. }
  1378. if(unicodeCheck && unicodeIndex < chars.Length - 5)
  1379. {
  1380. if(GUILayout.Button("Unicode", GUILayout.Width(60)))
  1381. {
  1382. // Get hex code
  1383. string unicodeHex = "";
  1384. for (int i = unicodeIndex + 2; i < unicodeIndex + 6; i++)
  1385. {
  1386. unicodeHex += chars[i];
  1387. }
  1388. int hexCode = int.Parse(unicodeHex, System.Globalization.NumberStyles.HexNumber);
  1389. // Get unicode
  1390. string unicode = char.ConvertFromUtf32(hexCode);
  1391. // Combine
  1392. string newString = "";
  1393. for(int i = 0; i < unicodeIndex; i++)
  1394. {
  1395. newString += chars[i];
  1396. }
  1397. newString += unicode;
  1398. for (int i = unicodeIndex + 6; i < chars.Length; i++)
  1399. {
  1400. newString += chars[i];
  1401. }
  1402. // Assign
  1403. textField.stringValue = newString;
  1404. }
  1405. }
  1406. }
  1407. EditorGUILayout.EndHorizontal();
  1408. }
  1409. public static void ChangeShaderToOverlay(DamageNumber damageNumber)
  1410. {
  1411. damageNumber.GetReferencesIfNecessary();
  1412. Material[] materials = damageNumber.GetSharedMaterials();
  1413. if (materials != null)
  1414. {
  1415. foreach (Material mat in materials)
  1416. {
  1417. if (!mat.shader.name.EndsWith("verlay"))
  1418. {
  1419. Shader shader = Shader.Find(mat.shader.name + " Overlay");
  1420. if (shader == null)
  1421. {
  1422. shader = Shader.Find("TextMeshPro/Distance Field - Overlay");
  1423. }
  1424. if (shader == null)
  1425. {
  1426. shader = Shader.Find("TextMeshPro/Distance Field (Overlay)");
  1427. }
  1428. if (shader == null)
  1429. {
  1430. shader = Shader.Find("TextMeshPro/Distance Field Overlay");
  1431. }
  1432. mat.shader = shader;
  1433. damageNumber.renderThroughWalls = false;
  1434. }
  1435. }
  1436. }
  1437. }
  1438. bool FeatureButton(SerializedProperty property, string featureTitle)
  1439. {
  1440. // Get name for toggle button
  1441. string buttonName = property.hasMultipleDifferentValues ? "<b>− − −</b>" : (property.boolValue ? "<b> " + featureTitle + "</b>" : featureTitle);
  1442. bool toggled = GUILayout.Button(buttonName, DNPEditorInternal.buttonStyle, GUILayout.Width(140));
  1443. if (toggled)
  1444. {
  1445. // Record changes
  1446. List<Object> objectsList = new List<Object>();
  1447. foreach(Object targetObject in targets)
  1448. {
  1449. objectsList.Add(targetObject);
  1450. }
  1451. foreach (DamageNumber damageNumber in DNPEditorInternal.damageNumbers)
  1452. {
  1453. if(damageNumber != null)
  1454. {
  1455. damageNumber.GetReferencesIfNecessary();
  1456. foreach (TMP_Text tmpText in damageNumber.GetTextMeshs())
  1457. {
  1458. if(tmpText != null)
  1459. {
  1460. objectsList.Add(tmpText);
  1461. }
  1462. }
  1463. }
  1464. }
  1465. Object[] objectsArray = new Object[objectsList.Count];
  1466. for(int i = 0; i < objectsList.Count; i++)
  1467. {
  1468. objectsArray[i] = objectsList[i];
  1469. }
  1470. Undo.RecordObjects(objectsArray, "Toggled " + featureTitle);
  1471. // Toggle feature
  1472. property.boolValue = !property.boolValue;
  1473. // Avoid Conflicts
  1474. if(property.boolValue)
  1475. {
  1476. switch (property.name)
  1477. {
  1478. case ("enableDestruction"):
  1479. serializedObject.FindProperty("enableCombination").boolValue = false;
  1480. break;
  1481. case ("enableCombination"):
  1482. serializedObject.FindProperty("enableDestruction").boolValue = false;
  1483. break;
  1484. }
  1485. }
  1486. }
  1487. if (property.boolValue || property.hasMultipleDifferentValues)
  1488. {
  1489. GUI.color = new Color(1, 1, 1, 0.8f);
  1490. GUI.Toolbar(GUILayoutUtility.GetLastRect(), 0, new string[] { buttonName }, DNPEditorInternal.buttonStyle);
  1491. GUI.color = new Color(1, 1, 1, 1f);
  1492. return true;
  1493. }
  1494. return false;
  1495. }
  1496. void DisplayTextMain(bool isMesh)
  1497. {
  1498. EditorGUILayout.Space(2);
  1499. DNPEditorInternal.StartBox();
  1500. bool editingPrefabPreview = DNPEditorInternal.EditingPrefabPreview(target);
  1501. if (editingPrefabPreview)
  1502. {
  1503. GUI.enabled = false;
  1504. }
  1505. // Font
  1506. bool mixedFontAssets = false;
  1507. TMP_FontAsset fontAsset = null;
  1508. foreach (DamageNumber dn in DNPEditorInternal.damageNumbers)
  1509. {
  1510. dn.GetReferencesIfNecessary();
  1511. if(isMesh)
  1512. {
  1513. TMP_Text tmp = dn.GetTextMesh();
  1514. if (fontAsset != null && tmp.font != null && tmp.font != fontAsset)
  1515. {
  1516. mixedFontAssets = true;
  1517. }
  1518. else
  1519. {
  1520. fontAsset = tmp.font;
  1521. }
  1522. }
  1523. else
  1524. {
  1525. foreach (TMP_Text tmp in dn.GetTextMeshs())
  1526. {
  1527. if (fontAsset != null && tmp.font != null && tmp.font != fontAsset)
  1528. {
  1529. mixedFontAssets = true;
  1530. }
  1531. else
  1532. {
  1533. fontAsset = tmp.font;
  1534. }
  1535. }
  1536. }
  1537. }
  1538. EditorGUI.showMixedValue = mixedFontAssets;
  1539. EditorGUI.BeginChangeCheck();
  1540. TMP_FontAsset newFontAsset = (TMP_FontAsset) EditorGUILayout.ObjectField(new GUIContent("Font", "The font used by text mesh pro."), fontAsset, typeof(TMP_FontAsset), false);
  1541. if(EditorGUI.EndChangeCheck())
  1542. {
  1543. foreach (DamageNumber dn in DNPEditorInternal.damageNumbers)
  1544. {
  1545. Undo.RecordObjects(dn.GetTextMeshs(), "Changed font.");
  1546. foreach (TMP_Text tmp in dn.GetTextMeshs())
  1547. {
  1548. tmp.font = newFontAsset;
  1549. }
  1550. }
  1551. DNPEditorInternal.ResetMaterials();
  1552. }
  1553. EditorGUI.showMixedValue = false;
  1554. // Color
  1555. bool mixedColor = false;
  1556. Color vertexColor = Color.white;
  1557. bool firstColor = true;
  1558. foreach (DamageNumber dn in DNPEditorInternal.damageNumbers)
  1559. {
  1560. foreach (TMP_Text tmp in dn.GetTextMeshs())
  1561. {
  1562. if (firstColor)
  1563. {
  1564. firstColor = false;
  1565. vertexColor = tmp.color;
  1566. }
  1567. else
  1568. {
  1569. if (vertexColor != tmp.color)
  1570. {
  1571. mixedColor = true;
  1572. }
  1573. }
  1574. }
  1575. }
  1576. EditorGUI.showMixedValue = mixedColor;
  1577. EditorGUI.BeginChangeCheck();
  1578. Color newColor = EditorGUILayout.ColorField(new GUIContent("Color", "The vertex color used by text mesh pro."), vertexColor);
  1579. if (EditorGUI.EndChangeCheck())
  1580. {
  1581. foreach (DamageNumber dn in DNPEditorInternal.damageNumbers)
  1582. {
  1583. Undo.RecordObjects(dn.GetTextMeshs(), "Changed color.");
  1584. foreach (TMP_Text tmp in dn.GetTextMeshs())
  1585. {
  1586. tmp.color = newColor;
  1587. }
  1588. }
  1589. }
  1590. GUI.enabled = true;
  1591. // Info
  1592. DNPEditorInternal.Lines();
  1593. GUI.color = new Color(1, 1, 1, 0.7f);
  1594. if (editingPrefabPreview)
  1595. {
  1596. DNPEditorInternal.ScalingLabel("You need to <b>open</b> the <b>prefab</b> to access these settings.", 355);
  1597. DNPEditorInternal.OpenPrefabButton(target);
  1598. }
  1599. else
  1600. {
  1601. DNPEditorInternal.ScalingLabel("Check out the <b>TextMeshPro</b> component for more settings.", 355);
  1602. GUI.color = Color.white;
  1603. }
  1604. DNPEditorInternal.CloseBox();
  1605. }
  1606. void DisplayMainSettings()
  1607. {
  1608. EditorGUILayout.Space(2);
  1609. DNPEditorInternal.StartBox();
  1610. SerializedProperty permanentProperty = serializedObject.FindProperty("permanent");
  1611. GUI.enabled = !permanentProperty.boolValue || permanentProperty.hasMultipleDifferentValues;
  1612. EditorGUILayout.BeginHorizontal();
  1613. SerializedProperty lifetimeProperty = serializedObject.FindProperty("lifetime");
  1614. EditorGUILayout.PropertyField(lifetimeProperty);
  1615. bool notEnoughLifetime = false;
  1616. foreach(DamageNumber dn in DNPEditorInternal.damageNumbers)
  1617. {
  1618. if(dn.lifetime < dn.durationFadeIn)
  1619. {
  1620. notEnoughLifetime = true;
  1621. break;
  1622. }
  1623. }
  1624. if (notEnoughLifetime)
  1625. {
  1626. PropertyOverlay("<color=#FF0000BB>Not enough time to fade in.</color>");
  1627. }
  1628. else
  1629. {
  1630. TimePropertyOverlay(lifetimeProperty.floatValue);
  1631. }
  1632. ResetButton("Lifetime");
  1633. EditorGUILayout.EndHorizontal();
  1634. GUI.enabled = true;
  1635. EditorGUILayout.BeginHorizontal();
  1636. SerializedProperty timescaleProperty = serializedObject.FindProperty("unscaledTime");
  1637. EditorGUILayout.PropertyField(timescaleProperty);
  1638. ResetButton("UnscaledTime");
  1639. EditorGUILayout.EndHorizontal();
  1640. GUI.enabled = true;
  1641. EditorGUILayout.BeginHorizontal();
  1642. EditorGUILayout.PropertyField(permanentProperty);
  1643. ResetButton("Permanent");
  1644. EditorGUILayout.EndHorizontal();
  1645. // Information
  1646. DNPEditorInternal.Lines();
  1647. GUI.color = new Color(1, 1, 1, 0.7f);
  1648. if (permanentProperty.boolValue)
  1649. {
  1650. DNPEditorInternal.Label("- Will not <b>fade out</b> on it's own.");
  1651. }
  1652. else
  1653. {
  1654. DNPEditorInternal.Label("- Will <b>fade out</b> after <b>" + (Mathf.Round(lifetimeProperty.floatValue * 10) * 0.1f) + "</b> seconds.");
  1655. }
  1656. GUI.color = Color.white;
  1657. DNPEditorInternal.CloseBox();
  1658. }
  1659. void DisplayFadeMain(string inOrOut)
  1660. {
  1661. EditorGUILayout.Space(2);
  1662. DNPEditorInternal.StartBox();
  1663. EditorGUILayout.BeginHorizontal();
  1664. SerializedProperty serializedProperty = serializedObject.FindProperty("durationFade" + inOrOut);
  1665. EditorGUILayout.PropertyField(serializedProperty, new GUIContent("Duration", "The duration it takes to fade " + inOrOut.ToLower() + "."));
  1666. TimePropertyOverlay(serializedProperty.floatValue);
  1667. ResetButton("Fade " + inOrOut + " Main");
  1668. EditorGUILayout.EndHorizontal();
  1669. DNPEditorInternal.CloseBox();
  1670. }
  1671. void DisplaySpamControlMain(bool isMesh)
  1672. {
  1673. EditorGUILayout.Space(2);
  1674. // Check if Spam Group is required
  1675. bool requiresSpamGroup = false;
  1676. bool hasSpamGroup = false;
  1677. SerializedProperty serializedProperty = serializedObject.FindProperty("spamGroup");
  1678. SerializedProperty combinationProperty = serializedObject.FindProperty("enableCombination");
  1679. SerializedProperty destructionProperty = serializedObject.FindProperty("enableDestruction");
  1680. SerializedProperty collisionProperty = serializedObject.FindProperty("enableCollision");
  1681. SerializedProperty pushProperty = serializedObject.FindProperty("enablePush");
  1682. if (combinationProperty.boolValue || combinationProperty.hasMultipleDifferentValues)
  1683. {
  1684. requiresSpamGroup = true;
  1685. }
  1686. if (destructionProperty.boolValue || destructionProperty.hasMultipleDifferentValues)
  1687. {
  1688. requiresSpamGroup = true;
  1689. }
  1690. if (collisionProperty.boolValue || collisionProperty.hasMultipleDifferentValues)
  1691. {
  1692. requiresSpamGroup = true;
  1693. }
  1694. if (pushProperty.boolValue || pushProperty.hasMultipleDifferentValues)
  1695. {
  1696. requiresSpamGroup = true;
  1697. }
  1698. if (requiresSpamGroup && serializedProperty.stringValue.Replace(" ", "") != "")
  1699. {
  1700. requiresSpamGroup = false;
  1701. hasSpamGroup = true;
  1702. }
  1703. DNPEditorInternal.StartBox(requiresSpamGroup ? new Color(1, 1f, 0.8f) : Color.white);
  1704. EditorGUILayout.BeginHorizontal();
  1705. EditorGUILayout.PropertyField(serializedProperty);
  1706. if(requiresSpamGroup)
  1707. {
  1708. PropertyOverlay("<color=#FF0000BB>Required</color>");
  1709. }
  1710. ResetButton("Spam Control Main");
  1711. EditorGUILayout.EndHorizontal();
  1712. if (requiresSpamGroup)
  1713. {
  1714. DNPEditorInternal.Lines();
  1715. GUI.color = new Color(1, 1, 1, 0.7f);
  1716. DNPEditorInternal.ScalingLabel("This field is <b>required</b> by the features below.",272);
  1717. }
  1718. else if(hasSpamGroup)
  1719. {
  1720. DNPEditorInternal.Lines();
  1721. GUI.color = new Color(1, 1, 1, 0.7f);
  1722. if(isMesh)
  1723. {
  1724. DNPEditorInternal.ScalingLabel("Damage numbers within the same <b>group</b> interact with each other.", 395);
  1725. }
  1726. else
  1727. {
  1728. DNPEditorInternal.ScalingLabel("Damage numbers with the same <b>group</b> & <b>parent</b> interact with each other.", 440);
  1729. }
  1730. }
  1731. DNPEditorInternal.CloseBox(requiresSpamGroup ? new Color(1, 1f, 0.7f) : Color.white);
  1732. }
  1733. int TextPosition(int current)
  1734. {
  1735. // Change Position
  1736. EditorGUILayout.BeginHorizontal();
  1737. GUI.color = new Color(1, 1, 1, 0.7f);
  1738. GUI.color = Color.white;
  1739. int swapWith = GUILayout.Toolbar(current, new GUIContent[] { new GUIContent("←", "Move this text to the left."), new GUIContent("→", "Move this text to the right."), new GUIContent("↑", "Move this text to the top."), new GUIContent("↓", "Move this text to the bottom.") }, GUILayout.Width(DNPEditorInternal.currentWidth > 330 ? 90 : 0));
  1740. GUI.color = new Color(1, 1, 1, 0.7f);
  1741. GUILayout.Label(" | ", DNPEditorInternal.centerTextStyle, GUILayout.Width(10), GUILayout.Height(18));
  1742. GUI.color = Color.white;
  1743. EditorGUILayout.EndHorizontal();
  1744. return swapWith;
  1745. }
  1746. void DisplayPerformanceMain()
  1747. {
  1748. EditorGUILayout.Space(4);
  1749. // Delays
  1750. DNPEditorInternal.StartBox();
  1751. EditorGUILayout.BeginHorizontal();
  1752. DisplayDelay("updateDelay", "Update Delay", "The delay between updates.\nGreatly affects performance.");
  1753. ResetButton("Update Delay");
  1754. EditorGUILayout.EndHorizontal();
  1755. DNPEditorInternal.CloseBox();
  1756. }
  1757. void DisplayPerformanceHints()
  1758. {
  1759. EditorGUILayout.Space(4);
  1760. DNPEditorInternal.StartBox();
  1761. GUI.color = new Color(1, 1, 1, 0.7f);
  1762. DNPEditorInternal.Label("<b><size=13>Performance Hints:</size></b>");
  1763. EditorGUILayout.Space(5);
  1764. DNPEditorInternal.ScalingLabel("Always make sure to enable <b>Pooling</b>.", 1);
  1765. DNPEditorInternal.ScalingLabel("You can also decrease the <b>Update FPS</b>.", 261);
  1766. DNPEditorInternal.ScalingLabel("Enabling <b>Combination</b> and <b>Destruction</b> also boosts performance.", 398);
  1767. DNPEditorInternal.ScalingLabel("You can find those features in the <b>Spam Control</b> section.", 350);
  1768. GUI.color = Color.white;
  1769. DNPEditorInternal.CloseBox();
  1770. }
  1771. void DisplayMovementHints(bool isMesh)
  1772. {
  1773. if(!isMesh)
  1774. {
  1775. EditorGUILayout.Space(4);
  1776. DNPEditorInternal.StartBox();
  1777. GUI.color = new Color(1, 1, 1, 0.7f);
  1778. DNPEditorInternal.Label("<b><size=13>GUI Hints:</size></b>");
  1779. EditorGUILayout.Space(5);
  1780. DNPEditorInternal.ScalingLabel("The <b>GUI</b> version handles movement in <b>anchored</b> position.", 363);
  1781. DNPEditorInternal.ScalingLabel("An <b>offset</b> or <b>velocity</b> of <b>1</b> equals <b>100</b> in <b>anchored</b> space.",352f);
  1782. DNPEditorInternal.ScalingLabel("This <b>x100</b> conversion is for keeping values <b>small</b> and <b>consistent</b>.",399f);
  1783. GUI.color = Color.white;
  1784. DNPEditorInternal.CloseBox();
  1785. }
  1786. }
  1787. void DisplaySpamControlHints(bool isMesh)
  1788. {
  1789. if (!isMesh)
  1790. {
  1791. EditorGUILayout.Space(4);
  1792. DNPEditorInternal.StartBox();
  1793. GUI.color = new Color(1, 1, 1, 0.7f);
  1794. DNPEditorInternal.Label("<b><size=13>GUI Hints:</size></b>");
  1795. EditorGUILayout.Space(5);
  1796. DNPEditorInternal.ScalingLabel("The <b>GUI</b> version handles everything in <b>anchored</b> position.", 363);
  1797. DNPEditorInternal.ScalingLabel("A <b>distance</b> or <b>radius</b> of <b>1</b> equals <b>100</b> in <b>anchored</b> space.", 358f);
  1798. DNPEditorInternal.ScalingLabel("This <b>x100</b> conversion is for keeping values <b>small</b> and <b>consistent</b>.", 399f);
  1799. GUI.color = Color.white;
  1800. DNPEditorInternal.CloseBox();
  1801. }
  1802. }
  1803. void DisplayDelay(string propertyName, string displayName, string displayTooltip)
  1804. {
  1805. // Property
  1806. SerializedProperty property = serializedObject.FindProperty(propertyName);
  1807. // Delay
  1808. EditorGUILayout.BeginHorizontal();
  1809. EditorGUILayout.PropertyField(property, new GUIContent(displayName, displayTooltip));
  1810. // Delay Overlay
  1811. string overlayContent;
  1812. if (property.hasMultipleDifferentValues)
  1813. {
  1814. overlayContent = "";
  1815. }
  1816. else
  1817. {
  1818. if (property.floatValue > 0)
  1819. {
  1820. if(DNPEditorInternal.currentWidth < 400f)
  1821. {
  1822. overlayContent = "s";
  1823. }
  1824. else
  1825. {
  1826. overlayContent = "Delay";
  1827. }
  1828. }
  1829. else
  1830. {
  1831. overlayContent = "No Delay";
  1832. }
  1833. }
  1834. PropertyOverlay(overlayContent);
  1835. GUI.color = new Color(1, 1, 1, 0.5f);
  1836. EditorGUILayout.LabelField("➜", DNPEditorInternal.centerTextStyle, GUILayout.Width(DNPEditorInternal.currentWidth > 334 ? 15 : 0));
  1837. GUI.color = Color.white;
  1838. if (property.hasMultipleDifferentValues)
  1839. {
  1840. GUI.enabled = false;
  1841. GUILayout.TextField(" - - - ", GUILayout.Width(100));
  1842. GUI.enabled = true;
  1843. }
  1844. else
  1845. {
  1846. if(property.floatValue > 0.10001f)
  1847. {
  1848. GUI.color = new Color(1f, 1f, 0.7f, 1f);
  1849. }
  1850. int currentFPS = property.floatValue > 0 ? Mathf.RoundToInt(1f / property.floatValue) : 0;
  1851. int fpsWidth = 90;
  1852. if(DNPEditorInternal.currentWidth < 400)
  1853. {
  1854. fpsWidth = (int) Mathf.Clamp(DNPEditorInternal.currentWidth - 300,50,90);
  1855. }
  1856. int newFPS = EditorGUILayout.IntField(currentFPS, GUILayout.Width(DNPEditorInternal.currentWidth > 294 ? fpsWidth : 0));
  1857. if (currentFPS != newFPS)
  1858. {
  1859. if (newFPS > 0)
  1860. {
  1861. property.floatValue = Mathf.Round(100000f / (float)newFPS) * 0.00001f;
  1862. }
  1863. else if (newFPS <= 0)
  1864. {
  1865. property.floatValue = 0f;
  1866. }
  1867. }
  1868. }
  1869. EditorGUILayout.EndHorizontal();
  1870. // FPS Overlay
  1871. GUI.color = new Color(1, 1, 1, 0.7f);
  1872. if(property.hasMultipleDifferentValues)
  1873. {
  1874. overlayContent = "";
  1875. }
  1876. else
  1877. {
  1878. if(property.floatValue > 0)
  1879. {
  1880. overlayContent = "FPS";
  1881. }
  1882. else
  1883. {
  1884. if(DNPEditorInternal.currentWidth < 400)
  1885. {
  1886. overlayContent = "";
  1887. }
  1888. else
  1889. {
  1890. overlayContent = "Every Frame";
  1891. }
  1892. }
  1893. }
  1894. PropertyOverlay(DNPEditorInternal.currentWidth > 310 ? overlayContent : "");
  1895. }
  1896. void ResetButton(string category)
  1897. {
  1898. GUIContent resetButton = new GUIContent();
  1899. resetButton.text = "R";
  1900. resetButton.tooltip = "Reset this feature.";
  1901. if (GUILayout.Button(resetButton, GUILayout.Width(21)))
  1902. {
  1903. EditorGUIUtility.keyboardControl = EditorGUIUtility.hotControl = 0;
  1904. ResetCategory(category);
  1905. }
  1906. }
  1907. void ResetCategory(string category)
  1908. {
  1909. Undo.RecordObject(target, "Reset " + category + " settings.");
  1910. foreach (DamageNumber dn in DNPEditorInternal.damageNumbers)
  1911. {
  1912. // Reset Feature
  1913. switch (category)
  1914. {
  1915. // Main
  1916. case ("Lifetime"):
  1917. dn.lifetime = 2f;
  1918. break;
  1919. case ("Permanent"):
  1920. dn.permanent = false;
  1921. break;
  1922. case ("UnscaledTime"):
  1923. dn.unscaledTime = false;
  1924. break;
  1925. case ("3D Game"):
  1926. dn.faceCameraView = true;
  1927. dn.renderThroughWalls = true;
  1928. dn.consistentScreenSize = false;
  1929. dn.distanceScalingSettings = new DistanceScalingSettings(0);
  1930. dn.cameraOverride = null;
  1931. break;
  1932. // Text Content
  1933. case ("Number"):
  1934. dn.number = 1;
  1935. dn.numberSettings = new TextSettings(0);
  1936. dn.digitSettings = new DigitSettings(0);
  1937. break;
  1938. case ("Left Text"):
  1939. dn.leftText = "";
  1940. dn.leftTextSettings = new TextSettings(0f);
  1941. break;
  1942. case ("Right Text"):
  1943. dn.rightText = "";
  1944. dn.rightTextSettings = new TextSettings(0f);
  1945. break;
  1946. case ("Top Text"):
  1947. dn.topText = "";
  1948. dn.topTextSettings = new TextSettings(0f);
  1949. break;
  1950. case ("Bottom Text"):
  1951. dn.bottomText = "";
  1952. dn.bottomTextSettings = new TextSettings(0f);
  1953. break;
  1954. case ("Color By Number"):
  1955. dn.colorByNumberSettings = new ColorByNumberSettings(0f);
  1956. break;
  1957. // Movement
  1958. case ("Lerp"):
  1959. dn.lerpSettings = new LerpSettings(0);
  1960. break;
  1961. case ("Velocity"):
  1962. dn.velocitySettings = new VelocitySettings(0);
  1963. break;
  1964. case ("Shaking"):
  1965. dn.shakeSettings = new ShakeSettings(new Vector2(0.005f, 0.005f));
  1966. break;
  1967. case ("Following"):
  1968. dn.followedTarget = null;
  1969. dn.followSettings = new FollowSettings(0);
  1970. break;
  1971. // Fade In
  1972. case ("Fade In Main"):
  1973. dn.durationFadeIn = 0.2f;
  1974. break;
  1975. case ("Offset In"):
  1976. dn.offsetFadeIn = new Vector2(0.5f, 0);
  1977. break;
  1978. case ("Scale In"):
  1979. dn.scaleFadeIn = new Vector2(2f, 2f);
  1980. break;
  1981. case ("Shake In"):
  1982. dn.shakeOffsetFadeIn = new Vector2(0f, 1.5f);
  1983. dn.shakeFrequencyFadeIn = 4f;
  1984. break;
  1985. case ("Cross Scale In"):
  1986. dn.crossScaleFadeIn = new Vector2(1f, 1.5f);
  1987. break;
  1988. // Fade Out
  1989. case ("Fade Out Main"):
  1990. dn.durationFadeOut = 0.2f;
  1991. break;
  1992. case ("Offset Out"):
  1993. dn.enableOffsetFadeOut = true;
  1994. dn.offsetFadeOut = new Vector2(0.5f, 0);
  1995. break;
  1996. case ("Scale Out"):
  1997. dn.scaleFadeOut = new Vector2(2f, 2f);
  1998. break;
  1999. case ("Shake Out"):
  2000. dn.shakeOffsetFadeOut = new Vector2(0f, 1.5f);
  2001. dn.shakeFrequencyFadeOut = 4f;
  2002. break;
  2003. case ("Cross Scale Out"):
  2004. dn.crossScaleFadeOut = new Vector2(1f, 1.5f);
  2005. break;
  2006. // Rotation & Scale
  2007. case ("Start Rotation"):
  2008. dn.minRotation = -4;
  2009. dn.maxRotation = 4;
  2010. break;
  2011. case ("Rotate Over Time"):
  2012. dn.minRotationSpeed = -15f;
  2013. dn.maxRotationSpeed = 15;
  2014. dn.rotateOverTime = new AnimationCurve(new Keyframe[] { new Keyframe(0, 1), new Keyframe(0.4f, 1), new Keyframe(0.8f, 0), new Keyframe(1, 0) });
  2015. break;
  2016. case ("Scale By Number"):
  2017. dn.scaleByNumberSettings = new ScaleByNumberSettings(0);
  2018. break;
  2019. case ("Scale Over Time"):
  2020. dn.scaleOverTime = new AnimationCurve(new Keyframe(0, 1), new Keyframe(1, 0.7f));
  2021. break;
  2022. case ("Orthographic Scaling"):
  2023. dn.defaultOrthographicSize = 5f;
  2024. dn.maxOrthographicSize = 1.5f;
  2025. dn.orthographicCamera = null;
  2026. break;
  2027. // Spam Control
  2028. case ("Spam Control Main"):
  2029. dn.spamGroup = "";
  2030. break;
  2031. case ("Combination"):
  2032. dn.combinationSettings = new CombinationSettings(0);
  2033. break;
  2034. case ("Destruction"):
  2035. dn.destructionSettings = new DestructionSettings(0);
  2036. break;
  2037. case ("Collision"):
  2038. dn.collisionSettings = new CollisionSettings(0);
  2039. break;
  2040. case ("Push"):
  2041. dn.pushSettings = new PushSettings(0);
  2042. break;
  2043. // Performance
  2044. case ("Pooling"):
  2045. dn.poolSize = 50;
  2046. break;
  2047. case ("Update Delay"):
  2048. dn.updateDelay = 0.0125f;
  2049. break;
  2050. }
  2051. }
  2052. }
  2053. void TimePropertyOverlay(float seconds, string zeroString = "Instantly")
  2054. {
  2055. if(seconds > 0)
  2056. {
  2057. PropertyOverlay("Seconds");
  2058. }
  2059. else
  2060. {
  2061. PropertyOverlay(zeroString);
  2062. }
  2063. }
  2064. void PropertyOverlay(string text)
  2065. {
  2066. GUI.color = new Color(1, 1, 1, 0.7f);
  2067. GUI.Label(GUILayoutUtility.GetLastRect(), text + " ", DNPEditorInternal.rightTextStyle);
  2068. GUI.color = Color.white;
  2069. }
  2070. #endregion
  2071. }
  2072. }
  2073. #endif