В инспекторе все работает отлично.
Синтаксис:
Используется csharp
EditorUtility.SetDirty(matrix);
срабатывает как надо.
Синтаксис:
Используется csharp
Debug.Log(matrix.Elements[0,0]);
Выводит изменения в первом элементе.
Синтаксис:
Используется csharp
if (serializedObject.ApplyModifiedProperties()) Debug.Log("Вернул True");
не срабатывает...
То-ли у меня руки кривые...
Синтаксис:
Используется csharp
using System;
using UnityEngine;
[Serializable]
public class Matrix : MonoBehaviour
{
public int[,] Elements = new int[6,6];
}
using UnityEngine;
[Serializable]
public class Matrix : MonoBehaviour
{
public int[,] Elements = new int[6,6];
}
Синтаксис:
Используется csharp
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(Matrix))]
public class MatrixEditor : Editor
{
private Matrix matrix;
void Awake()
{
matrix = (Matrix)target;
}
public override void OnInspectorGUI()
{
serializedObject.Update();
for (int i = 0; i < matrix.Elements.GetLength(0); i++)
{
EditorGUILayout.BeginHorizontal();
for (int j = 0; j < matrix.Elements.GetLength(1); j++)
{
matrix.Elements[i, j] = EditorGUILayout.IntField(matrix.Elements[i, j]);
}
EditorGUILayout.EndHorizontal();
}
if (GUI.changed)
{
EditorUtility.SetDirty(matrix);
Debug.Log(matrix.Elements[0,0]);
}
if (serializedObject.ApplyModifiedProperties()) Debug.Log("Вернул True");
}
}
using UnityEngine;
[CustomEditor(typeof(Matrix))]
public class MatrixEditor : Editor
{
private Matrix matrix;
void Awake()
{
matrix = (Matrix)target;
}
public override void OnInspectorGUI()
{
serializedObject.Update();
for (int i = 0; i < matrix.Elements.GetLength(0); i++)
{
EditorGUILayout.BeginHorizontal();
for (int j = 0; j < matrix.Elements.GetLength(1); j++)
{
matrix.Elements[i, j] = EditorGUILayout.IntField(matrix.Elements[i, j]);
}
EditorGUILayout.EndHorizontal();
}
if (GUI.changed)
{
EditorUtility.SetDirty(matrix);
Debug.Log(matrix.Elements[0,0]);
}
if (serializedObject.ApplyModifiedProperties()) Debug.Log("Вернул True");
}
}