/// <summary> /// Finds your player and populates internal variables so the chatbox /// can enable or disable various aspects of your character when the /// box is open or closed. /// </summary> protected virtual void SetMyPlayer() { foreach (vThirdPersonController controller in FindObjectsOfType <vThirdPersonController>()) { if (controller.gameObject.GetComponent <PhotonView>().IsMine == true) { player = controller; if (player.GetComponent <vMeleeCombatInput>()) { meleeInput = player.GetComponent <vMeleeCombatInput>(); } if (player.GetComponent <vInventory>()) { playerInventory = player.GetComponent <vInventory>(); } if (!playerInventory && player.GetComponent <vItemManager>()) { playerInventory = player.GetComponent <vItemManager>().inventory; } break; } } orgCursorMode = Cursor.lockState; }
/// <summary> /// Disable the main menu and redraw the character display. /// </summary> void OnEnable() { // deactivate main menu if (ParentMenu) { ParentMenu.SetActive(false); } if (!ScreenDrawnAlready) { // draw the full display on first open #if !VANILLA control = GetComponentInParent <vInventory>(); #endif if (Header && AttributeIcon && AttributeName && AttributeValue) { DefHeaderTXT = Header.gameObject.GetComponent <Text>(); DefAttribTXT = AttributeName.gameObject.GetComponent <Text>(); DefValueTXT = AttributeValue.gameObject.GetComponent <Text>(); DefPlusTXT = AttributeSpendPlus.gameObject.GetComponent <Text>(); if (DefHeaderTXT && DefAttribTXT && DefValueTXT && DefPlusTXT) { GameObject player = GlobalFuncs.FindPlayerInstance(); if (player) { levelingSystem = player.GetComponent <CharacterBase>(); if (levelingSystem) { // all required components found, draw the stats with labels CurrentPane = -1; reDrawAttributes(); ScreenDrawnAlready = true; } else { if (GlobalFuncs.DEBUGGING_MESSAGES) { Debug.Log("Player Leveling System NOT found"); } } } else { if (GlobalFuncs.DEBUGGING_MESSAGES) { Debug.Log("Player NOT found"); } } } else { if (GlobalFuncs.DEBUGGING_MESSAGES) { Debug.Log("GUI Text component is required on the default header/attribute name objects"); } } } else { if (GlobalFuncs.DEBUGGING_MESSAGES) { Debug.Log("Default UI rect transforms NOT set"); } } } else { // already have the components reDrawAttributes(); } }
/// <summary> /// Occurs per frame for the unity inspector GUI /// </summary> void OnGUI() { // header if (!skin) { skin = Resources.Load("skin") as GUISkin; } GUI.skin = skin; this.minSize = rect; this.titleContent = new GUIContent("Shadex", null, "Create Magic Controller"); m_Logo = Resources.Load("icon_v2") as Texture2D; GUILayout.BeginVertical("Create Magic Controller", "window"); GUILayout.Label(m_Logo, GUILayout.MaxHeight(25)); GUILayout.Space(5); GUILayout.BeginVertical("box"); if (!bLoaded) { // fill conditions list Conditions = new List <BaseCondition>(); BaseDamage[] AllConditions = (BaseDamage[])Enum.GetValues(typeof(BaseDamage)); for (int i = 0; i < AllConditions.Length; i++) { if (AllConditions[i] != BaseDamage.Physical) { Conditions.Add(new BaseCondition() { Type = AllConditions[i], Display = AssetDatabase.LoadAssetAtPath("Assets/Invector-3rdPersonController/Add-ons/ShadesSpellSystem/Prefabs/Conditions/" + AllConditions[i].ToString() + ".prefab", typeof(GameObject)) as GameObject }); } } // standard invector components, grab prefabs if (File.Exists(Application.dataPath + "/Invector-3rdPersonController/Basic Locomotion/3D Models/Particles/DamageEffect/prefabs/bloodSplash.prefab")) { HitDamageParticle = AssetDatabase.LoadAssetAtPath("Assets/Invector-3rdPersonController/Basic Locomotion/3D Models/Particles/DamageEffect/prefabs/bloodSplash.prefab", typeof(GameObject)) as GameObject; } if (File.Exists(Application.dataPath + "/Invector-3rdPersonController/ItemManager/Prefabs/ItemCollectionDisplay.prefab")) { ItemCollectionDisplay = AssetDatabase.LoadAssetAtPath("Assets/Invector-3rdPersonController/ItemManager/Prefabs/ItemCollectionDisplay.prefab", typeof(GameObject)) as GameObject; } // spell system components, grab prefabs if (File.Exists(Application.dataPath + "/Invector-3rdPersonController/Add-ons/ShadesSpellSystem/Inventory/Inventory_MeleeMagic_Auto.prefab")) { InventoryPrefab = AssetDatabase.LoadAssetAtPath("Assets/Invector-3rdPersonController/Add-ons/ShadesSpellSystem/Inventory/Inventory_MeleeMagic_Auto.prefab", typeof(vInventory)) as vInventory; } if (File.Exists(Application.dataPath + "/Invector-3rdPersonController/Add-ons/ShadesSpellSystem/Inventory/vMeleeMagic_ItemListDataV2.asset")) { ItemListData = AssetDatabase.LoadAssetAtPath("Assets/Invector-3rdPersonController/Add-ons/ShadesSpellSystem/Inventory/vMeleeMagic_ItemListDataV2.asset", typeof(vItemListData)) as vItemListData; } // find the vUI root hierarchy object GameObject[] goRoots = UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects(); foreach (GameObject go in goRoots) { if (go.name == "vUI") { UIBase = go; break; } } // only run once bLoaded = true; } // rescan for skinned mesh renderers on active selection change if (Selection.activeGameObject != null) { if (LastScanned != Selection.activeGameObject) { LastScanned = Selection.activeGameObject; iWhichMesh = -1; LOD1BodyMeshNames = new List <string>(); LOD1BodyMesh = null; LOD1BodyMesh = Selection.activeGameObject.GetComponentsInChildren <SkinnedMeshRenderer>(); if (LOD1BodyMesh != null) { for (int i = 0; i < LOD1BodyMesh.Length; i++) { LOD1BodyMeshNames.Add(LOD1BodyMesh[i].name); } } } } else { iWhichMesh = -1; LOD1BodyMeshNames = new List <string>(); } // allow user to change the default component parts InventoryPrefab = EditorGUILayout.ObjectField("Inventory Prefab: ", InventoryPrefab, typeof(vInventory), false) as vInventory; ItemListData = EditorGUILayout.ObjectField("Item List Data: ", ItemListData, typeof(vItemListData), false) as vItemListData; ItemCollectionDisplay = EditorGUILayout.ObjectField("Item Collection Display: ", ItemCollectionDisplay, typeof(GameObject), false) as GameObject; HitDamageParticle = EditorGUILayout.ObjectField("Hit Damage Particle: ", HitDamageParticle, typeof(GameObject), false) as GameObject; UIBase = EditorGUILayout.ObjectField("UI Parent: ", UIBase, typeof(GameObject), false) as GameObject; for (int i = 0; i < Conditions.Count; i++) { Conditions[i].Display = EditorGUILayout.ObjectField(Conditions[i].Type.ToString() + " Condition", Conditions[i].Display, typeof(GameObject), false) as GameObject; } //LOD1BodyMesh = EditorGUILayout.ObjectField("LOD1 Body Mesh: ", LOD1BodyMesh, typeof(SkinnedMeshRenderer), false) as SkinnedMeshRenderer; iWhichMesh = EditorGUILayout.Popup("LOD1 Body :", iWhichMesh, LOD1BodyMeshNames.ToArray()); // fail safe if (InventoryPrefab != null && InventoryPrefab.GetComponent <vInventory>() == null) { EditorGUILayout.HelpBox("Please select a Inventory Prefab that contains the vInventory script", MessageType.Warning); } GUILayout.EndVertical(); // create button if valid GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (InventoryPrefab != null && ItemListData != null) { if (Selection.activeGameObject != null && Selection.activeGameObject.GetComponent <vThirdPersonController>() != null) { if (iWhichMesh > -1) { if (GUILayout.Button("Create")) { Create(); } } else { EditorGUILayout.HelpBox("Please select which skinned mesh renderer is the LOD1 body", MessageType.Warning); } } else { EditorGUILayout.HelpBox("Please select the Player to add this component", MessageType.Warning); } } else { EditorGUILayout.HelpBox("Please select the inventory prefab and item list data", MessageType.Warning); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); }