public void ImportRaw(string path = null) { #if UNITY_EDITOR //importing if (path == null) { path = UnityEditor.EditorUtility.OpenFilePanel("Import Texture File", "", "raw,r16"); } if (path == null || path.Length == 0) { return; } if (textureAsset == null) { textureAsset = ScriptableObject.CreateInstance <MatrixAsset>(); } if (textureAsset.matrix == null) { textureAsset.matrix = new Matrix(new CoordRect(0, 0, 1, 1)); } textureAsset.matrix.ImportRaw(path); texturePath = path; //generating preview CoordRect previewRect = new CoordRect(0, 0, 70, 70); previewMatrix = textureAsset.matrix.Resize(previewRect, previewMatrix); preview = previewMatrix.SimpleToTexture(); #endif }
public override void OnInspectorGUI() { //DrawDefaultInspector(); MatrixAsset script = (MatrixAsset)target; if (layout == null) { layout = new Layout(); } layout.field = Layout.GetInspectorRect(); layout.cursor = new Rect(layout.field.x, layout.field.y, 0, 0); layout.OnBeforeChange -= RecordUndo; layout.OnBeforeChange += RecordUndo; if (script.matrix == null) { layout.Label("Matrix is not defined"); return; } layout.Label("Size: " + script.matrix.rect.size.x + "," + script.matrix.rect.size.z); layout.Label("Offset: " + script.matrix.rect.offset.x + "," + script.matrix.rect.offset.z); texture = script.preview.SimpleToTexture(texture); layout.Par(texture.height, padding: 0); layout.Icon(texture, layout.Inset(texture.width, padding: 0)); Layout.SetInspectorRect(layout.field); }