예제 #1
0
        /// <summary>
        /// Remove the hitbox at the list index.
        /// </summary>
        public static void OnHitboxListRemove(IMeleeWeaponPerspectiveProperties meleePerspective, ReorderableList list, string selectedKey)
        {
            var hitboxes = new List <MeleeWeapon.MeleeHitbox>(meleePerspective.Hitboxes);

            // Remove the element.
            InspectorUtility.RecordUndoDirtyObject(meleePerspective as UnityEngine.Object, "Change Value");
            hitboxes.RemoveAt(list.index);
            list.list = meleePerspective.Hitboxes = hitboxes.ToArray();

            // Update the index to point to no longer point to the now deleted view type.
            list.index = list.index - 1;
            if (list.index == -1 && hitboxes.Count > 0)
            {
                list.index = 0;
            }
            EditorPrefs.SetInt(selectedKey, list.index);
            InspectorUtility.SetDirty(meleePerspective as UnityEngine.Object);
        }
예제 #2
0
        /// <summary>
        /// Draws the specified hitbox.
        /// </summary>
        public static void DrawSelectedHitbox(IMeleeWeaponPerspectiveProperties meleePerspective, SerializedProperty hitboxProperty)
        {
            EditorGUI.BeginChangeCheck();

            EditorGUILayout.PropertyField(hitboxProperty.FindPropertyRelative("m_Collider"));
            if (hitboxProperty.FindPropertyRelative("m_Collider").objectReferenceValue == null)
            {
                EditorGUILayout.PropertyField(hitboxProperty.FindPropertyRelative("m_ColliderObjectID"));
            }
            EditorGUILayout.PropertyField(hitboxProperty.FindPropertyRelative("m_DamageMultiplier"));
            EditorGUILayout.PropertyField(hitboxProperty.FindPropertyRelative("m_MinimumYOffset"));
            EditorGUILayout.PropertyField(hitboxProperty.FindPropertyRelative("m_MinimumZOffset"));
            EditorGUILayout.PropertyField(hitboxProperty.FindPropertyRelative("m_SingleHit"));
            EditorGUILayout.PropertyField(hitboxProperty.FindPropertyRelative("m_SurfaceImpact"));

            if (EditorGUI.EndChangeCheck())
            {
                hitboxProperty.serializedObject.ApplyModifiedProperties();
                InspectorUtility.RecordUndoDirtyObject(meleePerspective as UnityEngine.Object, "Change Value");
            }
        }
예제 #3
0
        /// <summary>
        /// Adds a new hitbox to the list.
        /// </summary>
        public static void OnHitboxListAdd(IMeleeWeaponPerspectiveProperties meleePerspective, ReorderableList list, string selectedKey)
        {
            var hitboxes = meleePerspective.Hitboxes;

            if (hitboxes == null)
            {
                hitboxes = new MeleeWeapon.MeleeHitbox[1];
            }
            else
            {
                Array.Resize(ref hitboxes, hitboxes.Length + 1);
            }

            var hitbox = new MeleeWeapon.MeleeHitbox();

            hitboxes[hitboxes.Length - 1] = hitbox;
            meleePerspective.Hitboxes     = hitboxes;

            // Select the newly added hitbox.
            list.list  = meleePerspective.Hitboxes;
            list.index = hitboxes.Length - 1;
            EditorPrefs.SetInt(selectedKey, list.index);
            InspectorUtility.SetDirty(meleePerspective as UnityEngine.Object);
        }