Example #1
0
        public void CreateNewIKAdjustList(vIShooterIKController targetShooterManager)
        {
            vWeaponIKAdjustList ikAdjust = ScriptableObject.CreateInstance <vWeaponIKAdjustList>();

            AssetDatabase.CreateAsset(ikAdjust, "Assets/" + ikController.gameObject.name + "@IKAdjustList.asset");

            targetShooterManager.WeaponIKAdjustList = ikAdjust;
            ikList = new SerializedObject(ikAdjust);
            ikList.ApplyModifiedProperties();
            AssetDatabase.SaveAssets();
            EditorUtility.SetDirty(ikList.targetObject);
        }
Example #2
0
        //public void OnSceneGUI()
        //{
        //    DrawSceneGizmos();
        //}

        void Update()
        {
            this.minSize = new Vector2(300, 300);
            if (EditorApplication.isPlaying && !EditorApplication.isPaused)
            {
                if (curWindow == null)
                {
                    curWindow = this;
                }

                if (Selection.activeTransform && (ikController == null || (Selection.activeGameObject != ikController.gameObject && Selection.activeTransform.GetComponent <vIShooterIKController>() != null)))
                {
                    ikController = Selection.activeGameObject.GetComponent <vIShooterIKController>();
                }
                Repaint();
            }
        }
Example #3
0
        void OnGUI()
        {
            GUILayout.BeginVertical(skin.GetStyle("WindowBG"));

            if (!Application.isPlaying)
            {
                DrawMessageInfo("Go to <color=green>PlayMode</color> to edit the IK Adjust List", "PlayModeIcon");
                ikController = null;
                return;
            }
            if (ikController == null)
            {
                DrawMessageInfo("Select a <color=green>Shooter Controller</color>", "ShooterControllerIcon");
                return;
            }

            if (!ikController.CurrentActiveWeapon)
            {
                DrawMessageInfo("Shooter Controller Doesn't have a <color=green>Active Weapon</color>", "WeaponIcon");
                return;
            }

            if (skin == null)
            {
                skin = Resources.Load("vSkin") as GUISkin;
            }

            scroll = EditorGUILayout.BeginScrollView(scroll);
            {
                {
                    if (ikController.WeaponIKAdjustList)
                    {
                        if (ikList == null || ikList.targetObject != ikController.WeaponIKAdjustList)
                        {
                            ikList = new SerializedObject(ikController.WeaponIKAdjustList);
                        }
                        if (ikList != null)
                        {
                            ikList.UpdateIfRequiredOrScript();
                        }

                        var weaponIKAdjustList = ikController.WeaponIKAdjustList;
                        EditorGUI.BeginChangeCheck();
                        weaponIKAdjustList = (vWeaponIKAdjustList)EditorGUILayout.ObjectField(weaponIKAdjustList, typeof(vWeaponIKAdjustList), false);

                        if (EditorGUI.EndChangeCheck())
                        {
                            ikController.WeaponIKAdjustList = weaponIKAdjustList;
                            ikController.SetIKAdjust(weaponIKAdjustList.GetWeaponIK(ikController.CurrentActiveWeapon.weaponCategory));
                            return;
                        }

                        EditorGUI.BeginChangeCheck();
                        string stateTag = ikController.IsCrouching ? "Crouching " : "Standing ";
                        if (ikController.IsAiming)
                        {
                            stateTag += "Aiming";
                        }
                        GUILayout.Box("State : " + stateTag + " / " + ikController.CurrentActiveWeapon.weaponCategory + " Category", skin.box, GUILayout.ExpandWidth(true));

                        if (GUILayout.Button(ikController.LockAiming ? "Unlock Aim" : "Lock Aim", EditorStyles.miniButton))
                        {
                            ikController.LockAiming = !ikController.LockAiming;
                        }

                        if (GUILayout.Button(ikController.IsCrouching ? "Unlock Crouch" : "Lock Crouch", EditorStyles.miniButton))
                        {
                            ikController.IsCrouching = !ikController.IsCrouching;
                        }

                        if (useLockCamera && GUILayout.Button(LockCamera ? "Unlock Camera" : "Lock Camera", EditorStyles.miniButton))
                        {
                            LockCamera = !LockCamera;
                        }

                        if (ikController.CurrentWeaponIK)
                        {
                            if (ik == null || ik.targetObject != ikController.CurrentWeaponIK)
                            {
                                ik = new SerializedObject(ikController.CurrentWeaponIK);
                            }
                            ik.Update();
                            try
                            {
                                GUILayout.Space(20);
                                DrawWeaponIKSettings(ikController.CurrentWeaponIK);
                                GUILayout.Space(20);
                                DrawLeftIKOffsets();
                                GUILayout.Space(20);
                            }
                            catch { }
                        }
                        else
                        {
                            EditorStyles.helpBox.richText = true;
                            EditorGUILayout.HelpBox("This weapon doesn't have a IKAdjust for the '" + ikController.CurrentActiveWeapon.weaponCategory + "' category,  click in the button below to create one.", MessageType.Info);
                            if (GUILayout.Button("Create New IK Adjust", skin.button))
                            {
                                vWeaponIKAdjust ikAdjust = ScriptableObject.CreateInstance <vWeaponIKAdjust>();
                                AssetDatabase.CreateAsset(ikAdjust, "Assets/" + ikController.gameObject.name + "@" + ikController.CurrentActiveWeapon.weaponCategory + ".asset");
                                ikAdjust.weaponCategories = new List <string>()
                                {
                                    ikController.CurrentActiveWeapon.weaponCategory
                                };

                                ikController.WeaponIKAdjustList.weaponIKAdjusts.Add(ikAdjust);
                                ikController.SetIKAdjust(ikAdjust);

                                SerializedObject scriptableIK = new SerializedObject(ikAdjust);
                                scriptableIK.ApplyModifiedProperties();
                                ikList.ApplyModifiedProperties();
                                EditorUtility.SetDirty(ikList.targetObject);
                                AssetDatabase.SaveAssets();
                                EditorUtility.SetDirty(scriptableIK.targetObject);
                            }
                            if (GUILayout.Button("Choose IK Adjust", skin.button))
                            {
                                var action = new UnityEngine.Events.UnityAction <vWeaponIKAdjust>((ikAdjust) =>
                                {
                                    ikController.WeaponIKAdjustList.weaponIKAdjusts.Add(ikAdjust);
                                    ikController.SetIKAdjust(ikAdjust);

                                    ikList.ApplyModifiedProperties();
                                    EditorUtility.SetDirty(ikList.targetObject);
                                });

                                PopupWindow.Show(selectorRect, new vIKAjustSelector(ikController.CurrentActiveWeapon.weaponCategory, action, skin));
                            }
                            if (Event.current.type == EventType.Repaint)
                            {
                                selectorRect = GUILayoutUtility.GetLastRect();
                            }
                            ikController.LoadIKAdjust(ikController.CurrentActiveWeapon.weaponCategory);
                        }
                        if (EditorGUI.EndChangeCheck())
                        {
                            if (ikList != null)
                            {
                                ikList.ApplyModifiedProperties();
                                EditorUtility.SetDirty(ikList.targetObject);
                            }
                        }
                    }
                    else
                    {
                        GUILayout.FlexibleSpace();
                        GUILayout.Label("You need to assign a <color=green>IK Adjust List</color> in the ShooterManager First!", skin.GetStyle("SuperTitle"));
                    }
                }
                GUILayout.Space(20);
            }

            EditorGUILayout.EndScrollView();
            GUILayout.FlexibleSpace(); GUILayout.EndVertical();
        }