public void AmmoChange() { if (GameObject.FindGameObjectWithTag("Player").GetComponent <CombatController>().equipWeapon.type != WepType.MELEE) { RangedWep wep = (RangedWep)GameObject.FindGameObjectWithTag("Player").GetComponent <CombatController>().equipWeapon; GetComponentInChildren <Text>().text = wep.name.Remove(wep.name.Length - 7, 7) + ": " + wep.left.ToString() + "/" + wep.ammoCap.ToString(); } else { MeleeWep wep = (MeleeWep)GameObject.FindGameObjectWithTag("Player").GetComponent <CombatController>().equipWeapon; GetComponentInChildren <Text>().text = wep.name.Remove(wep.name.Length - 7, 7); } }
protected virtual void OnSceneGUI(SceneView sceneView) { MeleeWep wep = target as MeleeWep; m_ArcHandle.angle = wep.arcAngle; m_ArcHandle.radius = wep.arcRadius; m_ArcHandleUp.angle = wep.knockBackAngle; m_ArcHandleUp.radius = wep.knockBackForce; if (GameObject.FindGameObjectWithTag("Player") == null) { return; } Transform player = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>(); Vector3 handleDirection = player.forward; Matrix4x4 handleMatrix = Matrix4x4.TRS( player.position, Quaternion.LookRotation(player.forward, player.up), Vector3.one ); using (new Handles.DrawingScope(handleMatrix)) { EditorGUI.BeginChangeCheck(); m_ArcHandle.DrawHandle(); if (EditorGUI.EndChangeCheck()) { // record the target object before setting new values so changes can be undone/redone Undo.RecordObject(wep, "Change Projectile Properties"); // copy the handle's updated data back to the target object wep.arcAngle = m_ArcHandle.angle; wep.arcRadius = m_ArcHandle.radius; EditorUtility.SetDirty(wep); } } handleMatrix = Matrix4x4.TRS( player.position, Quaternion.LookRotation(player.forward, -player.up), Vector3.one ); using (new Handles.DrawingScope(handleMatrix)) { EditorGUI.BeginChangeCheck(); m_ArcHandle.DrawHandle(); if (EditorGUI.EndChangeCheck()) { // record the target object before setting new values so changes can be undone/redone Undo.RecordObject(wep, "Change Projectile Properties"); // copy the handle's updated data back to the target object wep.arcAngle = m_ArcHandle.angle; wep.arcRadius = m_ArcHandle.radius; EditorUtility.SetDirty(wep); } } handleMatrix = Matrix4x4.TRS( player.position, Quaternion.LookRotation(player.forward, -player.right), Vector3.one ); using (new Handles.DrawingScope(handleMatrix)) { EditorGUI.BeginChangeCheck(); m_ArcHandleUp.DrawHandle(); if (EditorGUI.EndChangeCheck()) { // record the target object before setting new values so changes can be undone/redone Undo.RecordObject(wep, "Change Projectile Properties"); // copy the handle's updated data back to the target object wep.knockBackAngle = m_ArcHandleUp.angle; wep.knockBackForce = m_ArcHandleUp.radius; EditorUtility.SetDirty(wep); } } AssetDatabase.SaveAssets(); }