示例#1
0
    public override void OnInspectorGUI()
    {
        if (exploderSerObject != null)
        {
            exploderSerObject.Update();
            var change = false;

            EditorGUILayout.Space();
            EditorExploderUtils.Separator("Fragment Audio", 20);
            EditorGUILayout.Space();

            var hasAudioSource = fragment.gameObject.GetComponent <AudioSource>();

            if (!hasAudioSource && EditorExploderUtils.Button("Add Hit Audio Source"))
            {
                fragment.audioSource             = fragment.gameObject.AddComponent <AudioSource>();
                fragment.audioSource.playOnAwake = false;
            }

            if (change)
            {
                exploderSerObject.ApplyModifiedProperties();
                EditorUtility.SetDirty(exploder);
            }

            EditorGUILayout.Separator();
        }
    }
示例#2
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        var exploder = this.target as ExploderObject;

        if (exploder)
        {
            var change = false;

            EditorExploderUtils.Separator("Main Settings", 20);
            EditorGUILayout.Space();

            GUI.enabled = !(exploder.ExplodeSelf && exploder.DisableRadiusScan);
            change     |= EditorExploderUtils.SliderEdit("Radius", "Explosion radius.", 0.0f, 100, radius);
            GUI.enabled = true;

            change |= EditorExploderUtils.SliderEdit("Force", "Force of explosion.", 0.0f, 100, force);
            change |= EditorExploderUtils.SliderEdit("Target Fragments", "Number of target fragments.", 0, 500, targetFragments);
            change |= EditorExploderUtils.SliderEdit("Frame Budget [ms]", "Time budget in [ms] for processing explosion calculation in one frame.", 0.0f, 60.0f, frameBudget);
            change |= EditorExploderUtils.Toggle("Use Force Vector", "Use this vector as a direction of explosion.", useForceVector);

            if (exploder.UseForceVector)
            {
                change |= EditorExploderUtils.Vector3("", "Use this vector as a direction of explosion.", forceVector);
            }

            change |= EditorExploderUtils.Toggle("Ignore Tag", "Ignore Exploder tag on object, use Explodable component instead.", ignoreTag);
            change |= EditorExploderUtils.Toggle("Mesh colliders", "Use mesh colliders for all fragments.", meshColliders);

            change |= EditorExploderUtils.Toggle("Explode self", "Explode this game object.", explodeSelf);
//            else
//            {
//                change |= EditorExploderUtils.Toggle2("Explode self", "Explode this game object.", "", "Disable radius",
//                                                      explodeSelf, disableRadiusScan);
//            }

            if (exploder.ExplodeSelf)
            {
                change |= EditorExploderUtils.Toggle("Disable radius", "Disable scanning for objects in radius.", disableRadiusScan);
            }

            change |= EditorExploderUtils.Toggle("Hide self", "Hide this game object after explosion.", hideSelf);
            change |= EditorExploderUtils.Toggle("Delete original object", "Delete original game object after explosion.", deleteOriginalObjects);
            change |= EditorExploderUtils.Toggle("Uniform distribution", "Uniformly distribute fragments inside the radius.", uniformDistribution);
            change |= EditorExploderUtils.Toggle("Split mesh islands", "Split non-connecting part of the mesh into separate fragments.", splitMeshIslands);
            change |= EditorExploderUtils.Toggle("Open mesh cutting", "Enable explosion of non-closed mesh.", openMeshCutting);
            change |= EditorExploderUtils.Toggle("Use 2D physics", "Enable 2D explosion.", user2dPhysics);

            EditorGUILayout.Space();
            EditorExploderUtils.Separator("Deactivation options", 20);
            EditorGUILayout.Space();

            EditorExploderUtils.EnumSelection("Deactivate on", "Options for fragment deactivation.", exploder.DeactivateOptions, deactivateOn, ref change);

            if (exploder.DeactivateOptions == DeactivateOptions.Timeout)
            {
                change |= EditorExploderUtils.SliderEdit("Deactivate Timeout [s]", "Time in [s] to deactivate fragments.", 0.0f, 60.0f, deactivateTimeout);
                EditorExploderUtils.EnumSelection("FadeOut", "Option for fragments to fadeout during deactivation timeout.", exploder.FadeoutOptions, fadeout, ref change);
            }

            EditorGUILayout.Space();
            EditorExploderUtils.Separator("Fragment options", 20);
            EditorGUILayout.Space();

            change |= EditorExploderUtils.Toggle("Explodable fragments", "Enable fragments to be exploded again.", explodableFragments);
            change |= EditorExploderUtils.SliderEdit("Pool Size", "Size of the fragment pool, this value should be higher than TargetFragments.", 0, 500, poolSize);

            change |= EditorExploderUtils.String("Layer", "Layer of the fragment game object.", layer);
            change |= EditorExploderUtils.SliderEdit("MaxVelocity", "Maximal velocity that fragment can have.", 0.0f, 100.0f, maxVelocity);
            change |= EditorExploderUtils.SliderEdit("MaxAngularVelocity", "Maximal angular velocity that fragment can have.", 0.0f, 30.0f, maxAngularVelocity);
            change |= EditorExploderUtils.Toggle("Inherit parent physics", "Use the same physics settings as in original game object.", inheritParentPhysics);
            change |= EditorExploderUtils.SliderEdit("Mass", "Mass property of every fragment.", 0.0f, 100.0f, mass);
            change |= EditorExploderUtils.Toggle("Use gravity", "Apply gravity to fragment.", useGravity);

            change |= EditorExploderUtils.Toggle("Disable colliders", "Disable colliders of all fragments.", disableColliders);

            change |= EditorExploderUtils.SliderEdit("Angular velocity", "Angular velocity of fragments.", 0.0f, 100.0f, angularVelocity);
            change |= EditorExploderUtils.Toggle("Random angular vector", "Randomize rotation of fragments.", randomAngularVelocity);

            if (!exploder.FragmentOptions.RandomAngularVelocityVector)
            {
                change |= EditorExploderUtils.Vector3("", "Use this vector as a angular velocity vector.", angularVelocityVector);
            }

            change |= EditorExploderUtils.Toggle3("Freeze Position", "Freeze position of the fragment in selected axis.",
                                                  "x", "y", "z", freezePositionX,
                                                  freezePositionY,
                                                  freezePositionZ);

            change |= EditorExploderUtils.Toggle3("Freeze Rotation", "Freeze rotation of the fragment in selected axis.",
                                                  "x", "y", "z", freezeRotationX,
                                                  freezeRotationY,
                                                  freezeRotationZ);

            change |= EditorExploderUtils.ObjectSelection <Material>("Material", "Optional material for fragments.",
                                                                     fragmentMaterial);

            EditorGUILayout.Space();
            EditorExploderUtils.Separator("SFX options", 20);
            EditorGUILayout.Space();

            change |= EditorExploderUtils.ObjectSelection <AudioClip>("Explosion sound", "Sound effect played on explosion.", explosionSound);
            change |= EditorExploderUtils.ObjectSelection <AudioClip>("Fragment hit sound", "Sound effect when the fragment hits another collider (wall, floor).", fragmentHitSound);

            if (exploder.SFXOptions.FragmentSoundClip)
            {
                change |= EditorExploderUtils.SliderEdit("Hit sound timeout", "Timeout between sound effects.",
                                                         0.0f, 1.0f, fragmentHitSoundTimeout);
            }

            change |= EditorExploderUtils.ObjectSelection <GameObject>("Fragment particles", "Particle effect that will start to emit from each fragment after explosion.", fragmentParticles);

            if (exploder.SFXOptions.FragmentEmitter)
            {
                change |= EditorExploderUtils.IntEdit("Maximum emitters", "Maximumal number of emmiters.", 0, 1000,
                                                      fragmentParticlesMax);
            }

            if (change)
            {
                serializedObject.ApplyModifiedProperties();
                EditorUtility.SetDirty(exploder);
            }

            EditorGUILayout.Separator();
        }
    }
示例#3
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        var exploder = this.target as ExploderObject;

        if (exploder)
        {
            var change = false;

            EditorExploderUtils.Separator("Main Settings", 20);
            EditorGUILayout.Space();

            GUI.enabled = !(exploder.ExplodeSelf && exploder.DisableRadiusScan && useCubeRadius.boolValue);

            change |= EditorExploderUtils.SliderEdit("Radius", "Explosion radius.", 0.0f, 100, radius);

            GUI.enabled = true;

            change |= EditorExploderUtils.SliderEdit("Force", "Force of explosion.", 0.0f, 100, force);
            change |= EditorExploderUtils.SliderEdit("Target Fragments", "Number of target fragments.", 0, 500, targetFragments);

            if (exploder.ThreadOption == ExploderObject.ThreadOptions.Disabled)
            {
                change |= EditorExploderUtils.SliderEdit("Frame Budget [ms]", "Time budget in [ms] for processing explosion calculation in one frame.", 0.0f, 60.0f, frameBudget);
            }

            change |= EditorExploderUtils.Toggle("Use Force Vector", "Use this vector as a direction of explosion.", useForceVector);

            if (exploder.UseForceVector)
            {
                change |= EditorExploderUtils.Vector3("", "Use this vector as a direction of explosion.", forceVector);
            }

            change |= EditorExploderUtils.Toggle("Ignore Tag", "Ignore Exploder tag on object, use Explodable component instead.", ignoreTag);

            change |= EditorExploderUtils.Toggle("Explode self", "Explode this game object.", explodeSelf);

            if (exploder.ExplodeSelf)
            {
                change |= EditorExploderUtils.Toggle("Disable radius", "Disable scanning for objects in radius.", disableRadiusScan);
            }

            change |= EditorExploderUtils.Toggle("Hide self", "Hide this game object after explosion.", hideSelf);
            change |= EditorExploderUtils.Toggle("Delete original object", "Delete original game object after explosion.", deleteOriginalObjects);
            change |= EditorExploderUtils.Toggle("Uniform distribution", "Uniformly distribute fragments inside the radius.", uniformDistribution);
            change |= EditorExploderUtils.Toggle("Split mesh islands", "Split non-connecting part of the mesh into separate fragments.", splitMeshIslands);
            change |= EditorExploderUtils.Toggle("Disable triangulation", "Disable triangulation of fragments.", disableTriangulation);
            change |= EditorExploderUtils.Toggle("Use 2D physics", "Enable 2D explosion.", user2dPhysics);

            change |= EditorExploderUtils.Toggle("Use Cube Radius", "Explosion cubic radius.", useCubeRadius);

            if (useCubeRadius.boolValue)
            {
                change |= EditorExploderUtils.Vector3("", "Explosion cubic radius.", cubeRadius);
            }

            EditorExploderUtils.EnumSelection("Multi-threading", "Options for multi-threaded calculations.", exploder.ThreadOption, threadingOptions, ref change);

            EditorExploderUtils.EnumSelection("Cutting plane angle", "Style of cutting plane.", exploder.CuttingStyle, cuttingStyle, ref change);

//            EditorGUILayout.Space();
//            EditorExploderUtils.Separator("Partial explosion", 20);
//            EditorGUILayout.Space();

            EditorGUILayout.Space();
            EditorExploderUtils.Separator("Audio", 20);
            EditorGUILayout.Space();

            var hasAudioSource = exploder.gameObject.GetComponent <AudioSource>();

            if (!hasAudioSource && EditorExploderUtils.Button("Add Explosion Audio Source"))
            {
                var audioSource = exploder.gameObject.AddComponent <AudioSource>();
                audioSource.playOnAwake = false;
            }

            EditorGUILayout.Space();
            EditorExploderUtils.Separator("Fragment options", 20);
            EditorGUILayout.Space();

            change |= EditorExploderUtils.SliderEdit("Pool Size", "Size of the fragment pool, this value should be higher than TargetFragments.", 0, 1000, poolSize);

            change |= EditorExploderUtils.Toggle("Explodable fragments", "Enable fragments to be exploded again.", explodableFragments);
            change |= EditorExploderUtils.String("Layer", "Layer of the fragment game object.", layer);

            change |= EditorExploderUtils.Toggle("Mesh colliders", "Use mesh colliders for all fragments.", meshColliders);
            change |= EditorExploderUtils.Toggle("Disable colliders", "Disable colliders of all fragments.", disableColliders);

            change |= EditorExploderUtils.SliderEdit("MaxVelocity", "Maximal velocity that fragment can have.", 0.0f, 100.0f, maxVelocity);
            change |= EditorExploderUtils.SliderEdit("MaxAngularVelocity", "Maximal angular velocity that fragment can have.", 0.0f, 30.0f, maxAngularVelocity);
            change |= EditorExploderUtils.Toggle("Inherit parent physics", "Use the same physics settings as in original game object.", inheritParentPhysics);
            change |= EditorExploderUtils.SliderEdit("Mass", "Mass property of every fragment.", 0.0f, 100.0f, mass);
            change |= EditorExploderUtils.Toggle("Use gravity", "Apply gravity to fragment.", useGravity);

            change |= EditorExploderUtils.SliderEdit("Angular velocity", "Angular velocity of fragments.", 0.0f, 100.0f, angularVelocity);
            change |= EditorExploderUtils.Toggle("Random angular vector", "Randomize rotation of fragments.", randomAngularVelocity);

            if (!exploder.FragmentOptions.RandomAngularVelocityVector)
            {
                change |= EditorExploderUtils.Vector3("", "Use this vector as a angular velocity vector.", angularVelocityVector);
            }

            change |= EditorExploderUtils.Toggle3("Freeze Position", "Freeze position of the fragment in selected axis.",
                                                  "x", "y", "z", freezePositionX,
                                                  freezePositionY,
                                                  freezePositionZ);

            change |= EditorExploderUtils.Toggle3("Freeze Rotation", "Freeze rotation of the fragment in selected axis.",
                                                  "x", "y", "z", freezeRotationX,
                                                  freezeRotationY,
                                                  freezeRotationZ);

            change |= EditorExploderUtils.ObjectSelection <Material>("Material", "Optional material for fragments.",
                                                                     fragmentMaterial);

            EditorGUILayout.Space();
            EditorExploderUtils.Separator("Fragment Deactivation", 20);
            EditorGUILayout.Space();

            EditorExploderUtils.EnumSelection("Deactivate on", "Options for fragment deactivation.", exploder.FragmentDeactivation.DeactivateOptions, deactivateOn, ref change);

            if (exploder.FragmentDeactivation.DeactivateOptions == DeactivateOptions.Timeout)
            {
                change |= EditorExploderUtils.SliderEdit("Deactivate Timeout [s]", "Time in [s] to deactivate fragments.", 0.0f, 60.0f, deactivateTimeout);
                EditorExploderUtils.EnumSelection("FadeOut", "Option for fragments to fadeout during deactivation timeout.", exploder.FragmentDeactivation.FadeoutOptions, fadeout, ref change);

                if (exploder.FragmentDeactivation.FadeoutOptions == FadeoutOptions.FadeoutAlpha)
                {
                    EditorExploderUtils.WarningBox("Requires transparent shaders", 20);
                }
            }

            EditorGUILayout.Space();
            EditorExploderUtils.Separator("Fragment Particles", 20);
            EditorGUILayout.Space();

            change |= EditorExploderUtils.ObjectSelection <GameObject>("Particles prefab", "Particle effect that will start to emit from each fragment after explosion.", fragmentParticles);

            if (exploder.FragmentSFX.FragmentEmitter)
            {
                change |= EditorExploderUtils.IntEdit("Maximum emitters", "Maximumal number of emmiters.", 0, 1000, fragmentParticlesMax);

                bool isTimeout     = fragmentParticlesTimeout.floatValue > 0.0f;
                var  changeTimeout = EditorExploderUtils.ToggleBool("Particle timeout", "Timeout to deactivate partices.", ref isTimeout);
                change |= changeTimeout;

                if (isTimeout)
                {
                    if (changeTimeout)
                    {
                        fragmentParticlesTimeout.floatValue = 1.0f;
                    }

                    change |= EditorExploderUtils.SliderEdit("", "Timeout to deactivate partices.", 0.001f, 100.0f, fragmentParticlesTimeout);
                }
                else
                {
                    fragmentParticlesTimeout.floatValue = -1.0f;
                }
            }

            EditorGUILayout.Space();
            EditorExploderUtils.Separator("Fragment Audio", 20);
            EditorGUILayout.Space();

            var fragment = GameObject.FindObjectOfType <Fragment>();

            if (fragment && fragment.GetComponent <AudioSource>())
            {
                change |= EditorExploderUtils.SliderEdit("Hit sound chance %", "Chance to play the hit sound.", 0, 100, fragmentHitSoundChance);
                change |= EditorExploderUtils.Toggle("Play only once", "Play only one time per fragment.", fragmentHitSoundOnce);
                change |= EditorExploderUtils.Toggle("Mix multiple hit sounds", "Allow playing multiple hit sounds.", fragmentMixMultipleSounds);
            }
            else
            {
                EditorExploderUtils.WarningBox("Audio Source on Fragment Prefab required.", 20);
            }

            EditorGUILayout.Space();
            EditorExploderUtils.Separator("Fragment Prefab", 20);
            EditorGUILayout.Space();

            if (EditorExploderUtils.Button("Edit Fragment Prefab"))
            {
                GameObject fragmentObject = null;

                if (fragment)
                {
                    fragmentObject = fragment.gameObject;
                }
                else
                {
                    var fragmentPrefab = Resources.Load("ExploderFragment");

                    if (fragmentPrefab)
                    {
                        fragmentObject = Instantiate(fragmentPrefab) as GameObject;

                        if (fragmentObject)
                        {
                            fragmentObject.name = "ExploderFragment";
                        }
                    }
                }

                if (fragmentObject)
                {
                    Selection.activeGameObject = fragmentObject;
                }
            }

            if (change)
            {
                serializedObject.ApplyModifiedProperties();
                EditorUtility.SetDirty(exploder);
            }

            EditorGUILayout.Separator();
        }
    }