private void OnEnable() { script = (bl_WeaponAnimation)target; Gun = script.transform.parent.GetComponent <bl_Gun>(); gType = bl_GameData.Instance.GetWeapon(Gun.GunID).Type; if (script.m_AnimationType == bl_WeaponAnimation.AnimationType.Animator) { _animator = script.GetComponent <Animator>(); } list = new ReorderableList(serializedObject, serializedObject.FindProperty("FireAnimations"), true, true, true, true); list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { var element = list.serializedProperty.GetArrayElementAtIndex(index); rect.y += 2; EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight), element, GUIContent.none); }; list.drawHeaderCallback = (Rect rect) => { EditorGUI.LabelField(rect, "Fire Animations"); }; }
void AnimatorGUI() { if (_animator == null) { _animator = script.GetComponent <Animator>(); if (_animator == null) { EditorGUILayout.HelpBox("This weapon don't have a Animator Component!", MessageType.Warning); return; } } if (_animator.runtimeAnimatorController == null) { EditorGUILayout.HelpBox("The animator for this weapons has not been assigned yet, if you already have it, assign it in the Animator Component, otherwise you can create it here," + "simply draw the AnimationClips in the respective field below and click in the button SetUp", MessageType.Info); GUILayout.BeginVertical("box"); script.DrawName = EditorGUILayout.ObjectField("Draw Animation", script.DrawName, typeof(AnimationClip), allowSceneObjects) as AnimationClip; script.TakeOut = EditorGUILayout.ObjectField("Hide Animation", script.TakeOut, typeof(AnimationClip), allowSceneObjects) as AnimationClip; script.SoloFireClip = EditorGUILayout.ObjectField("Fire Animation", script.SoloFireClip, typeof(AnimationClip), allowSceneObjects) as AnimationClip; script.FireAimAnimation = EditorGUILayout.ObjectField("Aim Fire Animation", script.FireAimAnimation, typeof(AnimationClip), allowSceneObjects) as AnimationClip; if (gType != GunType.Knife) { if ((gType == GunType.Shotgun || gType == GunType.Sniper) && Gun.SplitReloadAnimation) { script.StartReloadAnim = EditorGUILayout.ObjectField("Begin Reload", script.StartReloadAnim, typeof(AnimationClip), allowSceneObjects) as AnimationClip; script.InsertAnim = EditorGUILayout.ObjectField("Insert Reload", script.InsertAnim, typeof(AnimationClip), allowSceneObjects) as AnimationClip; script.AfterReloadAnim = EditorGUILayout.ObjectField("After Reload", script.AfterReloadAnim, typeof(AnimationClip), allowSceneObjects) as AnimationClip; } else { script.ReloadName = EditorGUILayout.ObjectField("Reload Animation", script.ReloadName, typeof(AnimationClip), allowSceneObjects) as AnimationClip; } } else { script.QuickFireAnim = EditorGUILayout.ObjectField("Quick Fire Animation", script.QuickFireAnim, typeof(AnimationClip), allowSceneObjects) as AnimationClip; } if (gType == GunType.Grenade) { script.QuickFireAnim = EditorGUILayout.ObjectField("Quick Fire Animation", script.QuickFireAnim, typeof(AnimationClip), allowSceneObjects) as AnimationClip; } script.IdleClip = EditorGUILayout.ObjectField("Idle Animation", script.IdleClip, typeof(AnimationClip), allowSceneObjects) as AnimationClip; script.AnimatedMovements = EditorGUILayout.ToggleLeft("Custom Animations For Movements", script.AnimatedMovements, EditorStyles.toolbarButton); if (script.AnimatedMovements) { GUILayout.Space(2); WalkAnim = EditorGUILayout.ObjectField("Walk Animation", WalkAnim, typeof(AnimationClip), allowSceneObjects) as AnimationClip; RunAnim = EditorGUILayout.ObjectField("Run Animation", RunAnim, typeof(AnimationClip), allowSceneObjects) as AnimationClip; } if (GUILayout.Button("SetUp", EditorStyles.toolbarButton)) { CreateAnimator(); } GUILayout.EndVertical(); } else { GUILayout.BeginHorizontal("box"); script.DrawName = EditorGUILayout.ObjectField("Draw Animation", script.DrawName, typeof(AnimationClip), allowSceneObjects) as AnimationClip; script.DrawSpeed = EditorGUILayout.Slider(script.DrawSpeed, 0.1f, 3, GUILayout.Width(125)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); script.TakeOut = EditorGUILayout.ObjectField("Hide Animation", script.TakeOut, typeof(AnimationClip), allowSceneObjects) as AnimationClip; script.HideSpeed = EditorGUILayout.Slider(script.HideSpeed, 0.1f, 3, GUILayout.Width(125)); GUILayout.EndHorizontal(); if (gType == GunType.Machinegun || gType == GunType.Pistol || gType == GunType.Burst) { GUILayout.BeginHorizontal("box"); script.SoloFireClip = EditorGUILayout.ObjectField("Fire Animation", script.SoloFireClip, typeof(AnimationClip), allowSceneObjects) as AnimationClip; script.FireSpeed = EditorGUILayout.Slider(script.FireSpeed, 0.1f, 3, GUILayout.Width(125)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); script.FireAimAnimation = EditorGUILayout.ObjectField("Aim Fire Animation", script.FireAimAnimation, typeof(AnimationClip), allowSceneObjects) as AnimationClip; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); script.ReloadName = EditorGUILayout.ObjectField("Reload Animation", script.ReloadName, typeof(AnimationClip), allowSceneObjects) as AnimationClip; GUILayout.EndHorizontal(); } else if (gType == GunType.Shotgun || gType == GunType.Sniper) { GUILayout.BeginHorizontal("box"); script.SoloFireClip = EditorGUILayout.ObjectField("Fire Animation", script.SoloFireClip, typeof(AnimationClip), allowSceneObjects) as AnimationClip; script.FireSpeed = EditorGUILayout.Slider(script.FireSpeed, 0.1f, 3, GUILayout.Width(125)); GUILayout.EndHorizontal(); script.FireAimAnimation = EditorGUILayout.ObjectField("Aim Fire Animation", script.FireAimAnimation, typeof(AnimationClip), allowSceneObjects) as AnimationClip; if (Gun.SplitReloadAnimation || gType == GunType.Shotgun) { GUILayout.BeginHorizontal("box"); script.StartReloadAnim = EditorGUILayout.ObjectField("Start Reload", script.StartReloadAnim, typeof(AnimationClip), allowSceneObjects) as AnimationClip; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); script.InsertAnim = EditorGUILayout.ObjectField("Insert Bullet", script.InsertAnim, typeof(AnimationClip), allowSceneObjects) as AnimationClip; script.InsertSpeed = EditorGUILayout.Slider(script.InsertSpeed, 0.1f, 3, GUILayout.Width(125)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); script.AfterReloadAnim = EditorGUILayout.ObjectField("End Reload", script.AfterReloadAnim, typeof(AnimationClip), allowSceneObjects) as AnimationClip; GUILayout.EndHorizontal(); } else { GUILayout.BeginHorizontal("box"); script.ReloadName = EditorGUILayout.ObjectField("Reload Animation", script.ReloadName, typeof(AnimationClip), allowSceneObjects) as AnimationClip; GUILayout.EndHorizontal(); } } else if (gType == GunType.Grenade) { GUILayout.BeginHorizontal("box"); script.SoloFireClip = EditorGUILayout.ObjectField("Fire Animation", script.SoloFireClip, typeof(AnimationClip), allowSceneObjects) as AnimationClip; script.FireSpeed = EditorGUILayout.Slider(script.FireSpeed, 0.1f, 3, GUILayout.Width(125)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); script.QuickFireAnim = EditorGUILayout.ObjectField("Quick Fire Animation", script.QuickFireAnim, typeof(AnimationClip), allowSceneObjects) as AnimationClip; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); script.ReloadName = EditorGUILayout.ObjectField("Reload Animation", script.ReloadName, typeof(AnimationClip), allowSceneObjects) as AnimationClip; GUILayout.EndHorizontal(); script.HasParticles = EditorGUILayout.ToggleLeft("Use Particles", script.HasParticles, EditorStyles.toolbarPopup); if (script.HasParticles) { script.ParticleRate = EditorGUILayout.Slider("Particle Rate", script.ParticleRate, 0.1f, 10); var prop = serializedObject.FindProperty("Particles"); serializedObject.Update(); EditorGUILayout.PropertyField(prop, true); serializedObject.ApplyModifiedProperties(); } GUILayout.Space(2); script.DrawAfterFire = EditorGUILayout.ToggleLeft("Draw After Fire", script.DrawAfterFire, EditorStyles.toolbarButton); } else if (gType == GunType.Knife) { GUILayout.BeginHorizontal("box"); script.FireAimAnimation = EditorGUILayout.ObjectField("Fire Animation", script.FireAimAnimation, typeof(AnimationClip), allowSceneObjects) as AnimationClip; script.FireSpeed = EditorGUILayout.Slider(script.FireSpeed, 0.1f, 3, GUILayout.Width(125)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); script.QuickFireAnim = EditorGUILayout.ObjectField("Quick Fire Animation", script.QuickFireAnim, typeof(AnimationClip), allowSceneObjects) as AnimationClip; GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal("box"); script.IdleClip = EditorGUILayout.ObjectField("Idle Animation", script.IdleClip, typeof(AnimationClip), allowSceneObjects) as AnimationClip; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box"); script.AnimatedMovements = EditorGUILayout.ToggleLeft("Custom Animations For Movements", script.AnimatedMovements, EditorStyles.toolbarButton); GUILayout.EndHorizontal(); } }