public void DrawInspector(Matrix matrix, BaseMatrixWindow window) { if (matrix == null) { return; } using (Cell.LineStd) Draw.Field(ref margins, "Margins"); using (Cell.LineStd) { using (Cell.RowPx(50)) Draw.Label("Asset"); using (Cell.Row) Draw.ObjectField(ref exportAsset, allowSceneObject: true); using (Cell.RowPx(60)) if (Draw.Button("Save...")) { MatrixAsset matrixAsset = new MatrixAsset(); matrixAsset.matrix = matrix; matrixAsset.RefreshPreview(); ScriptableAssetExtensions.SaveAsset(matrixAsset); } Cell.EmptyRowPx(10); using (Cell.RowPx(60)) { //if (Draw.Button("Save...")) {} } } using (Cell.LineStd) { using (Cell.RowPx(50)) Draw.Label("Texture"); using (Cell.Row) Draw.ObjectField(ref exportTexture, allowSceneObject: true); using (Cell.RowPx(60)) if (Draw.Button("Export") && exportTexture != null) { MatrixToTexture(matrix, ref exportTexture); } Cell.EmptyRowPx(10); using (Cell.RowPx(60)) if (Draw.Button("Save...")) { Texture2D texture = null; MatrixToTexture(matrix, ref texture); ScriptableAssetExtensions.SaveTexture(texture); } } using (Cell.LineStd) { using (Cell.RowPx(50)) Draw.Label("Terrain"); using (Cell.Row) Draw.ObjectField(ref exportTerrain, allowSceneObject: true); using (Cell.RowPx(60)) if (Draw.Button("Export") && exportTerrain != null) { MatrixToTerrain(matrix, exportTerrain); } Cell.EmptyRowPx(10); using (Cell.RowPx(60)) { //if (Draw.Button("Save...")) {} } } }
private void DrawGUI() { matrixAsset = (MatrixAsset)target; using (Cell.LinePx(32)) Draw.Label("WARNING: Serializing this asset when selected in \nInspector can slow down editor GUI performance.", style: UI.current.styles.helpBox); Cell.EmptyLinePx(5); if (matrixAsset.matrix != null && matrixAsset.preview == null) { matrixAsset.RefreshPreview(); } if (matrixAsset.preview != null) { using (Cell.LinePx(256)) { Cell.EmptyRowRel(1); using (Cell.RowPx(256)) { //Draw.Texture(matrixAsset.preview); Draw.MatrixPreviewTexture(matrixAsset.preview, colorize: colorize, relief: relief, min: 0, max: 1); Draw.MatrixPreviewReliefSwitch(ref colorize, ref relief); } Cell.EmptyRowRel(1); } if (matrixAsset.rawPath != null) { using (Cell.LineStd) Draw.Label(matrixAsset.rawPath); } if (matrixAsset.matrix != null) { using (Cell.LineStd) Draw.Label(matrixAsset.matrix.rect.size.x + ", " + matrixAsset.matrix.rect.size.z); } } Cell.EmptyLinePx(5); using (Cell.LineStd) Draw.Field(ref matrixAsset.source, "Map Source"); if (matrixAsset.source == MatrixAsset.Source.Raw) { using (Cell.LinePx(22)) Draw.Label("Square gray 16bit RAW, PC byte order", style: UI.current.styles.helpBox); using (Cell.LineStd) if (Draw.Button("Load RAW")) { matrixAsset.ImportRaw(); EditorUtility.SetDirty(matrixAsset); } } else //texture { using (Cell.LineStd) { Texture2D newTexture = Draw.ObjectField(matrixAsset.textureSource, "Texture"); // if (newTexture != matrixAsset.textureSource) { matrixAsset.ImportTexture(newTexture, matrixAsset.channelSource); } matrixAsset.textureSource = newTexture; EditorUtility.SetDirty(matrixAsset); } using (Cell.LineStd) { MatrixAsset.Channel newChannel = (MatrixAsset.Channel)Draw.Field(matrixAsset.channelSource, "Channel"); // if (newChannel != matrixAsset.channelSource) { matrixAsset.ImportTexture(matrixAsset.textureSource, newChannel); } matrixAsset.channelSource = newChannel; EditorUtility.SetDirty(matrixAsset); } } using (Cell.LineStd) { Cell.current.disabled = (matrixAsset.source == MatrixAsset.Source.Raw && matrixAsset.rawPath == null) || (matrixAsset.source == MatrixAsset.Source.Texture && matrixAsset.textureSource == null); if (Draw.Button("Reload")) { matrixAsset.Reload(); EditorUtility.SetDirty(matrixAsset); } } }