I have this custom editor:
[CustomEditor(typeof(Fluid3D), true)]
public class Fluid3DEditor : Editor
{
public override void OnInspectorGUI()
{
//this method for create default monoBehavior fields
//that i make it in base class (Fluid3D)
DrawDefaultInspector();
EditorUtility.SetDirty(target);
SerializedProperty zz = serializedObject.FindProperty("Particle Radius");
// Debug.Log(zz.intValue);
Fluid3D fluid3D = (Fluid3D)target;
switch (fluid3D.initParticleWay)
{
case InitParticleWay.SPHERE:
Sphere(ref fluid3D);
break;
case InitParticleWay.CUBE:
Cube(ref fluid3D);
break;
}
}
void Sphere(ref Fluid3D fluid3D)
{
fluid3D.BallRadius = EditorGUILayout.FloatField("Sphere Radius", fluid3D.BallRadius);
}
void Cube(ref Fluid3D fluid3D)
{
fluid3D.ParticleRadius = EditorGUILayout.FloatField("Particle Radius", fluid3D.ParticleRadius);
fluid3D.separationFactor = EditorGUILayout.FloatField("Sepreation Factor", fluid3D.separationFactor);
EditorGUILayout.LabelField("Volume", fluid3D.Volume.ToString());
}
and the init value in class Field3D is
private float ballRadius = 0.1f;
public float separationFactor = 1.4f;
private float particleRadius = 0.15f;
when I edit the values from inspector before run the Scene the values doesn't changed, just change while the game but I am need changing before the game started.
CodePudding user response:
The two variables ball radius and particle radius are private. Serialize them:
[SerializeField] private float ballRadius = 0.1f;
[SerializeField] public float separationFactor = 1.4f;
[SerializeField] private float particleRadius = 0.15f;