Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Help going mad - `WeaponScript' is defined multiple times

Discussion in 'Scripting' started by jf3000, Apr 22, 2014.

  1. jf3000

    jf3000

    Joined:
    Dec 31, 2013
    Posts:
    166
    Firstly I am no programmer. I am clueless with this as it was working now its spitting this error at me:

    Code (csharp):
    1. Assets/FPS Kit 2.0 C#/_CustomAssets/Scripts/WeaponSystem/Editor/WeaponScriptEditor.cs(6,23): error CS0433: The imported type `WeaponScript' is defined multiple times
    2.  
    What exactly does that error mean in the simplest of terms please. Here is the cs file for the above

    Code (csharp):
    1. //NSdesignGames @ 2012 - 2014
    2. //FPS Kit | Version 2.0
    3.  
    4. using UnityEditor;
    5.  
    6. [CustomEditor (typeof(WeaponScript))]
    7.  
    8. public class WeaponScriptEditor : Editor {
    9.  
    10.     public override void OnInspectorGUI() {
    11.  
    12.         //WeaponScript script = target as WeaponScript;
    13.         WeaponScript script = (WeaponScript) target;
    14.         bool allowSceneObjects = !EditorUtility.IsPersistent(script);
    15.  
    16.         script.GunType = (WeaponScript.gunType)EditorGUILayout.EnumPopup(" Gun Type:", script.GunType);
    17.         //EditorGUILayout.PropertyField(script.GunType);
    18.         script.weaponName = EditorGUILayout.TextField(" Weapon Name:", script.weaponName);
    19.  
    20.         if(script.GunType != WeaponScript.gunType.KNIFE){
    21.             script.singleFire = EditorGUILayout.Toggle(" Single Fire:  ", script.singleFire);
    22.             script.Recoil = EditorGUILayout.Toggle(" Recoil:  ", script.Recoil);
    23.         }
    24.        
    25.         if(script.GunType != WeaponScript.gunType.KNIFE){
    26.             EditorGUILayout.Space();
    27.             EditorGUILayout.LabelField("", "Aim properties", "button");
    28.             //Aim variables
    29.             script.Aim.aimPosition = EditorGUILayout.Vector3Field (" Aim Position:", script.Aim.aimPosition);
    30.             script.Aim.smoothTime = EditorGUILayout.Slider(" Aim Time:", script.Aim.smoothTime, 0, 1);
    31.             script.Aim.toFov = EditorGUILayout.IntSlider(" Aim Fov:", script.Aim.toFov, 5, 60);
    32.             script.Aim.aimBobbingAmount = EditorGUILayout.FloatField(" Aim Sway:", script.Aim.aimBobbingAmount );
    33.             script.Aim.playAnimation = EditorGUILayout.Toggle(" Play Animation:", script.Aim.playAnimation);
    34.         }
    35.  
    36.         //Grenade launcher
    37.         if(script.GunType == WeaponScript.gunType.GRENADE_LAUNCHER){
    38.             EditorGUILayout.Space();
    39.             EditorGUILayout.LabelField("", "Grenade launcher properties", "button");
    40.             script.firePoint = EditorGUILayout.ObjectField(" Fire Point:", script.firePoint, typeof(UnityEngine.Transform), allowSceneObjects) as UnityEngine.Transform;
    41.             script.grenadeLauncher.projectile = EditorGUILayout.ObjectField(" Projectile: ", script.grenadeLauncher.projectile, typeof(UnityEngine.Rigidbody), allowSceneObjects) as UnityEngine.Rigidbody;
    42.             script.grenadeLauncher.fireSound = EditorGUILayout.ObjectField(" Fire Sound: ", script.grenadeLauncher.fireSound, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
    43.             script.grenadeLauncher.reloadSound = EditorGUILayout.ObjectField(" Reload Sound: ", script.grenadeLauncher.reloadSound, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
    44.             script.grenadeLauncher.initialSpeed = EditorGUILayout.IntSlider(" Initial Speed:", script.grenadeLauncher.initialSpeed, 1, 80);
    45.             script.grenadeLauncher.shotDelay = EditorGUILayout.FloatField(" Shot Delay:", script.grenadeLauncher.shotDelay);
    46.             script.grenadeLauncher.waitBeforeReload = EditorGUILayout.FloatField(" Wait Before Reload:", script.grenadeLauncher.waitBeforeReload);
    47.             script.grenadeLauncher.reloadTime = EditorGUILayout.FloatField(" Reload Time:", script.grenadeLauncher.reloadTime);
    48.             script.grenadeLauncher.ammoCount = EditorGUILayout.IntSlider(" Ammo Count:", script.grenadeLauncher.ammoCount, 0, 999);
    49.         }
    50.  
    51.         if(script.GunType == WeaponScript.gunType.MACHINE_GUN){
    52.             EditorGUILayout.Space();
    53.         //Machine gun
    54.             EditorGUILayout.LabelField("", "Machine gun properties", "button");
    55.             script.firePoint = EditorGUILayout.ObjectField(" Fire Point:", script.firePoint, typeof(UnityEngine.Transform), allowSceneObjects) as UnityEngine.Transform;
    56.             script.machineGun.bullet = EditorGUILayout.ObjectField(" Bullet: ", script.machineGun.bullet, typeof(UnityEngine.Transform), allowSceneObjects) as UnityEngine.Transform;
    57.             script.machineGun.muzzleFlash = EditorGUILayout.ObjectField(" Muzzle Flash:", script.machineGun.muzzleFlash, typeof(UnityEngine.GameObject), allowSceneObjects) as UnityEngine.GameObject;
    58.             script.machineGun.fireSound = EditorGUILayout.ObjectField(" Fire Sound: ", script.machineGun.fireSound, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
    59.             script.machineGun.reloadSound = EditorGUILayout.ObjectField(" Reload Sound: ", script.machineGun.reloadSound, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
    60.             script.machineGun.pointLight = EditorGUILayout.ObjectField(" Muzzle Light:", script.machineGun.pointLight, typeof(UnityEngine.Light), allowSceneObjects) as UnityEngine.Light;
    61.             script.machineGun.fireRate = EditorGUILayout.FloatField(" Fire Rate:  ", script.machineGun.fireRate);
    62.             script.machineGun.bulletsPerClip = EditorGUILayout.IntSlider( " Bullets Per Clip:", script.machineGun.bulletsPerClip, 0, 999);
    63.             script.machineGun.clips = EditorGUILayout.IntSlider( " Total Bullets:", script.machineGun.clips, 0, 999);
    64.             script.machineGun.bulletsLeft = EditorGUILayout.IntSlider( " Current Ammo:", script.machineGun.bulletsLeft, 0, script.machineGun.bulletsPerClip);
    65.             script.machineGun.reloadTime = EditorGUILayout.FloatField(" Reload Time:  ", script.machineGun.reloadTime);
    66.             script.machineGun.NoAimErrorAngle = EditorGUILayout.Slider( " No Aim Error Angle:", script.machineGun.NoAimErrorAngle, 0, 10);
    67.             script.machineGun.AimErrorAngle = EditorGUILayout.Slider( " Aim Error Angle:", script.machineGun.AimErrorAngle, 0, 3);
    68.         }
    69.        
    70.         if(script.GunType == WeaponScript.gunType.SHOTGUN){
    71.             EditorGUILayout.Space();
    72.         //Shotgun
    73.             EditorGUILayout.LabelField("", "Shotgun properties", "button");
    74.             script.firePoint = EditorGUILayout.ObjectField(" Fire Point:", script.firePoint, typeof(UnityEngine.Transform), allowSceneObjects) as UnityEngine.Transform;
    75.             script.ShotGun.bullet = EditorGUILayout.ObjectField(" Bullet: ", script.ShotGun.bullet, typeof(UnityEngine.Transform), allowSceneObjects) as UnityEngine.Transform;
    76.             script.ShotGun.fireSound = EditorGUILayout.ObjectField(" Fire Sound: ", script.ShotGun.fireSound, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
    77.             script.ShotGun.reloadSound = EditorGUILayout.ObjectField(" Reload Sound: ", script.ShotGun.reloadSound, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
    78.             script.ShotGun.smoke = EditorGUILayout.ObjectField(" Smoke:", script.ShotGun.smoke, typeof(UnityEngine.ParticleEmitter), allowSceneObjects) as UnityEngine.ParticleEmitter;
    79.             script.ShotGun.fractions = EditorGUILayout.IntSlider( " Fractions:", script.ShotGun.fractions, 2, 8);
    80.             script.ShotGun.errorAngle = EditorGUILayout.Slider( " Error Angle:", script.ShotGun.errorAngle, 2, 10);
    81.             script.ShotGun.fireRate = EditorGUILayout.FloatField(" Fire Rate:  ", script.ShotGun.fireRate);
    82.             script.ShotGun.reloadTime = EditorGUILayout.FloatField(" Reload Time:  ", script.ShotGun.reloadTime);
    83.             script.ShotGun.bulletsPerClip = EditorGUILayout.IntSlider( " Bullets Per Clip:", script.ShotGun.bulletsPerClip, 0, 20);
    84.             script.ShotGun.bulletsLeft = EditorGUILayout.IntSlider( " Current Ammo:", script.ShotGun.bulletsLeft, 0, script.ShotGun.bulletsPerClip);
    85.             script.ShotGun.clips = EditorGUILayout.IntSlider( " Total Bullets:", script.ShotGun.clips, 0, 999);
    86.         }
    87.        
    88.         if(script.GunType == WeaponScript.gunType.KNIFE){
    89.             EditorGUILayout.Space();
    90.         //Knife
    91.             EditorGUILayout.LabelField("", "Knife properties", "button");  
    92.             script.knife.bullet = EditorGUILayout.ObjectField(" Bullet: ", script.knife.bullet, typeof(UnityEngine.Transform), allowSceneObjects) as UnityEngine.Transform;
    93.             script.knife.fireSound = EditorGUILayout.ObjectField(" Fire Sound: ", script.knife.fireSound, typeof(UnityEngine.AudioClip), allowSceneObjects) as UnityEngine.AudioClip;
    94.             script.knife.fireRate = EditorGUILayout.FloatField(" Fire Rate:  ", script.knife.fireRate);
    95.             script.knife.delayTime = EditorGUILayout.FloatField(" Delay Time:  ", script.knife.delayTime);
    96.         }
    97.        
    98.         EditorGUILayout.Space();
    99.         EditorGUILayout.LabelField("", "Rotation realism", "button");
    100.         script.RotRealism.RotationAmplitude = EditorGUILayout.IntSlider( " Rotation Amplitude:", script.RotRealism.RotationAmplitude, 0, 8);
    101.         script.RotRealism.smooth = EditorGUILayout.IntSlider( " Smooth:", script.RotRealism.smooth, 0, 10);
    102.        
    103.         EditorGUILayout.Space();
    104.         EditorGUILayout.LabelField("", "Smooth move", "button");
    105.         script.SmoothMovement.Smooth = EditorGUILayout.IntSlider( " Smooth:", script.SmoothMovement.Smooth, 0, 10);
    106.         script.SmoothMovement.maxAmount = EditorGUILayout.Slider(" Move Responce:  ", script.SmoothMovement.maxAmount, 0, 1);
    107.        
    108.         if(script.Recoil == true){
    109.             EditorGUILayout.Space();
    110.             EditorGUILayout.LabelField("", "Main camera recoil effect", "button");
    111.             script.CameraRecoil.recoilPower = EditorGUILayout.FloatField(" Recoil Power:  ", script.CameraRecoil.recoilPower);
    112.             script.CameraRecoil.shakeAmount = EditorGUILayout.FloatField(" Shake Amount:  ", script.CameraRecoil.shakeAmount);
    113.             script.CameraRecoil.smooth = EditorGUILayout.IntSlider( " Smooth:", script.CameraRecoil.smooth, 0, 20);
    114.         }
    115.         /*if (GUI.changed){
    116.             EditorUtility.SetDirty (script);
    117.         }*/
    118.     }
    119. }
    120.  
    Thank you for your patience.
     
  2. Epictickle

    Epictickle

    Joined:
    Aug 12, 2012
    Posts:
    431
    Search your project for "WeaponScript" and make sure it wasn't accidentally duplicated. If there are two instances of it, delete one.
     
  3. JackofTraes

    JackofTraes

    Joined:
    May 28, 2014
    Posts:
    10
    This helped me, thank you!