MaterialInspector.ts 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. //
  2. // Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. import ScriptWidget = require("ui/ScriptWidget");
  23. import UIEvents = require("ui/UIEvents");
  24. import EditorUI = require("ui/EditorUI");
  25. import EditorEvents = require("editor/EditorEvents");
  26. import TextureSelector = require("./TextureSelector");
  27. var techniqueSource = new Atomic.UIMenuItemSource();
  28. var solidSource = new Atomic.UIMenuItemSource();
  29. solidSource.addItem(new Atomic.UIMenuItem("Diffuse", "Diffuse"));
  30. solidSource.addItem(new Atomic.UIMenuItem("Diffuse Emissive", "Diffuse Emissive"));
  31. solidSource.addItem(new Atomic.UIMenuItem("Diffuse Normal", "Diffuse Normal"));
  32. solidSource.addItem(new Atomic.UIMenuItem("Diffuse Specular", "Diffuse Specular"));
  33. solidSource.addItem(new Atomic.UIMenuItem("Diffuse Normal Specular", "Diffuse Normal Specular"));
  34. solidSource.addItem(new Atomic.UIMenuItem("Diffuse Unlit", "Diffuse Unlit"));
  35. solidSource.addItem(new Atomic.UIMenuItem("No Texture", "No Texture"));
  36. var tranSource = new Atomic.UIMenuItemSource();
  37. tranSource.addItem(new Atomic.UIMenuItem("Alpha", "Alpha"));
  38. tranSource.addItem(new Atomic.UIMenuItem("Alpha Mask", "Alpha Mask"));
  39. tranSource.addItem(new Atomic.UIMenuItem("Additive", "Additive"));
  40. tranSource.addItem(new Atomic.UIMenuItem("Additive Alpha", "Additive Alpha"));
  41. tranSource.addItem(new Atomic.UIMenuItem("Emissive Alpha", "Emissive Alpha"));
  42. tranSource.addItem(new Atomic.UIMenuItem("Alpha AO", "Alpha AO"));
  43. tranSource.addItem(new Atomic.UIMenuItem("Alpha Mask AO", "Alpha Mask AO"));
  44. var lightmapSource = new Atomic.UIMenuItemSource();
  45. lightmapSource.addItem(new Atomic.UIMenuItem("Lightmap", "Lightmap"));
  46. lightmapSource.addItem(new Atomic.UIMenuItem("Lightmap Alpha", "Lightmap Alpha"));
  47. var projectSource = new Atomic.UIMenuItemSource();
  48. var _ = new Atomic.UIMenuItem();
  49. var techniqueLookup = {
  50. "Techniques/Diff.xml": "Diffuse",
  51. "Techniques/DiffEmissive.xml": "Diffuse Emissive",
  52. "Techniques/DiffNormal.xml": "Diffuse Normal",
  53. "Techniques/DiffSpec.xml": "Diffuse Specular",
  54. "Techniques/DiffNormalSpec.xml": "Diffuse Normal Specular",
  55. "Techniques/DiffUnlit.xml": "Diffuse Unlit",
  56. "Techniques/DiffAlpha.xml": "Alpha",
  57. "Techniques/DiffAlphaMask.xml": "Alpha Mask",
  58. "Techniques/DiffAdd.xml": "Additive",
  59. "Techniques/NoTexture.xml": "No Texture",
  60. "Techniques/DiffLightMap.xml": "Lightmap",
  61. "Techniques/DiffLightMapAlpha.xml": "Lightmap Alpha"
  62. };
  63. var techniqueReverseLookup = {};
  64. var projectTechniques = {};
  65. var projectTechniquesAddress = {};
  66. for (var key in techniqueLookup) {
  67. techniqueReverseLookup[techniqueLookup[key]] = key;
  68. }
  69. class MaterialInspector extends ScriptWidget {
  70. currentTexture: Atomic.UITextureWidget = null;
  71. tunit: number;
  72. textureWidget: Atomic.UITextureWidget;
  73. constructor() {
  74. super();
  75. this.fd.id = "Vera";
  76. this.fd.size = 11;
  77. this.subscribeToEvent(EditorEvents.RemoveCurrentAssetAssigned, (ev: EditorEvents.RemoveCurrentAssetAssignedEvent) => this.createTextureRemoveButtonCallback(this.tunit, this.textureWidget));
  78. this.subscribeToEvent("ResourceAdded", (ev: ToolCore.ResourceAddedEvent) => this.refreshTechniquesPopup());
  79. }
  80. createShaderParametersSection(): Atomic.UISection {
  81. var section = new Atomic.UISection();
  82. section.text = "Shader Paramaters";
  83. section.value = 1;
  84. section.fontDescription = this.fd;
  85. var attrsVerticalLayout = new Atomic.UILayout(Atomic.UI_AXIS_Y);
  86. attrsVerticalLayout.spacing = 3;
  87. attrsVerticalLayout.layoutPosition = Atomic.UI_LAYOUT_POSITION_LEFT_TOP;
  88. attrsVerticalLayout.layoutSize = Atomic.UI_LAYOUT_SIZE_AVAILABLE;
  89. section.contentRoot.addChild(attrsVerticalLayout);
  90. var params = this.material.getShaderParameters();
  91. for (var i in params) {
  92. var attrLayout = new Atomic.UILayout();
  93. attrLayout.layoutDistribution = Atomic.UI_LAYOUT_DISTRIBUTION_GRAVITY;
  94. var name = new Atomic.UITextField();
  95. name.textAlign = Atomic.UI_TEXT_ALIGN_LEFT;
  96. name.skinBg = "InspectorTextAttrName";
  97. name.text = params[i].name;
  98. name.fontDescription = this.fd;
  99. attrLayout.addChild(name);
  100. var field = new Atomic.UIEditField();
  101. field.textAlign = Atomic.UI_TEXT_ALIGN_LEFT;
  102. field.skinBg = "TBAttrEditorField";
  103. field.fontDescription = this.fd;
  104. var lp = new Atomic.UILayoutParams();
  105. lp.width = 140;
  106. field.layoutParams = lp;
  107. field.id = params[i].name;
  108. field.text = params[i].valueString;
  109. field.subscribeToEvent(field, "WidgetEvent", function (ev: Atomic.UIWidgetEvent) {
  110. if (ev.type == Atomic.UI_EVENT_TYPE_CHANGED) {
  111. var field = <Atomic.UIEditField>ev.target;
  112. this.material.setShaderParameter(field.id, field.text);
  113. }
  114. }.bind(this));
  115. attrLayout.addChild(field);
  116. attrsVerticalLayout.addChild(attrLayout);
  117. // print(params[i].name, " : ", params[i].value, " : ", params[i].type);
  118. }
  119. return section;
  120. }
  121. getTextureThumbnail(texture: Atomic.Texture): Atomic.Texture {
  122. if (!texture) return null;
  123. var db = ToolCore.getAssetDatabase();
  124. var asset = db.getAssetByPath(texture.name);
  125. if (!asset)
  126. return texture;
  127. var thumbnail = asset.cachePath + "_thumbnail.png";
  128. var cache = Atomic.getResourceCache();
  129. var thumb = <Atomic.Texture2D>cache.getTempResource("Texture2D", thumbnail);
  130. if (thumb)
  131. return thumb;
  132. return texture;
  133. }
  134. onTechniqueSet(techniqueName: string) {
  135. this.techniqueButton.text = techniqueName;
  136. var cache = Atomic.getResourceCache();
  137. var technique = <Atomic.Technique>cache.getResource("Technique", techniqueReverseLookup[techniqueName]);
  138. var resourcePath = ToolCore.toolSystem.project.getResourcePath();
  139. if (technique == null) {
  140. var techniquePath = "";
  141. for (var i in projectTechniques) {
  142. if (techniqueName == projectTechniques[i]) {
  143. techniquePath = projectTechniquesAddress[i];
  144. break;
  145. }
  146. }
  147. techniquePath = techniquePath.replace(resourcePath, "");
  148. technique = <Atomic.Technique>cache.getResource("Technique", techniquePath);
  149. }
  150. this.material.setTechnique(0, technique);
  151. }
  152. createTechniquePopup(): Atomic.UIWidget {
  153. this.refreshTechniquesPopup();
  154. var button = this.techniqueButton = new Atomic.UIButton();
  155. var technique = this.material.getTechnique(0);
  156. var techniqueName = "";
  157. if (technique != null) {
  158. techniqueName = technique.name.replace("Techniques/", "").replace(".xml", "");
  159. } else {
  160. techniqueName = "UNDEFINED";
  161. }
  162. button.text = techniqueName;
  163. button.fontDescription = this.fd;
  164. var lp = new Atomic.UILayoutParams();
  165. lp.width = 140;
  166. button.layoutParams = lp;
  167. button.onClick = function () {
  168. var menu = new Atomic.UIMenuWindow(button, "technique popup");
  169. menu.fontDescription = this.fd;
  170. menu.show(techniqueSource);
  171. button.subscribeToEvent(button, "WidgetEvent", function (ev: Atomic.UIWidgetEvent) {
  172. if (ev.type != Atomic.UI_EVENT_TYPE_CLICK)
  173. return;
  174. if (ev.target && ev.target.id == "technique popup") {
  175. this.onTechniqueSet(ev.refid);
  176. }
  177. }.bind(this));
  178. }.bind(this);
  179. return button;
  180. }
  181. acceptAssetDrag(importerTypeName: string, ev: Atomic.DragEndedEvent): ToolCore.AssetImporter {
  182. var dragObject = ev.dragObject;
  183. if (dragObject.object && dragObject.object.typeName == "Asset") {
  184. var asset = <ToolCore.Asset>dragObject.object;
  185. if (asset.importerTypeName == importerTypeName) {
  186. return asset.importer;
  187. }
  188. }
  189. return null;
  190. }
  191. openTextureSelectionBox(textureUnit: number, textureWidget: Atomic.UITextureWidget) {
  192. var inspector = this;
  193. EditorUI.getModelOps().showResourceSelection("Select Texture", "TextureImporter", "Texture2D", function (asset: ToolCore.Asset, args: any) {
  194. var texture = <Atomic.Texture2D>Atomic.cache.getResource("Texture2D", asset.path);
  195. if (texture) {
  196. inspector.material.setTexture(textureUnit, texture);
  197. textureWidget.texture = inspector.getTextureThumbnail(texture);
  198. this.sendEvent(EditorEvents.InspectorProjectReference, { "path": texture.getName() });
  199. }
  200. });
  201. }
  202. // Big Texture Button(referenced texture file path in project frame)
  203. createTextureButtonCallback(textureUnit: number, textureWidget: Atomic.UITextureWidget) {
  204. return () => {
  205. var texture = this.material.getTexture(textureUnit);
  206. if (textureWidget.getTexture() != null) {
  207. this.sendEvent(EditorEvents.InspectorProjectReference, { "path": texture.getName() });
  208. } else {
  209. this.openTextureSelectionBox(textureUnit, textureWidget);
  210. }
  211. return true;
  212. };
  213. }
  214. // Small Texture Button (Opens texture selection window)
  215. createTextureReferenceButtonCallback(textureUnit: number, textureWidget: Atomic.UITextureWidget) {
  216. return () => {
  217. this.tunit = textureUnit;
  218. this.textureWidget = textureWidget;
  219. this.openTextureSelectionBox(textureUnit, textureWidget);
  220. return true;
  221. };
  222. }
  223. //Remove Texture Button
  224. createTextureRemoveButtonCallback(textureUnit: number, textureWidget: Atomic.UITextureWidget) {
  225. var texture = this.material.getTexture(textureUnit);
  226. if (texture != null && textureWidget != null) {
  227. textureWidget.setTexture(null);
  228. }
  229. }
  230. createTextureSection(): Atomic.UISection {
  231. var section = new Atomic.UISection();
  232. section.text = "Textures";
  233. section.value = 1;
  234. section.fontDescription = this.fd;
  235. var attrsVerticalLayout = new Atomic.UILayout(Atomic.UI_AXIS_Y);
  236. attrsVerticalLayout.spacing = 3;
  237. attrsVerticalLayout.layoutPosition = Atomic.UI_LAYOUT_POSITION_LEFT_TOP;
  238. attrsVerticalLayout.layoutSize = Atomic.UI_LAYOUT_SIZE_AVAILABLE;
  239. section.contentRoot.addChild(attrsVerticalLayout);
  240. // TODO: Filter on technique
  241. var textureUnits = [Atomic.TU_DIFFUSE, Atomic.TU_NORMAL, Atomic.TU_SPECULAR, Atomic.TU_EMISSIVE];
  242. for (var i in textureUnits) {
  243. var tunit: Atomic.TextureUnit = textureUnits[i];
  244. var tunitName = Atomic.Material.getTextureUnitName(tunit);
  245. var attrLayout = new Atomic.UILayout();
  246. attrLayout.layoutDistribution = Atomic.UI_LAYOUT_DISTRIBUTION_GRAVITY;
  247. var name = new Atomic.UITextField();
  248. name.textAlign = Atomic.UI_TEXT_ALIGN_LEFT;
  249. name.skinBg = "InspectorTextAttrName";
  250. name.text = tunitName;
  251. name.fontDescription = this.fd;
  252. attrLayout.addChild(name);
  253. var textureWidget = new Atomic.UITextureWidget();
  254. var tlp = new Atomic.UILayoutParams();
  255. tlp.width = 64;
  256. tlp.height = 64;
  257. textureWidget.layoutParams = tlp;
  258. textureWidget.texture = this.getTextureThumbnail(this.material.getTexture(tunit));
  259. var textureButton = new Atomic.UIButton();
  260. textureButton.skinBg = "TBButton.flatoutline";
  261. textureButton["tunit"] = tunit;
  262. textureButton["textureWidget"] = textureWidget;
  263. //Create drop-down buttons to open Texture Selection Dialog Box
  264. var textureRefButton = new Atomic.UIButton();
  265. textureRefButton.skinBg = "arrow.down";
  266. textureRefButton["tunit"] = tunit;
  267. textureRefButton["textureWidget"] = textureWidget;
  268. textureButton.onClick = this.createTextureButtonCallback(tunit, textureWidget);
  269. textureRefButton.onClick = this.createTextureReferenceButtonCallback(tunit, textureWidget);
  270. textureButton.contentRoot.addChild(textureWidget);
  271. attrLayout.addChild(textureButton);
  272. attrLayout.addChild(textureRefButton);
  273. attrsVerticalLayout.addChild(attrLayout);
  274. // handle dropping of texture on widget
  275. textureButton.subscribeToEvent(textureButton, "DragEnded", (ev: Atomic.DragEndedEvent) => {
  276. var importer = this.acceptAssetDrag("TextureImporter", ev);
  277. if (importer) {
  278. var textureImporter = <ToolCore.TextureImporter>importer;
  279. var asset = textureImporter.asset;
  280. var texture = <Atomic.Texture2D>Atomic.cache.getResource("Texture2D", asset.path);
  281. if (texture) {
  282. this.material.setTexture(ev.target["tunit"], texture);
  283. (<Atomic.UITextureWidget>ev.target["textureWidget"]).texture = this.getTextureThumbnail(texture);
  284. this.sendEvent("InspectorProjectReference", { "path": texture.getName(), "ButtonID": texture.getName() });
  285. }
  286. }
  287. });
  288. }
  289. return section;
  290. }
  291. loadProjectTechniques(directory: string, menuItem: Atomic.UIMenuItemSource) {
  292. var resourcePath = ToolCore.toolSystem.project.getResourcePath();
  293. var TechniqueAssets = ToolCore.getAssetDatabase().getFolderAssets(directory);
  294. for (var i = 0; i < TechniqueAssets.length; i++) {
  295. var asset = TechniqueAssets[i];
  296. if (TechniqueAssets[i].isFolder()) {
  297. if (this.scanDirectoryForTechniques(asset.path)) {
  298. var subfoldersource = new Atomic.UIMenuItemSource();
  299. _ = new Atomic.UIMenuItem(TechniqueAssets[i].name);
  300. _.subSource = subfoldersource;
  301. menuItem.addItem(_);
  302. this.loadProjectTechniques(asset.path, subfoldersource);
  303. }
  304. }
  305. else {
  306. projectTechniques[i] = TechniqueAssets[i].name;
  307. projectTechniquesAddress[i] = TechniqueAssets[i].path;
  308. menuItem.addItem(new Atomic.UIMenuItem(projectTechniques[i], projectTechniques[i]));
  309. }
  310. }
  311. }
  312. scanDirectoryForTechniques(directory: string): boolean {
  313. var techniqueAssets = ToolCore.getAssetDatabase().getFolderAssets(directory);
  314. for (var i = 0; i < techniqueAssets.length; i++) {
  315. var asset = techniqueAssets[i];
  316. if (techniqueAssets[i].isFolder()) {
  317. if (this.scanDirectoryForTechniques(asset.path)) {
  318. return true;
  319. }
  320. }
  321. else if (techniqueAssets[i].getExtension() == ".xml") {
  322. return true;
  323. }
  324. }
  325. return false;
  326. }
  327. refreshTechniquesPopup() {
  328. techniqueSource.clear();
  329. _ = new Atomic.UIMenuItem("Solid");
  330. _.subSource = solidSource;
  331. techniqueSource.addItem(_);
  332. _ = new Atomic.UIMenuItem("Transparency");
  333. _.subSource = tranSource;
  334. techniqueSource.addItem(_);
  335. _ = new Atomic.UIMenuItem("Lightmap");
  336. _.subSource = lightmapSource;
  337. techniqueSource.addItem(_);
  338. var projectTechniquesPath = ToolCore.toolSystem.project.getResourcePath() + "Techniques";
  339. if (Atomic.fileSystem.dirExists(projectTechniquesPath)) {
  340. if (this.scanDirectoryForTechniques(projectTechniquesPath)) {
  341. projectSource.clear();
  342. _ = new Atomic.UIMenuItem("Project");
  343. _.subSource = projectSource;
  344. techniqueSource.addItem(_);
  345. this.loadProjectTechniques(projectTechniquesPath, projectSource);
  346. }
  347. }
  348. }
  349. inspect(asset: ToolCore.Asset, material: Atomic.Material) {
  350. // Add folders to resource directory
  351. this.asset = asset;
  352. this.material = material;
  353. var mlp = new Atomic.UILayoutParams();
  354. mlp.width = 310;
  355. var materialLayout = new Atomic.UILayout();
  356. materialLayout.spacing = 4;
  357. materialLayout.layoutDistribution = Atomic.UI_LAYOUT_DISTRIBUTION_GRAVITY;
  358. materialLayout.layoutPosition = Atomic.UI_LAYOUT_POSITION_LEFT_TOP;
  359. materialLayout.layoutParams = mlp;
  360. materialLayout.axis = Atomic.UI_AXIS_Y;
  361. // node attr layout
  362. var materialSection = new Atomic.UISection();
  363. materialSection.text = "Material";
  364. materialSection.value = 1;
  365. materialSection.fontDescription = this.fd;
  366. materialLayout.addChild(materialSection);
  367. var attrsVerticalLayout = new Atomic.UILayout(Atomic.UI_AXIS_Y);
  368. attrsVerticalLayout.spacing = 3;
  369. attrsVerticalLayout.layoutPosition = Atomic.UI_LAYOUT_POSITION_LEFT_TOP;
  370. attrsVerticalLayout.layoutSize = Atomic.UI_LAYOUT_SIZE_PREFERRED;
  371. // NAME
  372. var nameLayout = new Atomic.UILayout();
  373. nameLayout.layoutDistribution = Atomic.UI_LAYOUT_DISTRIBUTION_GRAVITY;
  374. var name = new Atomic.UITextField();
  375. name.textAlign = Atomic.UI_TEXT_ALIGN_LEFT;
  376. name.skinBg = "InspectorTextAttrName";
  377. name.text = "Name";
  378. name.fontDescription = this.fd;
  379. nameLayout.addChild(name);
  380. var field = new Atomic.UIEditField();
  381. field.textAlign = Atomic.UI_TEXT_ALIGN_LEFT;
  382. field.skinBg = "TBAttrEditorField";
  383. field.fontDescription = this.fd;
  384. var lp = new Atomic.UILayoutParams();
  385. lp.width = 160;
  386. field.layoutParams = lp;
  387. field.text = Atomic.splitPath(material.name).fileName;
  388. nameLayout.addChild(field);
  389. attrsVerticalLayout.addChild(nameLayout);
  390. // TECHNIQUE LAYOUT
  391. var techniqueLayout = new Atomic.UILayout();
  392. techniqueLayout.layoutSize = Atomic.UI_LAYOUT_SIZE_GRAVITY;
  393. techniqueLayout.layoutDistribution = Atomic.UI_LAYOUT_DISTRIBUTION_PREFERRED;
  394. name = new Atomic.UITextField();
  395. name.textAlign = Atomic.UI_TEXT_ALIGN_LEFT;
  396. name.skinBg = "InspectorTextAttrName";
  397. name.text = "Technique";
  398. name.fontDescription = this.fd;
  399. techniqueLayout.addChild(name);
  400. var techniquePopup = this.createTechniquePopup();
  401. techniqueLayout.addChild(techniquePopup);
  402. attrsVerticalLayout.addChild(techniqueLayout);
  403. materialSection.contentRoot.addChild(attrsVerticalLayout);
  404. materialLayout.addChild(this.createTextureSection());
  405. materialLayout.addChild(this.createShaderParametersSection());
  406. var button = new Atomic.UIButton();
  407. button.fontDescription = this.fd;
  408. button.gravity = Atomic.UI_GRAVITY_RIGHT;
  409. button.text = "Save";
  410. button.onClick = function () {
  411. var importer = <ToolCore.MaterialImporter>this.asset.getImporter();
  412. importer.saveMaterial();
  413. }.bind(this);
  414. materialLayout.addChild(button);
  415. this.addChild(materialLayout);
  416. }
  417. techniqueButton: Atomic.UIButton;
  418. material: Atomic.Material;
  419. asset: ToolCore.Asset;
  420. nameTextField: Atomic.UITextField;
  421. fd: Atomic.UIFontDescription = new Atomic.UIFontDescription();
  422. }
  423. export = MaterialInspector;