public override void BaseGUI()
        {
            BeginBox();
            GUILayout.Label(ContentProperties.ShootProperties, UEditorStyles.SectionHeaderLabel);
            GUILayout.Space(7);
            instance.SetFirePoint((Transform)EditorGUILayout.ObjectField(ContentProperties.ShootPoint, instance.GetFirePoint(), typeof(Transform), true));
            instance.SetBullet((RayBullet)EditorGUILayout.ObjectField(ContentProperties.RayBullet, instance.GetBullet(), typeof(RayBullet), false));
            instance.SetRange(EditorGUILayout.FloatField(ContentProperties.ShootRange, instance.GetRange()));
            instance.SetImpulse(EditorGUILayout.FloatField(ContentProperties.ShootImpulse, instance.GetImpulse()));
            instance.SetDelay(EditorGUILayout.FloatField(ContentProperties.Delay, instance.GetDelay()));

            GUILayout.Space(10);
            GUILayout.Label(ContentProperties.FireEffectProperties, UEditorStyles.SectionHeaderLabel);
            GUILayout.Space(7);
            if (instance.GetMuzzleFlash() != null)
            {
                instance.SetMuzzleFlash((ParticleSystem)EditorGUILayout.ObjectField(ContentProperties.MuzzleFlash, instance.GetMuzzleFlash(), typeof(ParticleSystem), true));
            }
            else
            {
                GUILayout.BeginHorizontal();
                instance.SetMuzzleFlash((ParticleSystem)EditorGUILayout.ObjectField(ContentProperties.MuzzleFlash, instance.GetMuzzleFlash(), typeof(ParticleSystem), true));
                if (SearchButton())
                {
                    ParticleSystem muzzleFlash = UEditorInternal.FindMuzzleFlash(instance.transform);
                    if (muzzleFlash != null)
                    {
                        instance.SetMuzzleFlash(muzzleFlash);
                    }
                    else
                    {
                        UDisplayDialogs.Message("Searching", "Muzzle Flash not found, try find it manually.");
                    }
                }
                GUILayout.EndHorizontal();
                UEditorHelpBoxMessages.Tip("Muzzle flash is empty!", "Muzzle flash won't play.");
            }

            if (instance.GetCartridgeEjection() != null)
            {
                instance.SetCartridgeEjection((ParticleSystem)EditorGUILayout.ObjectField(ContentProperties.CartridgeEjection, instance.GetCartridgeEjection(), typeof(ParticleSystem), true));
            }
            else
            {
                GUILayout.BeginHorizontal();
                instance.SetCartridgeEjection((ParticleSystem)EditorGUILayout.ObjectField(ContentProperties.CartridgeEjection, instance.GetCartridgeEjection(), typeof(ParticleSystem), true));
                if (SearchButton())
                {
                    ParticleSystem cartridgeEjection = UEditorInternal.FindCartridgeEjection(instance.transform);
                    if (cartridgeEjection != null)
                    {
                        instance.SetCartridgeEjection(cartridgeEjection);
                    }
                    else
                    {
                        UDisplayDialogs.Message("Searching", "Cartridge Ejection not found, try find it manually.");
                    }
                }
                GUILayout.EndHorizontal();
                UEditorHelpBoxMessages.Tip("Cartridge ejection is empty!", "Cartridge ejection won't play.");
            }

            GUILayout.Space(10);
            GUILayout.Label(ContentProperties.SoundProperties, UEditorStyles.SectionHeaderLabel);
            GUILayout.Space(7);
            IncreaseIndentLevel();
            BeginSubBox();
            GUILayout.Space(3);
            shootSoundsFoldout = EditorGUILayout.Foldout(shootSoundsFoldout, ContentProperties.ShootSound, true);
            if (shootSoundsFoldout)
            {
                if (instance.GetFireSounds() == null || instance.GetFireSounds().Length == 0)
                {
                    UEditorHelpBoxMessages.Tip("Fire sounds is empty!", "Add new fire sound by click on [Add] button.", true);
                }
                else
                {
                    for (int i = 0; i < instance.GetFireSounds().Length; i++)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Space(3);
                        GUILayout.Label("Clip " + (i + 1), GUILayout.Width(35));
                        instance.SetFireSound(i, (AudioClip)EditorGUILayout.ObjectField(instance.GetFireSound(i), typeof(AudioClip), true));
                        if (GUILayout.Button("", GUI.skin.GetStyle("OL Minus"), GUILayout.Width(20)))
                        {
                            fireSounds.DeleteArrayElementAtIndex(i);
                        }
                        GUILayout.Space(3);
                        GUILayout.EndHorizontal();
                    }
                }
                GUILayout.Space(3);
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button(" Add "))
                {
                    fireSounds.arraySize++;
                }
                GUILayout.Space(3);
                GUILayout.EndHorizontal();
                GUILayout.Space(5);
            }
            GUILayout.Space(3);
            EndSubBox();
            DecreaseIndentLevel();
            EndBox();
        }
Example #2
0
        public override void BaseGUI()
        {
            BeginBox();
            GUILayout.Label(ContentProperties.ShootProperties, UEditorStyles.SectionHeaderLabel);
            GUILayout.Space(7);
            instance.SetMode((WeaponShootingSystem.Mode)EditorGUILayout.EnumPopup(ContentProperties.ShootingMode, instance.GetMode()));
            instance.SetBulletType((WeaponShootingSystem.BulletType)EditorGUILayout.EnumPopup(ContentProperties.BulletType, instance.GetBulletType()));
            instance.SetFirePoint((Transform)EditorGUILayout.ObjectField(ContentProperties.ShootPoint, instance.GetFirePoint(), typeof(Transform), true));
            switch (instance.GetBulletType())
            {
            case WeaponShootingSystem.BulletType.RayBullet:
                instance.SetRayBullet((RayBullet)EditorGUILayout.ObjectField(ContentProperties.RayBullet, instance.GetRayBullet(), typeof(RayBullet), false));
                instance.SetFireRange(EditorGUILayout.FloatField(ContentProperties.ShootRange, instance.GetFireRange()));
                break;

            case WeaponShootingSystem.BulletType.PhysicsBullet:
                instance.SetPhysicsBullet((PhysicsBullet)EditorGUILayout.ObjectField(ContentProperties.BulletType, instance.GetPhysicsBullet(), typeof(PhysicsBullet), true));
                break;
            }
            instance.SetFireImpulse(EditorGUILayout.FloatField(ContentProperties.ShootImpulse, instance.GetFireImpulse()));
            instance.SetDelay(EditorGUILayout.FloatField(ContentProperties.Delay, instance.GetDelay()));

            if (instance.GetMode() == WeaponShootingSystem.Mode.Queue)
            {
                instance.SetFixedQueueCount(EditorGUILayout.IntField(ContentProperties.FixedQueueCount, instance.GetFixedQueueCount()));
            }

            GUILayout.Space(10);
            GUILayout.Label(ContentProperties.FireEffectProperties, UEditorStyles.SectionHeaderLabel);
            GUILayout.Space(7);
            WeaponShootingSystem.FireEffectProperties fireEffectProperties = instance.GetFireEffects();
            if (fireEffectProperties.muzzleFlash != null)
            {
                fireEffectProperties.muzzleFlash = (ParticleSystem)EditorGUILayout.ObjectField(ContentProperties.MuzzleFlash, fireEffectProperties.muzzleFlash, typeof(ParticleSystem), true);
            }
            else
            {
                GUILayout.BeginHorizontal();
                fireEffectProperties.muzzleFlash = (ParticleSystem)EditorGUILayout.ObjectField(ContentProperties.MuzzleFlash, fireEffectProperties.muzzleFlash, typeof(ParticleSystem), true);
                if (SearchButton())
                {
                    ParticleSystem muzzleFlash = UEditorInternal.FindMuzzleFlash(instance.transform);
                    if (muzzleFlash != null)
                    {
                        fireEffectProperties.muzzleFlash = muzzleFlash;
                    }
                    else
                    {
                        UDisplayDialogs.Message("Searching", "Muzzle Flash not found, try find it manually.");
                    }
                }
                GUILayout.EndHorizontal();
            }

            if (fireEffectProperties.cartridgeEjection != null)
            {
                fireEffectProperties.cartridgeEjection = (ParticleSystem)EditorGUILayout.ObjectField(ContentProperties.CartridgeEjection, fireEffectProperties.cartridgeEjection, typeof(ParticleSystem), true);
            }
            else
            {
                GUILayout.BeginHorizontal();
                fireEffectProperties.cartridgeEjection = (ParticleSystem)EditorGUILayout.ObjectField(ContentProperties.CartridgeEjection, fireEffectProperties.cartridgeEjection, typeof(ParticleSystem), true);
                if (SearchButton())
                {
                    ParticleSystem cartridgeEjection = UEditorInternal.FindCartridgeEjection(instance.transform);
                    if (cartridgeEjection != null)
                    {
                        fireEffectProperties.cartridgeEjection = cartridgeEjection;
                    }
                    else
                    {
                        UDisplayDialogs.Message("Searching", "Cartridge Ejection not found, try find it manually.");
                    }
                }
                GUILayout.EndHorizontal();
            }
            instance.SetFireEffects(fireEffectProperties);


            GUILayout.Space(10);
            GUILayout.Label(ContentProperties.SoundProperties, UEditorStyles.SectionHeaderLabel);
            GUILayout.Space(7);
            BeginSubBox();
            GUILayout.Space(3);
            IncreaseIndentLevel();
            shootSoundsFoldout = EditorGUILayout.Foldout(shootSoundsFoldout, ContentProperties.ShootSound, true);
            if (shootSoundsFoldout)
            {
                if (instance.GetSoundProperties().GetFireSounds() == null || instance.GetSoundProperties().GetFireSoundsCount() == 0)
                {
                    UEditorHelpBoxMessages.Tip("Fire sounds is empty!", "Add new fire sound by click on [Add] button.", true);
                }
                else
                {
                    for (int i = 0; i < instance.GetSoundProperties().GetFireSoundsCount(); i++)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Space(3);
                        GUILayout.Label("Clip " + (i + 1), GUILayout.Width(35));
                        instance.GetSoundProperties().SetFireSound(i, (AudioClip)EditorGUILayout.ObjectField(instance.GetSoundProperties().GetFireSound(i), typeof(AudioClip), true));
                        if (GUILayout.Button("", GUI.skin.GetStyle("OL Minus"), GUILayout.Width(20)))
                        {
                            shootSounds.DeleteArrayElementAtIndex(i);
                        }
                        GUILayout.Space(3);
                        GUILayout.EndHorizontal();
                    }
                }
                GUILayout.Space(3);
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button(" Add "))
                {
                    shootSounds.arraySize++;
                }
                GUILayout.Space(3);
                GUILayout.EndHorizontal();
            }
            GUILayout.Space(3);
            EndSubBox();

            BeginSubBox();
            GUILayout.Space(3);
            emptySoundsFoldout = EditorGUILayout.Foldout(emptySoundsFoldout, ContentProperties.EmptySound, true);
            if (emptySoundsFoldout)
            {
                if (instance.GetSoundProperties().GetEmptySounds() == null || instance.GetSoundProperties().GetEmptySoundsCount() == 0)
                {
                    UEditorHelpBoxMessages.Tip("Empty sounds is empty!", "Add new empty sound by click on [Add] button.", true);
                }
                else
                {
                    for (int i = 0; i < instance.GetSoundProperties().GetEmptySoundsCount(); i++)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Space(3);
                        GUILayout.Label("Clip " + (i + 1), GUILayout.Width(35));
                        instance.GetSoundProperties().SetEmptySound(i, (AudioClip)EditorGUILayout.ObjectField(instance.GetSoundProperties().GetEmptySound(i), typeof(AudioClip), true));
                        if (GUILayout.Button("", GUI.skin.GetStyle("OL Minus"), GUILayout.Width(20)))
                        {
                            emptySounds.DeleteArrayElementAtIndex(i);
                        }
                        GUILayout.Space(3);
                        GUILayout.EndHorizontal();
                    }
                }
                GUILayout.Space(3);
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button(" Add "))
                {
                    emptySounds.arraySize++;
                }
                GUILayout.Space(3);
                GUILayout.EndHorizontal();
            }
            GUILayout.Space(3);
            EndSubBox();

            GUILayout.Space(10);
            GUILayout.Label(ContentProperties.AdditionalSystem, UEditorStyles.SectionHeaderLabel);
            GUILayout.Space(7);
            BeginSubBox();
            GUILayout.Space(3);
            weaponSpreadSystemFoldout = EditorGUILayout.Foldout(weaponSpreadSystemFoldout, ContentProperties.WeaponSpreadProperties, true);
            if (weaponSpreadSystemFoldout)
            {
                instance.SetSpreadProperties((SpreadProperties)EditorGUILayout.ObjectField(ContentProperties.SpreadProperties, instance.GetSpreadProperties(), typeof(SpreadProperties), true));
                if (instance.GetSpreadProperties() == null)
                {
                    UEditorHelpBoxMessages.Message("Spread properties is empty!\nWeapon won't have a bullet spread and camera shake while shoothing!", MessageType.Warning, true);
                }
            }
            GUILayout.Space(3);
            EndSubBox();
            DecreaseIndentLevel();
            EndBox();
        }