/// <summary>
        /// Create new weapon by properties.
        /// </summary>
        private static GameObject CreateFPWeapon(WeaponProperties properties)
        {
            // Initialize gameobjects.
            GameObject weapon = GameObject.Instantiate <GameObject>(properties.GetWeapon(), Vector3.zero, Quaternion.identity);

            weapon.name  = properties.GetName();
            weapon.tag   = TNC.WEAPON;
            weapon.layer = LayerMask.NameToLayer(LNC.WEAPON);
            for (int i = 0, length = weapon.transform.childCount; i < length; i++)
            {
                weapon.transform.GetChild(i).gameObject.layer = LayerMask.NameToLayer(LNC.WEAPON);
            }

            // Initialize weapon components.
            Animator              animator              = UEditorInternal.AddComponent <Animator>(weapon);
            WeaponIdentifier      weaponIdentifier      = UEditorInternal.AddComponent <WeaponIdentifier>(weapon);
            WeaponAnimationSystem weaponAnimationSystem = UEditorInternal.AddComponent <WeaponAnimationSystem>(weapon);

            switch (properties.GetWeaponType())
            {
            case WeaponProperties.Type.Gun:
            {
                WeaponShootingSystem weaponShootingSystem = UEditorInternal.AddComponent <WeaponShootingSystem>(weapon);
                WeaponReloadSystem   weaponReloadSystem   = UEditorInternal.AddComponent <WeaponReloadSystem>(weapon);
                break;
            }

            case WeaponProperties.Type.Melee:
            {
                WeaponMeleeSystem weaponMeleeSystem = UEditorInternal.AddComponent <WeaponMeleeSystem>(weapon);
                break;
            }

            case WeaponProperties.Type.Throw:
            {
                ThrowingWeaponSystem throwingWeaponSystem = UEditorInternal.AddComponent <ThrowingWeaponSystem>(weapon);
                WeaponReloadSystem   weaponReloadSystem   = UEditorInternal.AddComponent <WeaponReloadSystem>(weapon);
                break;
            }
            }
            AudioSource audioSource = UEditorInternal.AddComponent <AudioSource>(weapon);

            // Setup Animator component.
            if (properties.GetController() != null)
            {
                animator.runtimeAnimatorController = properties.GetController();
            }

            // Setup WeaponID component.
            if (properties.GetWeaponID() != null)
            {
                weaponIdentifier.SetWeapon(properties.GetWeaponID());
            }

            // Apply components position.
            UEditorInternal.MoveComponentBottom <Animator>(weapon.transform);
            UEditorInternal.MoveComponentBottom <WeaponIdentifier>(weapon.transform);
            UEditorInternal.MoveComponentBottom <WeaponAnimationSystem>(weapon.transform);
            switch (properties.GetWeaponType())
            {
            case WeaponProperties.Type.Gun:
            {
                UEditorInternal.MoveComponentBottom <WeaponShootingSystem>(weapon.transform);
                UEditorInternal.MoveComponentBottom <WeaponReloadSystem>(weapon.transform);
                break;
            }

            case WeaponProperties.Type.Melee:
            {
                UEditorInternal.MoveComponentBottom <WeaponMeleeSystem>(weapon.transform);
                break;
            }

            case WeaponProperties.Type.Throw:
            {
                UEditorInternal.MoveComponentBottom <ThrowingWeaponSystem>(weapon.transform);
                UEditorInternal.MoveComponentBottom <WeaponReloadSystem>(weapon.transform);
                break;
            }
            }
            for (int i = 0, length = additionalComponents.Count; i < length; i++)
            {
                AdditionalComponents component = additionalComponents[i];
                if (component.isActive)
                {
                    weapon.AddComponent(component.component);
                }
            }
            UEditorInternal.MoveComponentBottom <AudioSource>(weapon.transform);

            return(weapon);
        }
        private static void DrawFPWeaponGUI()
        {
            GUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.Space(5);
            GUILayout.Label(ContentProperties.BaseOptions, UEditorStyles.SectionHeaderLabel);
            GUILayout.Space(7);
            properties.SetName(EditorGUILayout.TextField(ContentProperties.WeaponName, properties.GetName()));
            properties.SetWeaponType((WeaponProperties.Type)EditorGUILayout.EnumPopup(ContentProperties.WeaponType, properties.GetWeaponType()));
            properties.SetWeapon(UEditor.ObjectField <GameObject>(ContentProperties.WeaponObject, properties.GetWeapon(), true));
            if (properties.GetWeapon() == null)
            {
                UEditorHelpBoxMessages.Error("Weapon model cannot be empty!", "Add weapon model.");
            }

            properties.SetWeaponID(UEditor.ObjectField <WeaponID>(ContentProperties.WeaponID, properties.GetWeaponID(), true));

            properties.SetController(UEditor.ObjectField <RuntimeAnimatorController>(ContentProperties.WeaponAnimator, properties.GetController(), false));
            GUILayout.Space(10);
            additionalComponentsRL.DoLayoutList();

            GUILayout.Space(5);
            UEditor.HorizontalLine();
            GUILayout.Space(5);

            EditorGUI.BeginDisabledGroup(!properties.NameIsValid() || properties.GetWeapon() == null);
            if (UEditor.Button("Create", "Right", GUILayout.Width(70)))
            {
                weapon = CreateFPWeapon(properties);
            }
            EditorGUI.EndDisabledGroup();

            if (weapon != null && delay.WaitForSeconds())
            {
                if (UDisplayDialogs.Message("Create Successful", "Weapon was created on scene!\nSetup weapon components before start play.", "Select", "Ok"))
                {
                    Selection.activeGameObject = weapon;
                }
                weapon = null;
            }

            GUILayout.Space(5);
            GUILayout.EndVertical();
        }