Exemplo n.º 1
0
        public override void OnInspectorGUI()
        {
            serializedObject.UpdateIfDirtyOrScript();

            ObiEmitterMaterial.MaterialChanges changes = ObiEmitterMaterial.MaterialChanges.PER_MATERIAL_DATA;

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(isFluid);
            EditorGUILayout.PropertyField(restRadius);
            if (EditorGUI.EndChangeCheck())
            {
                changes |= ObiEmitterMaterial.MaterialChanges.PER_PARTICLE_DATA;
            }


            GUI.enabled = !isFluid.boolValue;
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(randomRadius);
            if (EditorGUI.EndChangeCheck())
            {
                changes |= ObiEmitterMaterial.MaterialChanges.PER_PARTICLE_DATA;
            }
            GUI.enabled = false;

            GUI.enabled = isFluid.boolValue;
            EditorGUILayout.PropertyField(smoothingRadius);
            EditorGUILayout.PropertyField(relaxationFactor);

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(restDensity);
            if (EditorGUI.EndChangeCheck())
            {
                changes |= ObiEmitterMaterial.MaterialChanges.PER_PARTICLE_DATA;
            }

            EditorGUILayout.PropertyField(viscosity);
            EditorGUILayout.PropertyField(cohesion);
            EditorGUILayout.PropertyField(surfaceTension);
            EditorGUILayout.PropertyField(buoyancy);
            EditorGUILayout.PropertyField(atmosphericDrag);
            EditorGUILayout.PropertyField(atmosphericPressure);
            EditorGUILayout.PropertyField(vorticity);
            GUI.enabled = true;

            // Apply changes to the serializedProperty
            if (GUI.changed)
            {
                serializedObject.ApplyModifiedProperties();

                material.CommitChanges(changes);
            }
        }
        public override void OnInspectorGUI()
        {
            serializedObject.UpdateIfRequiredOrScript();

            ObiEmitterMaterial.MaterialChanges changes = ObiEmitterMaterial.MaterialChanges.PER_MATERIAL_DATA | ObiEmitterMaterial.MaterialChanges.PER_PARTICLE_DATA;

            Editor.DrawPropertiesExcluding(serializedObject, "m_Script");

            EditorGUILayout.HelpBox("Particle mass (kg):\n" +
                                    "2D:" + material.GetParticleMass(Oni.SolverParameters.Mode.Mode2D) + "\n" +
                                    "3D;" + material.GetParticleMass(Oni.SolverParameters.Mode.Mode3D) + "\n\n" +
                                    "Particle size:\n" +
                                    "2D:" + material.GetParticleSize(Oni.SolverParameters.Mode.Mode2D) + "\n" +
                                    "3D;" + material.GetParticleSize(Oni.SolverParameters.Mode.Mode3D), MessageType.Info);

            // Apply changes to the serializedProperty
            if (GUI.changed)
            {
                serializedObject.ApplyModifiedProperties();

                material.CommitChanges(changes);
            }
        }
Exemplo n.º 3
0
        public override void OnInspectorGUI()
        {
            serializedObject.UpdateIfDirtyOrScript();

            ObiEmitterMaterial.MaterialChanges changes = ObiEmitterMaterial.MaterialChanges.PER_MATERIAL_DATA;

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(isFluid);
            if (EditorGUI.EndChangeCheck())
            {
                changes |= ObiEmitterMaterial.MaterialChanges.PER_PARTICLE_DATA;
            }

            ObiEmitterMaterial.MaterialDimensions newMode = (ObiEmitterMaterial.MaterialDimensions)EditorGUILayout.EnumPopup(
                new GUIContent("Mode", "Sets the material for 2D mode or 3D mode. This affects particle mass/density calculations."),
                material.Mode);
            if (material.Mode != newMode)
            {
                Undo.RecordObject(material, "Set emitter material mode");
                material.Mode = newMode;
                EditorUtility.SetDirty(material);
            }

            GUI.enabled = !isFluid.boolValue;
            EditorGUI.BeginChangeCheck();

            float newRestRadius = EditorGUILayout.FloatField(new GUIContent("Rest radius", "Enabling this allows particles generated by this actor to interact with each other."), material.RestRadius);

            if (material.RestRadius != newRestRadius)
            {
                Undo.RecordObject(material, "Set rest radius");
                material.RestRadius = newRestRadius;
                EditorUtility.SetDirty(material);
            }

            EditorGUILayout.PropertyField(randomRadius);

            float newParticleMass = EditorGUILayout.FloatField(new GUIContent("Particle mass", "Enabling this allows particles generated by this actor to interact with each other."), material.ParticleMass);

            if (material.ParticleMass != newParticleMass)
            {
                Undo.RecordObject(material, "Set particle mass");
                material.ParticleMass = newParticleMass;
                EditorUtility.SetDirty(material);
            }

            if (EditorGUI.EndChangeCheck())
            {
                changes |= ObiEmitterMaterial.MaterialChanges.PER_PARTICLE_DATA;
            }

            GUI.enabled = isFluid.boolValue;
            EditorGUI.BeginChangeCheck();

            float newResolution = EditorGUILayout.FloatField(new GUIContent("Resolution", "Enabling this allows particles generated by this actor to interact with each other."), material.Resolution);

            if (material.Resolution != newResolution)
            {
                Undo.RecordObject(material, "Set resolution");
                material.Resolution = newResolution;
                EditorUtility.SetDirty(material);
            }

            float newSmoothing = EditorGUILayout.FloatField(new GUIContent("Smoothing", "Enabling this allows particles generated by this actor to interact with each other."), material.Smoothing);

            if (material.Smoothing != newSmoothing)
            {
                Undo.RecordObject(material, "Set smoothing");
                material.Smoothing = newSmoothing;
                EditorUtility.SetDirty(material);
            }

            float newRestDensity = EditorGUILayout.FloatField(new GUIContent("Rest density", "Enabling this allows particles generated by this actor to interact with each other."), material.RestDensity);

            if (material.RestDensity != newRestDensity)
            {
                Undo.RecordObject(material, "Set smoothing");
                material.RestDensity = newRestDensity;
                EditorUtility.SetDirty(material);
            }

            if (EditorGUI.EndChangeCheck())
            {
                changes |= ObiEmitterMaterial.MaterialChanges.PER_PARTICLE_DATA;
            }
            EditorGUILayout.PropertyField(viscosity);
            EditorGUILayout.PropertyField(surfaceTension);
            EditorGUILayout.PropertyField(buoyancy);
            EditorGUILayout.PropertyField(atmosphericDrag);
            EditorGUILayout.PropertyField(atmosphericPressure);
            EditorGUILayout.PropertyField(vorticity);
            GUI.enabled = true;

            // Apply changes to the serializedProperty
            if (GUI.changed)
            {
                serializedObject.ApplyModifiedProperties();

                material.CommitChanges(changes);
            }
        }