|
|
@@ -9,6 +9,7 @@ import EditorUI = require("ui/EditorUI");
|
|
|
import InspectorUtils = require("./InspectorUtils");
|
|
|
import AttributeInfoEdit = require("./AttributeInfoEdit");
|
|
|
import SerializableEditType = require("./SerializableEditType");
|
|
|
+import EditorEvents = require("editor/EditorEvents");
|
|
|
|
|
|
class LightCascadeAttributeEdit extends AttributeInfoEdit {
|
|
|
|
|
|
@@ -106,6 +107,7 @@ class LightCascadeAttributeEdit extends AttributeInfoEdit {
|
|
|
interface MaterialEdit {
|
|
|
|
|
|
index: number;
|
|
|
+ pathReference: string;
|
|
|
editField: Atomic.UIEditField;
|
|
|
selectButton: Atomic.UIButton;
|
|
|
|
|
|
@@ -121,12 +123,47 @@ class SubmeshAttributeEdit extends AttributeInfoEdit {
|
|
|
enabledCheckBox: Atomic.UICheckBox;
|
|
|
nameField: Atomic.UITextField;
|
|
|
name: string;
|
|
|
+ matIndex: number;
|
|
|
|
|
|
constructor(name: string) {
|
|
|
|
|
|
super();
|
|
|
this.name = name;
|
|
|
this.hideName = true;
|
|
|
+
|
|
|
+ this.subscribeToEvent(EditorEvents.RemoveCurrentAssetAssigned, (ev: EditorEvents.RemoveCurrentAssetAssignedEvent) => {
|
|
|
+
|
|
|
+ this.editType.onAttributeInfoEdited(this.attrInfo, null, this.matIndex);
|
|
|
+ this.refresh();
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ openResourceSelectionBox(materialIndex: number, resourceTypeName: string, importerName: string) {
|
|
|
+
|
|
|
+ this.matIndex = materialIndex;
|
|
|
+
|
|
|
+ EditorUI.getModelOps().showResourceSelection("Select " + resourceTypeName + " Resource", importerName, resourceTypeName, function (retObject: any) {
|
|
|
+
|
|
|
+ var resource: Atomic.Resource = null;
|
|
|
+
|
|
|
+ if (retObject instanceof ToolCore.Asset) {
|
|
|
+
|
|
|
+ resource = (<ToolCore.Asset>retObject).getResource(resourceTypeName);
|
|
|
+
|
|
|
+ } else if (retObject instanceof Atomic.Resource) {
|
|
|
+
|
|
|
+ resource = <Atomic.Resource>retObject;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ this.sendEvent(EditorEvents.InspectorProjectReference, { "path": resource.name });
|
|
|
+ this.editType.onAttributeInfoEdited(this.attrInfo, resource, materialIndex);
|
|
|
+ this.refresh();
|
|
|
+
|
|
|
+ }.bind(this));
|
|
|
+
|
|
|
}
|
|
|
|
|
|
createMaterialEdit(materialIndex: number) {
|
|
|
@@ -141,32 +178,18 @@ class SubmeshAttributeEdit extends AttributeInfoEdit {
|
|
|
|
|
|
var selectButton = o.selectButton;
|
|
|
|
|
|
- var materialEdit: MaterialEdit = { index: materialIndex, editField: o.editField, selectButton: selectButton };
|
|
|
+ var materialEdit: MaterialEdit = { index: materialIndex, pathReference: "" , editField: o.editField, selectButton: selectButton };
|
|
|
this.materialEdits[materialIndex] = materialEdit;
|
|
|
|
|
|
var resourceTypeName = "Material";
|
|
|
var importerName = ToolCore.assetDatabase.getResourceImporterName(resourceTypeName);
|
|
|
|
|
|
- selectButton.onClick = () => {
|
|
|
-
|
|
|
- EditorUI.getModelOps().showResourceSelection("Select " + resourceTypeName + " Resource", importerName, resourceTypeName, function(retObject: any) {
|
|
|
-
|
|
|
- var resource: Atomic.Resource = null;
|
|
|
-
|
|
|
- if (retObject instanceof ToolCore.Asset) {
|
|
|
|
|
|
- resource = (<ToolCore.Asset>retObject).getResource(resourceTypeName);
|
|
|
-
|
|
|
- } else if (retObject instanceof Atomic.Resource) {
|
|
|
-
|
|
|
- resource = <Atomic.Resource>retObject;
|
|
|
-
|
|
|
- }
|
|
|
+ selectButton.onClick = () => {
|
|
|
|
|
|
- this.editType.onAttributeInfoEdited(this.attrInfo, resource, materialIndex);
|
|
|
- this.refresh();
|
|
|
+ this.openResourceSelectionBox(materialIndex, resourceTypeName, importerName);
|
|
|
+ // this.sendEvent(EditorEvents.InspectorProjectReference, { "path": pathName });
|
|
|
|
|
|
- }.bind(this));
|
|
|
};
|
|
|
|
|
|
// handle dropping of component on field
|
|
|
@@ -191,7 +214,7 @@ class SubmeshAttributeEdit extends AttributeInfoEdit {
|
|
|
if (importer) {
|
|
|
|
|
|
var resource = asset.getResource(resourceTypeName);
|
|
|
-
|
|
|
+ this.sendEvent(EditorEvents.InspectorProjectReference, { "path": resource.name });
|
|
|
this.editType.onAttributeInfoEdited(this.attrInfo, resource, materialIndex);
|
|
|
this.refresh();
|
|
|
}
|
|
|
@@ -199,6 +222,19 @@ class SubmeshAttributeEdit extends AttributeInfoEdit {
|
|
|
|
|
|
});
|
|
|
|
|
|
+ o.editField.subscribeToEvent(o.editField, "WidgetEvent", (ev: Atomic.UIWidgetEvent) => {
|
|
|
+
|
|
|
+ if (ev.type == Atomic.UI_EVENT_TYPE_POINTER_DOWN && o.editField.text != "") {
|
|
|
+
|
|
|
+ var pathName = materialEdit.pathReference;
|
|
|
+ this.sendEvent(EditorEvents.InspectorProjectReference, { "path": pathName });
|
|
|
+
|
|
|
+ } else if (o.editField.text == "") {
|
|
|
+
|
|
|
+ this.openResourceSelectionBox(materialIndex, resourceTypeName, importerName);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
createEditWidget() {
|
|
|
@@ -332,6 +368,7 @@ class SubmeshAttributeEdit extends AttributeInfoEdit {
|
|
|
|
|
|
var pathinfo = Atomic.splitPath(text);
|
|
|
matEdit.editField.text = pathinfo.fileName;
|
|
|
+ matEdit.pathReference = text;
|
|
|
}
|
|
|
|
|
|
|