|
|
@@ -8,6 +8,7 @@
|
|
|
import ScriptWidget = require("ui/ScriptWidget");
|
|
|
import UIEvents = require("ui/UIEvents");
|
|
|
import EditorUI = require("ui/EditorUI");
|
|
|
+import EditorEvents = require("editor/EditorEvents");
|
|
|
|
|
|
import TextureSelector = require("./TextureSelector");
|
|
|
|
|
|
@@ -237,22 +238,38 @@ class MaterialInspector extends ScriptWidget {
|
|
|
|
|
|
}
|
|
|
|
|
|
- createTextureButtonCallback(textureUnit:number, textureWidget:Atomic.UITextureWidget) {
|
|
|
|
|
|
- return () => {
|
|
|
+ openTextureSelectionBox(textureUnit: number, textureWidget: Atomic.UITextureWidget) {
|
|
|
|
|
|
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) {
|
|
|
inspector.material.setTexture(textureUnit, 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 (texture != null) {
|
|
|
+ this.sendEvent(EditorEvents.InspectorProjectReference, { "path": texture.getName() });
|
|
|
+ } else {
|
|
|
+ this.openTextureSelectionBox(textureUnit, textureWidget);
|
|
|
+ }
|
|
|
|
|
|
return true;
|
|
|
|
|
|
@@ -260,6 +277,14 @@ class MaterialInspector extends ScriptWidget {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ // Small Texture Button (Opens texture selection window)
|
|
|
+ createTextureReferenceButtonCallback(textureUnit: number, textureWidget: Atomic.UITextureWidget) {
|
|
|
+
|
|
|
+ return () => {
|
|
|
+ this.openTextureSelectionBox(textureUnit, textureWidget);
|
|
|
+ return true;
|
|
|
+ };
|
|
|
+ }
|
|
|
|
|
|
createTextureSection(): Atomic.UISection {
|
|
|
|
|
|
@@ -310,11 +335,19 @@ class MaterialInspector extends ScriptWidget {
|
|
|
textureButton["tunit"] = tunit;
|
|
|
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);
|
|
|
+ textureRefButton.onClick = this.createTextureReferenceButtonCallback(tunit, textureWidget);
|
|
|
|
|
|
textureButton.contentRoot.addChild(textureWidget);
|
|
|
|
|
|
attrLayout.addChild(textureButton);
|
|
|
+ attrLayout.addChild(textureRefButton);
|
|
|
|
|
|
attrsVerticalLayout.addChild(attrLayout);
|
|
|
|
|
|
@@ -335,6 +368,7 @@ class MaterialInspector extends ScriptWidget {
|
|
|
this.material.setTexture(ev.target["tunit"], texture);
|
|
|
(<Atomic.UITextureWidget>ev.target["textureWidget"]).texture = this.getTextureThumbnail(texture);
|
|
|
|
|
|
+ this.sendEvent("InspectorProjectReference", { "path": texture.getName(), "ButtonID": texture.getName() });
|
|
|
}
|
|
|
}
|
|
|
});
|