No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TMP_BaseHDRPUnlitShaderGUI.cs 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. #if HDRP_10_7_OR_NEWER
  2. using UnityEngine;
  3. using UnityEditor;
  4. using UnityEditor.Rendering.HighDefinition;
  5. namespace TMPro.EditorUtilities
  6. {
  7. /// <summary>Base class for TextMesh Pro shader GUIs.</summary>
  8. #if HDRP_11_OR_NEWER
  9. internal abstract class TMP_BaseHDRPUnlitShaderGUI : UnlitShaderGraphGUI
  10. #else
  11. internal abstract class TMP_BaseHDRPUnlitShaderGUI : HDUnlitGUI
  12. #endif
  13. {
  14. /// <summary>Representation of a #pragma shader_feature.</summary>
  15. /// <description>It is assumed that the first feature option is for no keyword (underscores).</description>
  16. protected class ShaderFeature
  17. {
  18. public string undoLabel;
  19. public GUIContent label;
  20. /// <summary>The keyword labels, for display. Include the no-keyword as the first option.</summary>
  21. public GUIContent[] keywordLabels;
  22. /// <summary>The shader keywords. Exclude the no-keyword option.</summary>
  23. public string[] keywords;
  24. int m_State;
  25. public bool Active
  26. {
  27. get { return m_State >= 0; }
  28. }
  29. public int State
  30. {
  31. get { return m_State; }
  32. }
  33. public void ReadState(Material material)
  34. {
  35. for (int i = 0; i < keywords.Length; i++)
  36. {
  37. if (material.IsKeywordEnabled(keywords[i]))
  38. {
  39. m_State = i;
  40. return;
  41. }
  42. }
  43. m_State = -1;
  44. }
  45. public void SetActive(bool active, Material material)
  46. {
  47. m_State = active ? 0 : -1;
  48. SetStateKeywords(material);
  49. }
  50. public void DoPopup(MaterialEditor editor, Material material)
  51. {
  52. EditorGUI.BeginChangeCheck();
  53. int selection = EditorGUILayout.Popup(label, m_State + 1, keywordLabels);
  54. if (EditorGUI.EndChangeCheck())
  55. {
  56. m_State = selection - 1;
  57. editor.RegisterPropertyChangeUndo(undoLabel);
  58. SetStateKeywords(material);
  59. }
  60. }
  61. void SetStateKeywords(Material material)
  62. {
  63. for (int i = 0; i < keywords.Length; i++)
  64. {
  65. if (i == m_State)
  66. {
  67. material.EnableKeyword(keywords[i]);
  68. }
  69. else
  70. {
  71. material.DisableKeyword(keywords[i]);
  72. }
  73. }
  74. }
  75. }
  76. static GUIContent s_TempLabel = new GUIContent();
  77. protected static bool s_DebugExtended;
  78. static int s_UndoRedoCount, s_LastSeenUndoRedoCount;
  79. static float[][] s_TempFloats =
  80. {
  81. null, new float[1], new float[2], new float[3], new float[4]
  82. };
  83. protected static GUIContent[] s_XywhVectorLabels =
  84. {
  85. new GUIContent("X"),
  86. new GUIContent("Y"),
  87. new GUIContent("W", "Width"),
  88. new GUIContent("H", "Height")
  89. };
  90. protected static GUIContent[] s_LbrtVectorLabels =
  91. {
  92. new GUIContent("L", "Left"),
  93. new GUIContent("B", "Bottom"),
  94. new GUIContent("R", "Right"),
  95. new GUIContent("T", "Top")
  96. };
  97. protected static GUIContent[] s_CullingTypeLabels =
  98. {
  99. new GUIContent("Off"),
  100. new GUIContent("Front"),
  101. new GUIContent("Back")
  102. };
  103. static TMP_BaseHDRPUnlitShaderGUI()
  104. {
  105. // Keep track of how many undo/redo events happened.
  106. Undo.undoRedoPerformed += () => s_UndoRedoCount += 1;
  107. }
  108. bool m_IsNewGUI = true;
  109. float m_DragAndDropMinY;
  110. protected MaterialEditor m_Editor;
  111. protected Material m_Material;
  112. protected MaterialProperty[] m_Properties;
  113. void PrepareGUI()
  114. {
  115. m_IsNewGUI = false;
  116. ShaderUtilities.GetShaderPropertyIDs();
  117. // New GUI just got constructed. This happens in response to a selection,
  118. // but also after undo/redo events.
  119. if (s_LastSeenUndoRedoCount != s_UndoRedoCount)
  120. {
  121. // There's been at least one undo/redo since the last time this GUI got constructed.
  122. // Maybe the undo/redo was for this material? Assume that is was.
  123. TMPro_EventManager.ON_MATERIAL_PROPERTY_CHANGED(true, m_Material as Material);
  124. }
  125. s_LastSeenUndoRedoCount = s_UndoRedoCount;
  126. }
  127. protected override void OnMaterialGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
  128. {
  129. m_Editor = materialEditor;
  130. m_Material = materialEditor.target as Material;
  131. this.m_Properties = properties;
  132. if (m_IsNewGUI)
  133. {
  134. PrepareGUI();
  135. }
  136. DoDragAndDropBegin();
  137. EditorGUI.BeginChangeCheck();
  138. DoGUI();
  139. if (EditorGUI.EndChangeCheck())
  140. {
  141. TMPro_EventManager.ON_MATERIAL_PROPERTY_CHANGED(true, m_Material);
  142. }
  143. DoDragAndDropEnd();
  144. }
  145. /// <summary>Override this method to create the specific shader GUI.</summary>
  146. protected abstract void DoGUI();
  147. static string[] s_PanelStateLabel = new string[] { "\t- <i>Click to collapse</i> -", "\t- <i>Click to expand</i> -" };
  148. protected bool BeginPanel(string panel, bool expanded)
  149. {
  150. EditorGUI.indentLevel = 0;
  151. EditorGUILayout.BeginVertical(EditorStyles.helpBox);
  152. Rect r = EditorGUI.IndentedRect(GUILayoutUtility.GetRect(20, 18));
  153. r.x += 20;
  154. r.width += 6;
  155. bool enabled = GUI.enabled;
  156. GUI.enabled = true;
  157. expanded = TMP_EditorUtility.EditorToggle(r, expanded, new GUIContent(panel), TMP_UIStyleManager.panelTitle);
  158. r.width -= 30;
  159. EditorGUI.LabelField(r, new GUIContent(expanded ? s_PanelStateLabel[0] : s_PanelStateLabel[1]), TMP_UIStyleManager.rightLabel);
  160. GUI.enabled = enabled;
  161. EditorGUI.indentLevel += 1;
  162. EditorGUI.BeginDisabledGroup(false);
  163. return expanded;
  164. }
  165. protected bool BeginPanel(string panel, ShaderFeature feature, bool expanded, bool readState = true)
  166. {
  167. EditorGUI.indentLevel = 0;
  168. if (readState)
  169. {
  170. feature.ReadState(m_Material);
  171. }
  172. EditorGUI.BeginChangeCheck();
  173. EditorGUILayout.BeginVertical(EditorStyles.helpBox);
  174. GUILayout.BeginHorizontal();
  175. Rect r = EditorGUI.IndentedRect(GUILayoutUtility.GetRect(20, 20, GUILayout.Width(20f)));
  176. bool active = EditorGUI.Toggle(r, feature.Active);
  177. if (EditorGUI.EndChangeCheck())
  178. {
  179. m_Editor.RegisterPropertyChangeUndo(feature.undoLabel);
  180. feature.SetActive(active, m_Material);
  181. }
  182. r = EditorGUI.IndentedRect(GUILayoutUtility.GetRect(20, 18));
  183. r.width += 6;
  184. bool enabled = GUI.enabled;
  185. GUI.enabled = true;
  186. expanded = TMP_EditorUtility.EditorToggle(r, expanded, new GUIContent(panel), TMP_UIStyleManager.panelTitle);
  187. r.width -= 10;
  188. EditorGUI.LabelField(r, new GUIContent(expanded ? s_PanelStateLabel[0] : s_PanelStateLabel[1]), TMP_UIStyleManager.rightLabel);
  189. GUI.enabled = enabled;
  190. GUILayout.EndHorizontal();
  191. EditorGUI.indentLevel += 1;
  192. EditorGUI.BeginDisabledGroup(!active);
  193. return expanded;
  194. }
  195. protected void EndPanel()
  196. {
  197. EditorGUI.EndDisabledGroup();
  198. EditorGUI.indentLevel -= 1;
  199. EditorGUILayout.EndVertical();
  200. }
  201. MaterialProperty BeginProperty(string name)
  202. {
  203. MaterialProperty property = FindProperty(name, m_Properties);
  204. EditorGUI.BeginChangeCheck();
  205. EditorGUI.showMixedValue = property.hasMixedValue;
  206. m_Editor.BeginAnimatedCheck(Rect.zero, property);
  207. return property;
  208. }
  209. bool EndProperty()
  210. {
  211. m_Editor.EndAnimatedCheck();
  212. EditorGUI.showMixedValue = false;
  213. return EditorGUI.EndChangeCheck();
  214. }
  215. protected void DoPopup(string name, string label, GUIContent[] options)
  216. {
  217. MaterialProperty property = BeginProperty(name);
  218. s_TempLabel.text = label;
  219. int index = EditorGUILayout.Popup(s_TempLabel, (int)property.floatValue, options);
  220. if (EndProperty())
  221. {
  222. property.floatValue = index;
  223. }
  224. }
  225. protected void DoCubeMap(string name, string label)
  226. {
  227. DoTexture(name, label, typeof(Cubemap));
  228. }
  229. protected void DoTexture2D(string name, string label, bool withTilingOffset = false, string[] speedNames = null)
  230. {
  231. DoTexture(name, label, typeof(Texture2D), withTilingOffset, speedNames);
  232. }
  233. void DoTexture(string name, string label, System.Type type, bool withTilingOffset = false, string[] speedNames = null)
  234. {
  235. float objFieldSize = 60f;
  236. bool smallLayout = EditorGUIUtility.currentViewWidth <= 440f && (withTilingOffset || speedNames != null);
  237. float controlHeight = smallLayout ? objFieldSize * 2 : objFieldSize;
  238. MaterialProperty property = FindProperty(name, m_Properties);
  239. m_Editor.BeginAnimatedCheck(Rect.zero, property);
  240. Rect rect = EditorGUILayout.GetControlRect(true, controlHeight);
  241. float totalWidth = rect.width;
  242. rect.width = EditorGUIUtility.labelWidth + objFieldSize;
  243. rect.height = objFieldSize;
  244. s_TempLabel.text = label;
  245. EditorGUI.BeginChangeCheck();
  246. Object tex = EditorGUI.ObjectField(rect, s_TempLabel, property.textureValue, type, false);
  247. if (EditorGUI.EndChangeCheck())
  248. {
  249. property.textureValue = tex as Texture;
  250. }
  251. float additionalHeight = controlHeight - objFieldSize;
  252. float xOffset = smallLayout ? rect.width - objFieldSize : rect.width;
  253. rect.y += additionalHeight;
  254. rect.x += xOffset;
  255. rect.width = totalWidth - xOffset;
  256. rect.height = EditorGUIUtility.singleLineHeight;
  257. if (withTilingOffset)
  258. {
  259. DoTilingOffset(rect, property);
  260. rect.y += (rect.height + 2f) * 2f;
  261. }
  262. m_Editor.EndAnimatedCheck();
  263. if (speedNames != null)
  264. {
  265. DoUVSpeed(rect, speedNames);
  266. }
  267. }
  268. void DoTilingOffset(Rect rect, MaterialProperty property)
  269. {
  270. float labelWidth = EditorGUIUtility.labelWidth;
  271. int indentLevel = EditorGUI.indentLevel;
  272. EditorGUI.indentLevel = 0;
  273. EditorGUIUtility.labelWidth = Mathf.Min(40f, rect.width * 0.40f);
  274. Vector4 vector = property.textureScaleAndOffset;
  275. bool changed = false;
  276. float[] values = s_TempFloats[2];
  277. s_TempLabel.text = "Tiling";
  278. Rect vectorRect = EditorGUI.PrefixLabel(rect, s_TempLabel);
  279. values[0] = vector.x;
  280. values[1] = vector.y;
  281. EditorGUI.BeginChangeCheck();
  282. EditorGUI.MultiFloatField(vectorRect, s_XywhVectorLabels, values);
  283. if (EditorGUI.EndChangeCheck())
  284. {
  285. vector.x = values[0];
  286. vector.y = values[1];
  287. changed = true;
  288. }
  289. rect.y += rect.height + 2f;
  290. s_TempLabel.text = "Offset";
  291. vectorRect = EditorGUI.PrefixLabel(rect, s_TempLabel);
  292. values[0] = vector.z;
  293. values[1] = vector.w;
  294. EditorGUI.BeginChangeCheck();
  295. EditorGUI.MultiFloatField(vectorRect, s_XywhVectorLabels, values);
  296. if (EditorGUI.EndChangeCheck())
  297. {
  298. vector.z = values[0];
  299. vector.w = values[1];
  300. changed = true;
  301. }
  302. if (changed)
  303. {
  304. property.textureScaleAndOffset = vector;
  305. }
  306. EditorGUIUtility.labelWidth = labelWidth;
  307. EditorGUI.indentLevel = indentLevel;
  308. }
  309. void DoUVSpeed(Rect rect, string[] names)
  310. {
  311. float labelWidth = EditorGUIUtility.labelWidth;
  312. int indentLevel = EditorGUI.indentLevel;
  313. EditorGUI.indentLevel = 0;
  314. EditorGUIUtility.labelWidth = Mathf.Min(40f, rect.width * 0.40f);
  315. s_TempLabel.text = "Speed";
  316. rect = EditorGUI.PrefixLabel(rect, s_TempLabel);
  317. EditorGUIUtility.labelWidth = 10f;
  318. rect.width = rect.width * 0.5f - 2f;
  319. if (names.Length == 1)
  320. {
  321. DoFloat2(rect, names[0]);
  322. }
  323. else
  324. {
  325. DoFloat(rect, names[0], "X");
  326. rect.x += rect.width + 4f;
  327. DoFloat(rect, names[1], "Y");
  328. }
  329. EditorGUIUtility.labelWidth = labelWidth;
  330. EditorGUI.indentLevel = indentLevel;
  331. }
  332. protected void DoToggle(string name, string label)
  333. {
  334. MaterialProperty property = BeginProperty(name);
  335. s_TempLabel.text = label;
  336. bool value = EditorGUILayout.Toggle(s_TempLabel, property.floatValue == 1f);
  337. if (EndProperty())
  338. {
  339. property.floatValue = value ? 1f : 0f;
  340. }
  341. }
  342. protected void DoFloat(string name, string label)
  343. {
  344. MaterialProperty property = BeginProperty(name);
  345. Rect rect = EditorGUILayout.GetControlRect();
  346. rect.width = EditorGUIUtility.labelWidth + 55f;
  347. s_TempLabel.text = label;
  348. float value = EditorGUI.FloatField(rect, s_TempLabel, property.floatValue);
  349. if (EndProperty())
  350. {
  351. property.floatValue = value;
  352. }
  353. }
  354. protected void DoColor(string name, string label)
  355. {
  356. MaterialProperty property = BeginProperty(name);
  357. s_TempLabel.text = label;
  358. Color value = EditorGUI.ColorField(EditorGUILayout.GetControlRect(), s_TempLabel, property.colorValue, false, true, true);
  359. if (EndProperty())
  360. {
  361. property.colorValue = value;
  362. }
  363. }
  364. void DoFloat(Rect rect, string name, string label)
  365. {
  366. MaterialProperty property = BeginProperty(name);
  367. s_TempLabel.text = label;
  368. float value = EditorGUI.FloatField(rect, s_TempLabel, property.floatValue);
  369. if (EndProperty())
  370. {
  371. property.floatValue = value;
  372. }
  373. }
  374. void DoFloat2(Rect rect, string name)
  375. {
  376. MaterialProperty property = BeginProperty(name);
  377. float x = EditorGUI.FloatField(rect, "X", property.vectorValue.x);
  378. rect.x += rect.width + 4f;
  379. float y = EditorGUI.FloatField(rect, "Y", property.vectorValue.y);
  380. if (EndProperty())
  381. {
  382. property.vectorValue = new Vector2(x, y);
  383. }
  384. }
  385. protected void DoOffset(string name, string label)
  386. {
  387. MaterialProperty property = BeginProperty(name);
  388. s_TempLabel.text = label;
  389. Vector2 value = EditorGUI.Vector2Field(EditorGUILayout.GetControlRect(), s_TempLabel, property.vectorValue);
  390. if (EndProperty())
  391. {
  392. property.vectorValue = value;
  393. }
  394. }
  395. protected void DoSlider(string name, string label)
  396. {
  397. MaterialProperty property = BeginProperty(name);
  398. Vector2 range = property.rangeLimits;
  399. s_TempLabel.text = label;
  400. float value = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, property.floatValue, range.x, range.y);
  401. if (EndProperty())
  402. {
  403. property.floatValue = value;
  404. }
  405. }
  406. protected void DoSlider(string name, Vector2 range, string label)
  407. {
  408. MaterialProperty property = BeginProperty(name);
  409. s_TempLabel.text = label;
  410. float value = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, property.floatValue, range.x, range.y);
  411. if (EndProperty())
  412. {
  413. property.floatValue = value;
  414. }
  415. }
  416. protected void DoSlider(string propertyName, string propertyField, string label)
  417. {
  418. MaterialProperty property = BeginProperty(propertyName);
  419. Vector2 range = property.rangeLimits;
  420. s_TempLabel.text = label;
  421. Vector4 value = property.vectorValue;
  422. switch (propertyField)
  423. {
  424. case "X":
  425. value.x = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, value.x, range.x, range.y);
  426. break;
  427. case "Y":
  428. value.y = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, value.y, range.x, range.y);
  429. break;
  430. case "Z":
  431. value.z = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, value.z, range.x, range.y);
  432. break;
  433. case "W":
  434. value.w = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, value.w, range.x, range.y);
  435. break;
  436. }
  437. if (EndProperty())
  438. {
  439. property.vectorValue = value;
  440. }
  441. }
  442. protected void DoSlider(string propertyName, string propertyField, Vector2 range, string label)
  443. {
  444. MaterialProperty property = BeginProperty(propertyName);
  445. s_TempLabel.text = label;
  446. Vector4 value = property.vectorValue;
  447. switch (propertyField)
  448. {
  449. case "X":
  450. value.x = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, value.x, range.x, range.y);
  451. break;
  452. case "Y":
  453. value.y = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, value.y, range.x, range.y);
  454. break;
  455. case "Z":
  456. value.z = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, value.z, range.x, range.y);
  457. break;
  458. case "W":
  459. value.w = EditorGUI.Slider(EditorGUILayout.GetControlRect(), s_TempLabel, value.w, range.x, range.y);
  460. break;
  461. }
  462. if (EndProperty())
  463. {
  464. property.vectorValue = value;
  465. }
  466. }
  467. protected void DoVector2(string name, string label)
  468. {
  469. MaterialProperty property = BeginProperty(name);
  470. s_TempLabel.text = label;
  471. Vector4 value = EditorGUILayout.Vector3Field(s_TempLabel, property.vectorValue);
  472. if (EndProperty())
  473. {
  474. property.vectorValue = value;
  475. }
  476. }
  477. protected void DoVector3(string name, string label)
  478. {
  479. MaterialProperty property = BeginProperty(name);
  480. s_TempLabel.text = label;
  481. Vector4 value = EditorGUILayout.Vector3Field(s_TempLabel, property.vectorValue);
  482. if (EndProperty())
  483. {
  484. property.vectorValue = value;
  485. }
  486. }
  487. protected void DoVector(string name, string label, GUIContent[] subLabels)
  488. {
  489. MaterialProperty property = BeginProperty(name);
  490. Rect rect = EditorGUILayout.GetControlRect();
  491. s_TempLabel.text = label;
  492. rect = EditorGUI.PrefixLabel(rect, s_TempLabel);
  493. Vector4 vector = property.vectorValue;
  494. float[] values = s_TempFloats[subLabels.Length];
  495. for (int i = 0; i < subLabels.Length; i++)
  496. {
  497. values[i] = vector[i];
  498. }
  499. EditorGUI.MultiFloatField(rect, subLabels, values);
  500. if (EndProperty())
  501. {
  502. for (int i = 0; i < subLabels.Length; i++)
  503. {
  504. vector[i] = values[i];
  505. }
  506. property.vectorValue = vector;
  507. }
  508. }
  509. void DoDragAndDropBegin()
  510. {
  511. m_DragAndDropMinY = GUILayoutUtility.GetRect(0f, 0f, GUILayout.ExpandWidth(true)).y;
  512. }
  513. void DoDragAndDropEnd()
  514. {
  515. Rect rect = GUILayoutUtility.GetRect(0f, 0f, GUILayout.ExpandWidth(true));
  516. Event evt = Event.current;
  517. if (evt.type == EventType.DragUpdated)
  518. {
  519. DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
  520. evt.Use();
  521. }
  522. else if (
  523. evt.type == EventType.DragPerform &&
  524. Rect.MinMaxRect(rect.xMin, m_DragAndDropMinY, rect.xMax, rect.yMax).Contains(evt.mousePosition)
  525. )
  526. {
  527. DragAndDrop.AcceptDrag();
  528. evt.Use();
  529. Material droppedMaterial = DragAndDrop.objectReferences[0] as Material;
  530. if (droppedMaterial && droppedMaterial != m_Material)
  531. {
  532. PerformDrop(droppedMaterial);
  533. }
  534. }
  535. }
  536. void PerformDrop(Material droppedMaterial)
  537. {
  538. Texture droppedTex = droppedMaterial.GetTexture(ShaderUtilities.ID_MainTex);
  539. if (!droppedTex)
  540. {
  541. return;
  542. }
  543. Texture currentTex = m_Material.GetTexture(ShaderUtilities.ID_MainTex);
  544. TMP_FontAsset requiredFontAsset = null;
  545. if (droppedTex != currentTex)
  546. {
  547. requiredFontAsset = TMP_EditorUtility.FindMatchingFontAsset(droppedMaterial);
  548. if (!requiredFontAsset)
  549. {
  550. return;
  551. }
  552. }
  553. foreach (GameObject o in Selection.gameObjects)
  554. {
  555. if (requiredFontAsset)
  556. {
  557. TMP_Text textComponent = o.GetComponent<TMP_Text>();
  558. if (textComponent)
  559. {
  560. Undo.RecordObject(textComponent, "Font Asset Change");
  561. textComponent.font = requiredFontAsset;
  562. }
  563. }
  564. TMPro_EventManager.ON_DRAG_AND_DROP_MATERIAL_CHANGED(o, m_Material, droppedMaterial);
  565. EditorUtility.SetDirty(o);
  566. }
  567. }
  568. }
  569. }
  570. #endif