|
@@ -8,6 +8,7 @@
|
|
|
import ScriptWidget = require("ui/ScriptWidget");
|
|
import ScriptWidget = require("ui/ScriptWidget");
|
|
|
import UIEvents = require("ui/UIEvents");
|
|
import UIEvents = require("ui/UIEvents");
|
|
|
import EditorUI = require("ui/EditorUI");
|
|
import EditorUI = require("ui/EditorUI");
|
|
|
|
|
+import EditorEvents = require("editor/EditorEvents");
|
|
|
|
|
|
|
|
import TextureSelector = require("./TextureSelector");
|
|
import TextureSelector = require("./TextureSelector");
|
|
|
|
|
|
|
@@ -73,6 +74,10 @@ for (var key in techniqueLookup) {
|
|
|
|
|
|
|
|
class MaterialInspector extends ScriptWidget {
|
|
class MaterialInspector extends ScriptWidget {
|
|
|
|
|
|
|
|
|
|
+ currentTexture: Atomic.UITextureWidget = null;
|
|
|
|
|
+ tunit: number;
|
|
|
|
|
+ textureWidget: Atomic.UITextureWidget
|
|
|
|
|
+
|
|
|
constructor() {
|
|
constructor() {
|
|
|
|
|
|
|
|
super();
|
|
super();
|
|
@@ -80,7 +85,7 @@ class MaterialInspector extends ScriptWidget {
|
|
|
this.fd.id = "Vera";
|
|
this.fd.id = "Vera";
|
|
|
this.fd.size = 11;
|
|
this.fd.size = 11;
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ this.subscribeToEvent(EditorEvents.RemoveCurrentAssetAssigned, (ev: EditorEvents.RemoveCurrentAssetAssignedEvent) => this.createTextureRemoveButtonCallback(this.tunit, this.textureWidget));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
createShaderParametersSection(): Atomic.UISection {
|
|
createShaderParametersSection(): Atomic.UISection {
|
|
@@ -237,22 +242,38 @@ class MaterialInspector extends ScriptWidget {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- createTextureButtonCallback(textureUnit:number, textureWidget:Atomic.UITextureWidget) {
|
|
|
|
|
|
|
|
|
|
- return () => {
|
|
|
|
|
|
|
+ openTextureSelectionBox(textureUnit: number, textureWidget: Atomic.UITextureWidget) {
|
|
|
|
|
|
|
|
var inspector = this;
|
|
var inspector = this;
|
|
|
|
|
+
|
|
|
|
|
+ EditorUI.getModelOps().showResourceSelection("Select Texture", "TextureImporter", "Texture2D", function (asset: ToolCore.Asset, args: any) {
|
|
|
|
|
|
|
|
- EditorUI.getModelOps().showResourceSelection("Select Texture", "TextureImporter", "Texture2D", function(asset: ToolCore.Asset, args: any) {
|
|
|
|
|
-
|
|
|
|
|
- var texture = <Atomic.Texture2D> Atomic.cache.getResource("Texture2D", asset.path);
|
|
|
|
|
|
|
+ var texture = <Atomic.Texture2D>Atomic.cache.getResource("Texture2D", asset.path);
|
|
|
|
|
|
|
|
if (texture) {
|
|
if (texture) {
|
|
|
inspector.material.setTexture(textureUnit, texture);
|
|
inspector.material.setTexture(textureUnit, texture);
|
|
|
textureWidget.texture = inspector.getTextureThumbnail(texture);
|
|
textureWidget.texture = inspector.getTextureThumbnail(texture);
|
|
|
|
|
+
|
|
|
|
|
+ this.sendEvent(EditorEvents.InspectorProjectReference, { "path": texture.getName() });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Big Texture Button(referenced texture file path in project frame)
|
|
|
|
|
+ createTextureButtonCallback(textureUnit:number, textureWidget:Atomic.UITextureWidget) {
|
|
|
|
|
+
|
|
|
|
|
+ return () => {
|
|
|
|
|
+
|
|
|
|
|
+ var texture = this.material.getTexture(textureUnit);
|
|
|
|
|
+
|
|
|
|
|
+ if (textureWidget.getTexture() != null) {
|
|
|
|
|
+ this.sendEvent(EditorEvents.InspectorProjectReference, { "path": texture.getName() });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.openTextureSelectionBox(textureUnit, textureWidget);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
return true;
|
|
return true;
|
|
|
|
|
|
|
@@ -260,6 +281,27 @@ class MaterialInspector extends ScriptWidget {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // Small Texture Button (Opens texture selection window)
|
|
|
|
|
+ createTextureReferenceButtonCallback(textureUnit: number, textureWidget: Atomic.UITextureWidget) {
|
|
|
|
|
+
|
|
|
|
|
+ return () => {
|
|
|
|
|
+ this.tunit = textureUnit;
|
|
|
|
|
+ this.textureWidget = textureWidget;
|
|
|
|
|
+ this.openTextureSelectionBox(textureUnit, textureWidget);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //Remove Texture Button
|
|
|
|
|
+ createTextureRemoveButtonCallback(textureUnit: number, textureWidget: Atomic.UITextureWidget) {
|
|
|
|
|
+
|
|
|
|
|
+ var texture = this.material.getTexture(textureUnit);
|
|
|
|
|
+
|
|
|
|
|
+ if (texture != null && textureWidget != null) {
|
|
|
|
|
+ textureWidget.setTexture(null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
createTextureSection(): Atomic.UISection {
|
|
createTextureSection(): Atomic.UISection {
|
|
|
|
|
|
|
@@ -276,8 +318,7 @@ class MaterialInspector extends ScriptWidget {
|
|
|
section.contentRoot.addChild(attrsVerticalLayout);
|
|
section.contentRoot.addChild(attrsVerticalLayout);
|
|
|
|
|
|
|
|
// TODO: Filter on technique
|
|
// TODO: Filter on technique
|
|
|
- var textureUnits = [Atomic.TU_DIFFUSE, Atomic.TU_NORMAL, Atomic.TU_SPECULAR ,Atomic.TU_EMISSIVE];//, Atomic.TU_ENVIRONMENT,
|
|
|
|
|
- //Atomic.TU_CUSTOM1, Atomic.TU_CUSTOM2];
|
|
|
|
|
|
|
+ var textureUnits = [ Atomic.TU_DIFFUSE, Atomic.TU_NORMAL, Atomic.TU_SPECULAR, Atomic.TU_EMISSIVE ];
|
|
|
|
|
|
|
|
for (var i in textureUnits) {
|
|
for (var i in textureUnits) {
|
|
|
|
|
|
|
@@ -310,11 +351,19 @@ class MaterialInspector extends ScriptWidget {
|
|
|
textureButton["tunit"] = tunit;
|
|
textureButton["tunit"] = tunit;
|
|
|
textureButton["textureWidget"] = textureWidget;
|
|
textureButton["textureWidget"] = textureWidget;
|
|
|
|
|
|
|
|
|
|
+ //Create drop-down buttons to open Texture Selection Dialog Box
|
|
|
|
|
+ var textureRefButton = new Atomic.UIButton();
|
|
|
|
|
+ textureRefButton.skinBg = "arrow.down";
|
|
|
|
|
+ textureRefButton["tunit"] = tunit;
|
|
|
|
|
+ textureRefButton["textureWidget"] = textureWidget;
|
|
|
|
|
+
|
|
|
textureButton.onClick = this.createTextureButtonCallback(tunit, textureWidget);
|
|
textureButton.onClick = this.createTextureButtonCallback(tunit, textureWidget);
|
|
|
|
|
+ textureRefButton.onClick = this.createTextureReferenceButtonCallback(tunit, textureWidget);
|
|
|
|
|
|
|
|
textureButton.contentRoot.addChild(textureWidget);
|
|
textureButton.contentRoot.addChild(textureWidget);
|
|
|
|
|
|
|
|
attrLayout.addChild(textureButton);
|
|
attrLayout.addChild(textureButton);
|
|
|
|
|
+ attrLayout.addChild(textureRefButton);
|
|
|
|
|
|
|
|
attrsVerticalLayout.addChild(attrLayout);
|
|
attrsVerticalLayout.addChild(attrLayout);
|
|
|
|
|
|
|
@@ -335,6 +384,7 @@ class MaterialInspector extends ScriptWidget {
|
|
|
this.material.setTexture(ev.target["tunit"], texture);
|
|
this.material.setTexture(ev.target["tunit"], texture);
|
|
|
(<Atomic.UITextureWidget>ev.target["textureWidget"]).texture = this.getTextureThumbnail(texture);
|
|
(<Atomic.UITextureWidget>ev.target["textureWidget"]).texture = this.getTextureThumbnail(texture);
|
|
|
|
|
|
|
|
|
|
+ this.sendEvent("InspectorProjectReference", { "path": texture.getName(), "ButtonID": texture.getName() });
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|