This commit is contained in:
sewmina7@gmail.com 2024-02-15 00:15:22 +05:30
parent 36da1f016f
commit 74d86ce2fe
31 changed files with 454400 additions and 24942 deletions

View File

@ -0,0 +1,127 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: EmissionTube 4
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ValidKeywords:
- _EMISSION
m_InvalidKeywords: []
m_LightmapFlags: 2
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap:
RenderType: Opaque
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _AlphaClip: 0
- _Blend: 0
- _BumpScale: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _EnvironmentReflections: 1
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Surface: 0
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 0.05088248, b: 0, a: 1}
- _Color: {r: 1, g: 0.05088248, b: 0, a: 1}
- _EmissionColor: {r: 0, g: 20.078432, b: 746.91766, a: 1}
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
m_BuildTextureStacks: []
--- !u!114 &3890951831807874510
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0a4aed7a9d297c742847515adfffb221
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -59,7 +59,7 @@ Material:
m_Offset: {x: 0, y: 0} m_Offset: {x: 0, y: 0}
m_Ints: [] m_Ints: []
m_Floats: m_Floats:
- _Emission: 0.25 - _Emission: 0.5
- _QueueControl: 0 - _QueueControl: 0
- _QueueOffset: 0 - _QueueOffset: 0
- _Speed: 2.78 - _Speed: 2.78

View File

@ -7743,7 +7743,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 0
--- !u!4 &7930422585703925222 --- !u!4 &7930422585703925222
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -10146,7 +10146,7 @@ GameObject:
- component: {fileID: 7603268240441996394} - component: {fileID: 7603268240441996394}
- component: {fileID: 7603268240441996386} - component: {fileID: 7603268240441996386}
- component: {fileID: 7603268240441996387} - component: {fileID: 7603268240441996387}
m_Layer: 0 m_Layer: 2
m_Name: Player m_Name: Player
m_TagString: Player m_TagString: Player
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
@ -10398,6 +10398,9 @@ MonoBehaviour:
airTimeForGliding: 1.2 airTimeForGliding: 1.2
airTimeForAim: 1 airTimeForAim: 1
recoil: 0.3 recoil: 0.3
shootingLayerMask:
serializedVersion: 2
m_Bits: 51
--- !u!114 &1081782896438465053 --- !u!114 &1081782896438465053
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -10639,6 +10642,7 @@ MonoBehaviour:
m_RotationOrder: 4 m_RotationOrder: 4
BulletEffectiveRange: 30 BulletEffectiveRange: 30
CurrentWeaponData: {fileID: 0} CurrentWeaponData: {fileID: 0}
ignoreFriendlyFire: 0
--- !u!1 &9112347911067776042 --- !u!1 &9112347911067776042
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -1994,9 +1994,9 @@ RectTransform:
m_Father: {fileID: 788620501} m_Father: {fileID: 788620501}
m_RootOrder: 6 m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0} m_AnchorMin: {x: 1, y: 1}
m_AnchorMax: {x: 1, y: 0} m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -103.7, y: 992.9} m_AnchoredPosition: {x: -103.7, y: -80.94}
m_SizeDelta: {x: 100, y: 100} m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &238250731 --- !u!114 &238250731

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1d9589d0420f2184db2b4c78ef1f0aff
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,6 +1,7 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Photon.Realtime;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
@ -10,7 +11,6 @@ public class LeaderboardTDM : MonoBehaviour
public Transform[] TeamParents; public Transform[] TeamParents;
public void Populate(PlayerNetwork[] list){ public void Populate(PlayerNetwork[] list){
//Teamify //Teamify
Teams = new Dictionary<string, List<PlayerNetwork>>(); Teams = new Dictionary<string, List<PlayerNetwork>>();
foreach(PlayerNetwork player in list){ foreach(PlayerNetwork player in list){
@ -24,13 +24,12 @@ public class LeaderboardTDM : MonoBehaviour
for(int i=0; i < TeamParents.Length; i++){ for(int i=0; i < TeamParents.Length; i++){
bool withinRange = (Teams.Keys.Count > i); bool withinRange = (Teams.Keys.Count > i);
TeamParents[i].gameObject.SetActive(withinRange); TeamParents[i].gameObject.SetActive(withinRange);
unsortedTeamScores = new Dictionary<string, int>();
if(withinRange){ if(withinRange){
TeamParents[i].GetChild(0).GetComponent<TMP_Text>().text = Teams.Keys.ElementAt(i); TeamParents[i].GetChild(0).GetComponent<TMP_Text>().text = Teams.Keys.ElementAt(i);
int score =0; int score =0;
for(int ii = 0; ii < TeamParents[i].GetChild(2).childCount; ii++){ for(int ii = 0; ii < TeamParents[i].GetChild(2).childCount; ii++){
bool playerItemsWithinRange = Teams.Values.ElementAt(i).Count > ii; bool playerItemsWithinRange = Teams.Values.ElementAt(i).Count > ii;
Transform playerItemTransform = TeamParents[i].GetChild(2).GetChild(ii); Transform playerItemTransform = TeamParents[i].GetChild(2).GetChild(ii);
playerItemTransform.gameObject.SetActive(playerItemsWithinRange); playerItemTransform.gameObject.SetActive(playerItemsWithinRange);
@ -45,10 +44,12 @@ public class LeaderboardTDM : MonoBehaviour
score+= player.kills; score+= player.kills;
} }
unsortedTeamScores.Add(Teams.Keys.ElementAt(i), score);
TeamParents[i].GetChild(1).GetComponent<TMP_Text>().text = (score * 10).ToString("n0"); TeamParents[i].GetChild(1).GetComponent<TMP_Text>().text = (score * 10).ToString("n0");
} }
} }
} }
public static Dictionary<string, int> unsortedTeamScores;
} }

View File

@ -22,6 +22,7 @@ public class GameManager : MonoBehaviourPunCallbacks, IOnEventCallback
private double m_startTime; private double m_startTime;
public int DeathmatchRoundLength = 600; public int DeathmatchRoundLength = 600;
public int DeathmtachRoundCountdown = 5; public int DeathmtachRoundCountdown = 5;
public int TDM_MinPlayers = 4;
public double StartTime{ public double StartTime{
get{ get{
return m_startTime; return m_startTime;
@ -55,7 +56,7 @@ public class GameManager : MonoBehaviourPunCallbacks, IOnEventCallback
public static string partyId; public static string partyId;
public static string RoomName; public static string RoomName;
public static bool isInit =false; public static bool isInit =false;
public static string desiredGameMode; public static string desiredGameMode = GameModes.Deathmatch.ToString();
public static GameManager instance; public static GameManager instance;
public static PlayerController localPlayer; public static PlayerController localPlayer;
@ -85,7 +86,7 @@ public class GameManager : MonoBehaviourPunCallbacks, IOnEventCallback
base.OnJoinedRoom(); base.OnJoinedRoom();
StartCoroutine(KickstartGame()); StartCoroutine(KickstartGame());
// //
UIManager.instance.loadingPanel.SetActive(false);
} }
void SpawnLoots(){ void SpawnLoots(){
@ -166,11 +167,11 @@ public class GameManager : MonoBehaviourPunCallbacks, IOnEventCallback
} }
public void FinishRound(){ public void FinishRound(){
int position =0;
for(position=0; position < Leaderboard.list.Length; position++){ if(desiredGameMode == GameModes.Deathmatch.ToString()){
if(Leaderboard.list[position] == localPlayer.playerNetwork){ FinishDeathmatch();
break; }else if(desiredGameMode == GameModes.TeamDeathmatch.ToString()){
} FinishTeamdeathmatch();
} }
if(PhotonNetwork.IsMasterClient){ if(PhotonNetwork.IsMasterClient){
@ -179,16 +180,37 @@ public class GameManager : MonoBehaviourPunCallbacks, IOnEventCallback
Cursor.lockState = CursorLockMode.None; Cursor.lockState = CursorLockMode.None;
Cursor.visible = true; Cursor.visible = true;
CameraFollow.Pause(); CameraFollow.Pause();
if(desiredGameMode == GameModes.Deathmatch.ToString()){
UIManager.ShowDeathmatchFinishScreen(position, Leaderboard.list[0].username);
}
PhotonNetwork.LeaveRoom(); PhotonNetwork.LeaveRoom();
StartCoroutine(PlayAgain()); StartCoroutine(PlayAgain());
} }
void FinishDeathmatch(){
int position =0;
for(position=0; position < Leaderboard.list.Length; position++){
if(Leaderboard.list[position] == localPlayer.playerNetwork){
break;
}
}
if(desiredGameMode == GameModes.Deathmatch.ToString()){
UIManager.ShowDeathmatchFinishScreen(position, Leaderboard.list[0].username);
}
}
void FinishTeamdeathmatch(){
KeyValuePair<string,int> winnerTeam = new KeyValuePair<string, int>("",0);
foreach(KeyValuePair<string,int> team in LeaderboardTDM.unsortedTeamScores){
if(team.Value > winnerTeam.Value){
winnerTeam = team;
}
}
if(desiredGameMode == GameModes.Deathmatch.ToString()){
UIManager.ShowTDMFinishScreen(winnerTeam.Key);
}
}
IEnumerator PlayAgain(){ IEnumerator PlayAgain(){
yield return new WaitForSeconds(10f); yield return new WaitForSeconds(10f);
ResetStatics(); ResetStatics();
@ -269,10 +291,10 @@ public class GameManager : MonoBehaviourPunCallbacks, IOnEventCallback
localPlayer = PhotonNetwork.Instantiate("Player", GetRandomSpawnPoint().position, Quaternion.identity).GetComponentInChildren<PlayerController>(); localPlayer = PhotonNetwork.Instantiate("Player", GetRandomSpawnPoint().position, Quaternion.identity).GetComponentInChildren<PlayerController>();
// localPlayer.GetComponent<PlayerNetwork>().SetPartyName(partyName,partyId); // localPlayer.GetComponent<PlayerNetwork>().SetPartyName(partyName,partyId);
UIManager.instance.RoundLength = DeathmatchRoundLength; UIManager.instance.RoundLength = DeathmatchRoundLength;
localPlayer.GetComponent<PlayerNetwork>().AutoAssignParty();
//Wait for Players //Wait for Players
if(PhotonNetwork.IsMasterClient){ if(PhotonNetwork.IsMasterClient){
while(PhotonNetwork.CurrentRoom.PlayerCount < DeathmatchMinPlayerCount){ while(PhotonNetwork.CurrentRoom.PlayerCount <(desiredGameMode == GameModes.TeamDeathmatch.ToString() ? TDM_MinPlayers : DeathmatchMinPlayerCount)){
yield return new WaitForSeconds(0.5f); yield return new WaitForSeconds(0.5f);
UIManager.WaitingForPlayers(); UIManager.WaitingForPlayers();
} }
@ -329,6 +351,8 @@ public class GameManager : MonoBehaviourPunCallbacks, IOnEventCallback
{ {
StartCoroutine(BeginStartTimer()); StartCoroutine(BeginStartTimer());
}else if(eventCode == BeginGameModeCode){ }else if(eventCode == BeginGameModeCode){
isInit=true;
object[] customData = (object[])photonEvent.CustomData; object[] customData = (object[])photonEvent.CustomData;
StartTime = (double)customData[0]; StartTime = (double)customData[0];
@ -347,7 +371,6 @@ public class GameManager : MonoBehaviourPunCallbacks, IOnEventCallback
localPlayer.transform.position = SpawnPositions[customPlayerId].position; localPlayer.transform.position = SpawnPositions[customPlayerId].position;
isInit=true;
} }
} }

View File

@ -136,6 +136,8 @@ public class MainMenu : MonoBehaviourPunCallbacks, IOnEventCallback
if(val.ToLower()== "tdm"){gameMode = GameModes.TeamDeathmatch;} if(val.ToLower()== "tdm"){gameMode = GameModes.TeamDeathmatch;}
if(val.ToLower() == "br"){gameMode = GameModes.BattleRoyale;} if(val.ToLower() == "br"){gameMode = GameModes.BattleRoyale;}
btnPlay.interactable = gameMode != GameModes.BattleRoyale;
Debug.Log("Set game mode to : " + gameMode.ToString() + $" ({val})"); Debug.Log("Set game mode to : " + gameMode.ToString() + $" ({val})");
GameManager.desiredGameMode = gameMode.ToString(); GameManager.desiredGameMode = gameMode.ToString();
} }

View File

@ -513,6 +513,7 @@ public class PlayerController : MonoBehaviourPunCallbacks
collider.GetComponent<HitBox>().OnPunched(photonView.ViewID, meleeListener.transform.position, transform); collider.GetComponent<HitBox>().OnPunched(photonView.ViewID, meleeListener.transform.position, transform);
} }
} }
public LayerMask shootingLayerMask;
IEnumerator CoroutineFireShot() IEnumerator CoroutineFireShot()
{ {
bool aiming = anim.GetCurrentAnimatorClipInfo(1)[0].clip.name.Contains("Aiming"); bool aiming = anim.GetCurrentAnimatorClipInfo(1)[0].clip.name.Contains("Aiming");

View File

@ -84,7 +84,7 @@ public class PlayerFX : MonoBehaviourPunCallbacks
{ {
HitBox hitbox = impact?.collider.GetComponent<HitBox>(); HitBox hitbox = impact?.collider.GetComponent<HitBox>();
if(hitbox == null){ if(hitbox == null){
playerNetwork.OnHit(photonView.ViewID, PlayerControllerHelper.GetDamageForHitboxType(HitBoxType.Body), transform.position, 1); // playerNetwork.OnHit(photonView.ViewID, PlayerControllerHelper.GetDamageForHitboxType(HitBoxType.Body), transform.position, 1); //PHANTOM SHOTS
}else{ }else{
hitbox.OnHit(photonView.ViewID, impact?.point ?? transform.position, transform); hitbox.OnHit(photonView.ViewID, impact?.point ?? transform.position, transform);
} }

View File

@ -60,37 +60,103 @@ public class PlayerNetwork : MonoBehaviourPunCallbacks, IPunObservable
// //
partyId = GameManager.partyId;
List<string> availablePartyNames = Helpers.battleTeamNames.ToList<string>();
string partyName = Helpers.RandomTeamName;
PlayerNetwork[] players = FindObjectsOfType<PlayerNetwork>();
bool foundMyParty = false;
foreach(PlayerNetwork player in players){
if(player == this){continue;}
if(player.partyId == partyId){
//Found my party!
partyName = player.partyname;
foundMyParty = true;
Debug.Log("Found my party! Its called " + player.partyname);
break;
}else{
if(availablePartyNames.Contains(player.partyname)){
availablePartyNames.Remove(player.partyname);
}
}
}
if(!foundMyParty){ if(GameManager.desiredGameMode== GameModes.TeamDeathmatch.ToString()){ignoreFriendlyFire=true;}
partyName = availablePartyNames[UnityEngine.Random.Range(0, availablePartyNames.Count)];
Debug.Log("Got a new party name! : " + partyName);
}
partyname = partyName;
} }
GetComponent<CharacterController>().detectCollisions=false; GetComponent<CharacterController>().detectCollisions=false;
} }
public void AutoAssignParty(){
StartCoroutine(AutoSwitchTeams());
}
void autoAssignParty(){
partyId = GameManager.partyId;
List<string> availablePartyNames = Helpers.battleTeamNames.ToList<string>();
Dictionary<string, int> parties = new Dictionary<string, int>();
PlayerNetwork[] players = FindObjectsOfType<PlayerNetwork>();
string myLobbyParty = "";
foreach(PlayerNetwork player in players){
if(player.partyname != ""){
//has a party
if(parties.ContainsKey(player.partyname)){
parties[player.partyname]++;
}else{
parties.Add(player.partyname, 1);
}
if(availablePartyNames.Contains(player.partyname)){availablePartyNames.Remove(player.partyname);}
if(partyId == player.partyId){
myLobbyParty = player.partyname;
}
}
}
Debug.Log($"Found {parties.Count} Parties");
if(myLobbyParty == ""){
//Didn't find a party of my own
if(parties.Count > 1){
foreach(KeyValuePair<string,int> party in parties){
if(party.Value < 4){
partyname = party.Key;
break;
}
}
}else{
partyname = availablePartyNames[UnityEngine.Random.Range(0, availablePartyNames.Count)];
}
}else{
if(parties[myLobbyParty] < 4){
partyname = myLobbyParty;
}else{
foreach(KeyValuePair<string,int> party in parties){
if(party.Value < 4){
partyname = party.Key;
break;
}
}
}
}
if(partyname == ""){
partyname = availablePartyNames[UnityEngine.Random.Range(0, availablePartyNames.Count)];
}
}
int autoTeamSwitchCount = 0;
IEnumerator AutoSwitchTeams(){
while(autoTeamSwitchCount < 4){
autoTeamSwitchCount++;
yield return new WaitForSeconds(UnityEngine.Random.Range(0.5f,1f));
autoAssignParty();
}
}
public Dictionary<string, int> GetPartySizes(){
Dictionary<string, int> parties = new Dictionary<string, int>();
foreach(PlayerNetwork player in FindObjectsOfType<PlayerNetwork>()){
if(player.partyname != ""){
//has a party
if(parties.ContainsKey(player.partyname)){
parties[player.partyname]++;
}else{
parties.Add(player.partyname, 1);
}
}
}
return parties;
}
public void SetActiveWeapon(LootItemScriptableObject data) public void SetActiveWeapon(LootItemScriptableObject data)
{ {
int _selectedIndex = -1; int _selectedIndex = -1;
@ -247,7 +313,7 @@ public class PlayerNetwork : MonoBehaviourPunCallbacks, IPunObservable
return DistanceDamageCurve.Evaluate(Mathf.Clamp01(dist/BulletEffectiveRange)); return DistanceDamageCurve.Evaluate(Mathf.Clamp01(dist/BulletEffectiveRange));
} }
public bool ignoreFriendlyFire;
[PunRPC] [PunRPC]
void RpcOnHit(int id, float damage, Vector3 point) void RpcOnHit(int id, float damage, Vector3 point)
{ {
@ -256,6 +322,17 @@ public class PlayerNetwork : MonoBehaviourPunCallbacks, IPunObservable
float newShield = shield; float newShield = shield;
float newHealth = health; float newHealth = health;
if(ignoreFriendlyFire){
PlayerNetwork[] players = FindObjectsOfType<PlayerNetwork>();
foreach(PlayerNetwork p in players){
if(p.photonView.ViewID == id){
//This is the shooter
if(partyname == p.partyname){return;} //Friendly fire
}
}
}
if(shield > 0){ if(shield > 0){
newShield = Mathf.Clamp(shield - damage,0,100); newShield = Mathf.Clamp(shield - damage,0,100);
}else{ }else{
@ -383,7 +460,7 @@ public class PlayerNetwork : MonoBehaviourPunCallbacks, IPunObservable
CameraFollow.Resume(); CameraFollow.Resume();
playerController.isActive=true; playerController.isActive=true;
UIManager.OnRespawn(); UIManager.OnRespawn();
if(GameManager.desiredGameMode == GameModes.Deathmatch.ToString()){ if(GameManager.desiredGameMode == GameModes.Deathmatch.ToString() || GameManager.desiredGameMode == GameModes.TeamDeathmatch.ToString()){
InventoryManager.instance.GiveDefaultLoots(GameManager.instance.DeathmatchDefaultInventory); InventoryManager.instance.GiveDefaultLoots(GameManager.instance.DeathmatchDefaultInventory);
} }
UIManager.UpdateInventory(InventoryManager.instance); UIManager.UpdateInventory(InventoryManager.instance);

View File

@ -38,8 +38,8 @@ public class UIManager : MonoBehaviour
public GameObject inventoryPanel; public GameObject inventoryPanel;
public Transform inventoryGridParent; public Transform inventoryGridParent;
public GameObject inventoryGridItemPrefab; public GameObject inventoryGridItemPrefab;
public Image weaponSlot1Inventory, weaponSlot2Inventory, pistolSlotInventory, throwableSlotInventory; public Image weaponSlot1Inventory, weaponSlot2Inventory, pistolSlotInventory, throwableSlotInventory;
[Header("Deathmatch")] [Header("Deathmatch")]
public TMP_Text TimerTxt; public TMP_Text TimerTxt;
public TMP_Text LastChampTxt; public TMP_Text LastChampTxt;
@ -134,6 +134,19 @@ public class UIManager : MonoBehaviour
instance.m_ShowDeathmatchFinishScreen(position, winnerName); instance.m_ShowDeathmatchFinishScreen(position, winnerName);
} }
public static void ShowTDMFinishScreen(string winnerName){
instance.m_ShowTDMFinishScreen(winnerName);
}
void m_ShowTDMFinishScreen(string winnerName){
DeathmatchPanel.SetActive(true);
// DeathmatchPositionTxt.text = $"You finished {Helpers.numberToPosition(position+1)}";
DeathmatchWinnerTxt.text = $"The Winner is {winnerName}";
StartCoroutine(StartDeathmatchRestartCountdown());
}
void m_ShowDeathmatchFinishScreen(int position, string winnerName){ void m_ShowDeathmatchFinishScreen(int position, string winnerName){
DeathmatchPanel.SetActive(true); DeathmatchPanel.SetActive(true);
DeathmatchPositionTxt.text = $"You finished {Helpers.numberToPosition(position+1)}"; DeathmatchPositionTxt.text = $"You finished {Helpers.numberToPosition(position+1)}";
@ -174,7 +187,6 @@ public class UIManager : MonoBehaviour
public static void SetHealth(float health,float shield) public static void SetHealth(float health,float shield)
{ {
//instance.HealthSlider.value = health;
instance.Healthbar.fillAmount = health / 100f; instance.Healthbar.fillAmount = health / 100f;
instance.ShieldBar.fillAmount = shield /100f; instance.ShieldBar.fillAmount = shield /100f;
instance.HealthTxt.text = health.ToString("n0") + " / 100"; instance.HealthTxt.text = health.ToString("n0") + " / 100";

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 07ae7569bb3e15745bd4b95c5dbf20a6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b0e79e43e01ff3e4991e8902ac89b322
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,487 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.Linq;
using System.Runtime.InteropServices;
using System.IO;
using UnityProjectCloner;
namespace UnityProjectCloner
{
/// <summary>
/// Contains all required methods for creating a linked clone of the Unity project.
/// </summary>
public class ProjectCloner
{
/// <summary>
/// Name used for an identifying file created in the clone project directory.
/// </summary>
/// <remarks>
/// (!) Do not change this after the clone was created, because then connection will be lost.
/// </remarks>
public const string CloneFileName = ".clone";
/// <summary>
/// Suffix added to the end of the project clone name when it is created.
/// </summary>
/// <remarks>
/// (!) Do not change this after the clone was created, because then connection will be lost.
/// </remarks>
public const string CloneNameSuffix = "_clone";
public const int MaxCloneProjectCount = 10;
#region Managing clones
/// <summary>
/// Creates clone from the project currently open in Unity Editor.
/// </summary>
/// <returns></returns>
public static Project CreateCloneFromCurrent()
{
if (IsClone())
{
Debug.LogError("This project is already a clone. Cannot clone it.");
return null;
}
string currentProjectPath = ProjectCloner.GetCurrentProjectPath();
return ProjectCloner.CreateCloneFromPath(currentProjectPath);
}
/// <summary>
/// Creates clone of the project located at the given path.
/// </summary>
/// <param name="sourceProjectPath"></param>
/// <returns></returns>
public static Project CreateCloneFromPath(string sourceProjectPath)
{
Project sourceProject = new Project(sourceProjectPath);
string cloneProjectPath = null;
//Find available clone suffix id
for (int i = 0; i < MaxCloneProjectCount; i++)
{
string originalProjectPath = ProjectCloner.GetCurrentProject().projectPath;
string possibleCloneProjectPath = originalProjectPath + ProjectCloner.CloneNameSuffix + "_" + i;
if (!Directory.Exists(possibleCloneProjectPath))
{
cloneProjectPath = possibleCloneProjectPath;
break;
}
}
if (string.IsNullOrEmpty(cloneProjectPath))
{
Debug.LogError("The number of cloned projects has reach its limit. Limit: " + MaxCloneProjectCount);
return null;
}
Project cloneProject = new Project(cloneProjectPath);
Debug.Log("Start project name: " + sourceProject);
Debug.Log("Clone project name: " + cloneProject);
ProjectCloner.CreateProjectFolder(cloneProject);
ProjectCloner.CopyLibraryFolder(sourceProject, cloneProject);
ProjectCloner.LinkFolders(sourceProject.assetPath, cloneProject.assetPath);
ProjectCloner.LinkFolders(sourceProject.projectSettingsPath, cloneProject.projectSettingsPath);
ProjectCloner.LinkFolders(sourceProject.packagesPath, cloneProject.packagesPath);
ProjectCloner.LinkFolders(sourceProject.autoBuildPath, cloneProject.autoBuildPath);
ProjectCloner.RegisterClone(cloneProject);
return cloneProject;
}
/// <summary>
/// Registers a clone by placing an identifying ".clone" file in its root directory.
/// </summary>
/// <param name="cloneProject"></param>
private static void RegisterClone(Project cloneProject)
{
/// Add clone identifier file.
string identifierFile = Path.Combine(cloneProject.projectPath, ProjectCloner.CloneFileName);
File.Create(identifierFile).Dispose();
/// Add collabignore.txt to stop the clone from messing with Unity Collaborate if it's enabled. Just in case.
string collabignoreFile = Path.Combine(cloneProject.projectPath, "collabignore.txt");
File.WriteAllText(collabignoreFile, "*"); /// Make it ignore ALL files in the clone.
}
/// <summary>
/// Opens a project located at the given path (if one exists).
/// </summary>
/// <param name="projectPath"></param>
public static void OpenProject(string projectPath)
{
if (!Directory.Exists(projectPath))
{
Debug.LogError("Cannot open the project - provided folder (" + projectPath + ") does not exist.");
return;
}
if (projectPath == ProjectCloner.GetCurrentProjectPath())
{
Debug.LogError("Cannot open the project - it is already open.");
return;
}
string fileName = EditorApplication.applicationPath;
string args = "-projectPath \"" + projectPath + "\"";
Debug.Log("Opening project \"" + fileName + " " + args + "\"");
ProjectCloner.StartHiddenConsoleProcess(fileName, args);
}
/// <summary>
/// Deletes the clone of the currently open project, if such exists.
/// </summary>
public static void DeleteClone(string cloneProjectPath)
{
/// Clone won't be able to delete itself.
if (ProjectCloner.IsClone()) return;
///Extra precautions.
if (cloneProjectPath == string.Empty) return;
if (cloneProjectPath == ProjectCloner.GetOriginalProjectPath()) return;
if (!cloneProjectPath.EndsWith(ProjectCloner.CloneNameSuffix)) return;
//Check what OS is
switch (Application.platform)
{
case (RuntimePlatform.WindowsEditor):
Debug.Log("Attempting to delete folder \"" + cloneProjectPath + "\"");
string args = "/c " + @"rmdir /s/q " + string.Format("\"{0}\"", cloneProjectPath);
StartHiddenConsoleProcess("cmd.exe", args);
break;
case (RuntimePlatform.OSXEditor):
throw new System.NotImplementedException("No Mac function implement yet :(");
//break;
case (RuntimePlatform.LinuxEditor):
throw new System.NotImplementedException("No linux support yet :(");
//break;
default:
Debug.LogWarning("Not in a known editor. Where are you!?");
break;
}
}
#endregion
#region Creating project folders
/// <summary>
/// Creates an empty folder using data in the given Project object
/// </summary>
/// <param name="project"></param>
public static void CreateProjectFolder(Project project)
{
string path = project.projectPath;
Debug.Log("Creating new empty folder at: " + path);
Directory.CreateDirectory(path);
}
/// <summary>
/// Copies the full contents of the unity library. We want to do this to avoid the lengthy reserialization of the whole project when it opens up the clone.
/// </summary>
/// <param name="sourceProject"></param>
/// <param name="destinationProject"></param>
public static void CopyLibraryFolder(Project sourceProject, Project destinationProject)
{
if (Directory.Exists(destinationProject.libraryPath))
{
Debug.LogWarning("Library copy: destination path already exists! ");
return;
}
Debug.Log("Library copy: " + destinationProject.libraryPath);
ProjectCloner.CopyDirectoryWithProgressBar(sourceProject.libraryPath, destinationProject.libraryPath, "Cloning project '" + sourceProject.name + "'. ");
}
#endregion
#region Creating symlinks
/// <summary>
/// Creates a symlink between destinationPath and sourcePath (Mac version).
/// </summary>
/// <param name="sourcePath"></param>
/// <param name="destinationPath"></param>
private static void CreateLinkMac(string sourcePath, string destinationPath)
{
Debug.LogWarning("This hasn't been tested yet! I am mac-less :( Please chime in on the github if it works for you.");
string cmd = "ln " + string.Format("\"{0}\" \"{1}\"", destinationPath, sourcePath);
Debug.Log("Mac hard link " + cmd);
ProjectCloner.StartHiddenConsoleProcess("/bin/bash", cmd);
}
/// <summary>
/// Creates a symlink between destinationPath and sourcePath (Windows version).
/// </summary>
/// <param name="sourcePath"></param>
/// <param name="destinationPath"></param>
private static void CreateLinkWin(string sourcePath, string destinationPath)
{
string cmd = "/C mklink /J " + string.Format("\"{0}\" \"{1}\"", destinationPath, sourcePath);
Debug.Log("Windows junction: " + cmd);
ProjectCloner.StartHiddenConsoleProcess("cmd.exe", cmd);
}
/// <summary>
/// Creates a symlink between destinationPath and sourcePath (Linux version).
/// </summary>
/// <param name="sourcePath"></param>
/// <param name="destinationPath"></param>
private static void CreateLinkLunux(string sourcePath, string destinationPath)
{
string cmd = string.Format("-c \"ln -s {0} {1}\"", sourcePath, destinationPath);
Debug.Log("Linux junction: " + cmd);
ProjectCloner.StartHiddenConsoleProcess("/bin/bash", cmd);
}
//TODO avoid terminal calls and use proper api stuff. See below for windows!
////https://docs.microsoft.com/en-us/windows/desktop/api/ioapiset/nf-ioapiset-deviceiocontrol
//[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
//private static extern bool DeviceIoControl(System.IntPtr hDevice, uint dwIoControlCode,
// System.IntPtr InBuffer, int nInBufferSize,
// System.IntPtr OutBuffer, int nOutBufferSize,
// out int pBytesReturned, System.IntPtr lpOverlapped);
/// <summary>
/// Create a link / junction from the real project to it's clone.
/// </summary>
/// <param name="sourcePath"></param>
/// <param name="destinationPath"></param>
public static void LinkFolders(string sourcePath, string destinationPath)
{
if ((Directory.Exists(destinationPath) == false) && (Directory.Exists(sourcePath) == true))
{
switch (Application.platform)
{
case (RuntimePlatform.WindowsEditor):
CreateLinkWin(sourcePath, destinationPath);
break;
case (RuntimePlatform.OSXEditor):
CreateLinkMac(sourcePath, destinationPath);
break;
case (RuntimePlatform.LinuxEditor):
CreateLinkLunux(sourcePath, destinationPath);
break;
default:
Debug.LogWarning("Not in a known editor. Where are you!?");
break;
}
}
else
{
Debug.LogWarning("Skipping Asset link, it already exists: " + destinationPath);
}
}
#endregion
#region Utility methods
/// <summary>
/// Returns true is the project currently open in Unity Editor is a clone.
/// </summary>
/// <returns></returns>
public static bool IsClone()
{
/// The project is a clone if its root directory contains an empty file named ".clone".
string cloneFilePath = Path.Combine(ProjectCloner.GetCurrentProjectPath(), ProjectCloner.CloneFileName);
bool isClone = File.Exists(cloneFilePath);
return isClone;
}
/// <summary>
/// Get the path to the current unityEditor project folder's info
/// </summary>
/// <returns></returns>
public static string GetCurrentProjectPath()
{
return Application.dataPath.Replace("/Assets", "");
}
/// <summary>
/// Return a project object that describes all the paths we need to clone it.
/// </summary>
/// <returns></returns>
public static Project GetCurrentProject()
{
string pathString = ProjectCloner.GetCurrentProjectPath();
return new Project(pathString);
}
/// <summary>
/// Returns the path to the original project.
/// If currently open project is the original, returns its own path.
/// If the original project folder cannot be found, retuns an empty string.
/// </summary>
/// <returns></returns>
public static string GetOriginalProjectPath()
{
if (IsClone())
{
/// If this is a clone...
/// Original project path can be deduced by removing the suffix from the clone's path.
string cloneProjectPath = ProjectCloner.GetCurrentProject().projectPath;
int index = cloneProjectPath.LastIndexOf(ProjectCloner.CloneNameSuffix);
if (index > 0)
{
string originalProjectPath = cloneProjectPath.Substring(0, index);
if (Directory.Exists(originalProjectPath)) return originalProjectPath;
}
return string.Empty;
}
else
{
/// If this is the original, we return its own path.
return ProjectCloner.GetCurrentProjectPath();
}
}
/// <summary>
/// Returns all clone projects path.
/// </summary>
/// <returns></returns>
public static List<string> GetCloneProjectsPath()
{
List<string> projectsPath = new List<string>();
for (int i = 0; i < MaxCloneProjectCount; i++)
{
string originalProjectPath = ProjectCloner.GetCurrentProject().projectPath;
string cloneProjectPath = originalProjectPath + ProjectCloner.CloneNameSuffix + "_" + i;
if (Directory.Exists(cloneProjectPath))
projectsPath.Add(cloneProjectPath);
}
return projectsPath;
}
/// <summary>
/// Copies directory located at sourcePath to destinationPath. Displays a progress bar.
/// </summary>
/// <param name="source">Directory to be copied.</param>
/// <param name="destination">Destination directory (created automatically if needed).</param>
/// <param name="progressBarPrefix">Optional string added to the beginning of the progress bar window header.</param>
public static void CopyDirectoryWithProgressBar(string sourcePath, string destinationPath, string progressBarPrefix = "")
{
var source = new DirectoryInfo(sourcePath);
var destination = new DirectoryInfo(destinationPath);
long totalBytes = 0;
long copiedBytes = 0;
ProjectCloner.CopyDirectoryWithProgressBarRecursive(source, destination, ref totalBytes, ref copiedBytes, progressBarPrefix);
EditorUtility.ClearProgressBar();
}
/// <summary>
/// Copies directory located at sourcePath to destinationPath. Displays a progress bar.
/// Same as the previous method, but uses recursion to copy all nested folders as well.
/// </summary>
/// <param name="source">Directory to be copied.</param>
/// <param name="destination">Destination directory (created automatically if needed).</param>
/// <param name="totalBytes">Total bytes to be copied. Calculated automatically, initialize at 0.</param>
/// <param name="copiedBytes">To track already copied bytes. Calculated automatically, initialize at 0.</param>
/// <param name="progressBarPrefix">Optional string added to the beginning of the progress bar window header.</param>
private static void CopyDirectoryWithProgressBarRecursive(DirectoryInfo source, DirectoryInfo destination, ref long totalBytes, ref long copiedBytes, string progressBarPrefix = "")
{
/// Directory cannot be copied into itself.
if (source.FullName.ToLower() == destination.FullName.ToLower())
{
Debug.LogError("Cannot copy directory into itself.");
return;
}
/// Calculate total bytes, if required.
if (totalBytes == 0)
{
totalBytes = ProjectCloner.GetDirectorySize(source, true, progressBarPrefix);
}
/// Create destination directory, if required.
if (!Directory.Exists(destination.FullName))
{
Directory.CreateDirectory(destination.FullName);
}
/// Copy all files from the source.
foreach (FileInfo file in source.GetFiles())
{
try
{
file.CopyTo(Path.Combine(destination.ToString(), file.Name), true);
}
catch (IOException)
{
/// Some files may throw IOException if they are currently open in Unity editor.
/// Just ignore them in such case.
}
/// Account the copied file size.
copiedBytes += file.Length;
/// Display the progress bar.
float progress = (float)copiedBytes / (float)totalBytes;
bool cancelCopy = EditorUtility.DisplayCancelableProgressBar(
progressBarPrefix + "Copying '" + source.FullName + "' to '" + destination.FullName + "'...",
"(" + (progress * 100f).ToString("F2") + "%) Copying file '" + file.Name + "'...",
progress);
if (cancelCopy) return;
}
/// Copy all nested directories from the source.
foreach (DirectoryInfo sourceNestedDir in source.GetDirectories())
{
DirectoryInfo nextDestingationNestedDir = destination.CreateSubdirectory(sourceNestedDir.Name);
ProjectCloner.CopyDirectoryWithProgressBarRecursive(sourceNestedDir, nextDestingationNestedDir, ref totalBytes, ref copiedBytes, progressBarPrefix);
}
}
/// <summary>
/// Calculates the size of the given directory. Displays a progress bar.
/// </summary>
/// <param name="directory">Directory, which size has to be calculated.</param>
/// <param name="includeNested">If true, size will include all nested directories.</param>
/// <param name="progressBarPrefix">Optional string added to the beginning of the progress bar window header.</param>
/// <returns>Size of the directory in bytes.</returns>
private static long GetDirectorySize(DirectoryInfo directory, bool includeNested = false, string progressBarPrefix = "")
{
EditorUtility.DisplayProgressBar(progressBarPrefix + "Calculating size of directories...", "Scanning '" + directory.FullName + "'...", 0f);
/// Calculate size of all files in directory.
long filesSize = directory.EnumerateFiles().Sum((FileInfo file) => file.Length);
/// Calculate size of all nested directories.
long directoriesSize = 0;
if (includeNested)
{
IEnumerable<DirectoryInfo> nestedDirectories = directory.EnumerateDirectories();
foreach (DirectoryInfo nestedDir in nestedDirectories)
{
directoriesSize += ProjectCloner.GetDirectorySize(nestedDir, true, progressBarPrefix);
}
}
return filesSize + directoriesSize;
}
/// <summary>
/// Starts process in the system console, taking the given fileName and args.
/// </summary>
/// <param name="fileName"></param>
/// <param name="args"></param>
private static void StartHiddenConsoleProcess(string fileName, string args)
{
var process = new System.Diagnostics.Process();
//process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
process.StartInfo.FileName = fileName;
process.StartInfo.Arguments = args;
process.Start();
}
#endregion
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6148e48ed6b61d748b187d06d3687b83
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,131 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityProjectCloner;
using System.IO;
namespace UnityProjectCloner
{
/// <summary>
/// Provides Unity Editor window for ProjectCloner.
/// </summary>
public class ProjectClonerWindow : EditorWindow
{
/// <summary>
/// True if currently open project is a clone.
/// </summary>
public bool isClone
{
get { return ProjectCloner.IsClone(); }
}
/// <summary>
/// Returns true if project clone exists.
/// </summary>
public bool isCloneCreated
{
get { return ProjectCloner.GetCloneProjectsPath().Count >= 1; }
}
[MenuItem("Tools/Project Cloner")]
private static void InitWindow()
{
ProjectClonerWindow window = (ProjectClonerWindow)EditorWindow.GetWindow(typeof(ProjectClonerWindow));
window.titleContent = new GUIContent("Project Cloner");
window.Show();
}
private void OnGUI()
{
if (isClone)
{
/// If it is a clone project...
string originalProjectPath = ProjectCloner.GetOriginalProjectPath();
if (originalProjectPath == string.Empty)
{
/// If original project cannot be found, display warning message.
string thisProjectName = ProjectCloner.GetCurrentProject().name;
string supposedOriginalProjectName = ProjectCloner.GetCurrentProject().name.Replace("_clone", "");
EditorGUILayout.HelpBox(
"This project is a clone, but the link to the original seems lost.\nYou have to manually open the original and create a new clone instead of this one.\nThe original project should have a name '" + supposedOriginalProjectName + "', if it was not changed.",
MessageType.Warning);
}
else
{
/// If original project is present, display some usage info.
EditorGUILayout.HelpBox(
"This project is a clone of the project '" + Path.GetFileName(originalProjectPath) + "'.\nIf you want to make changes the project files or manage clones, please open the original project through Unity Hub.",
MessageType.Info);
}
}
else
{
/// If it is an original project...
if (isCloneCreated)
{
GUILayout.BeginVertical("HelpBox");
GUILayout.Label("Clones of this Project");
/// If clone(s) is created, we can either open it or delete it.
var cloneProjectsPath = ProjectCloner.GetCloneProjectsPath();
for (int i = 0; i < cloneProjectsPath.Count; i++)
{
GUILayout.BeginVertical("GroupBox");
string cloneProjectPath = cloneProjectsPath[i];
EditorGUILayout.LabelField("Clone " + i);
EditorGUILayout.TextField("Clone project path", cloneProjectPath, EditorStyles.textField);
if (GUILayout.Button("Open in New Editor"))
{
ProjectCloner.OpenProject(cloneProjectPath);
}
GUILayout.BeginHorizontal();
if (GUILayout.Button("Delete"))
{
bool delete = EditorUtility.DisplayDialog(
"Delete the clone?",
"Are you sure you want to delete the clone project '" + ProjectCloner.GetCurrentProject().name + "_clone'? If so, you can always create a new clone from ProjectCloner window.",
"Delete",
"Cancel");
if (delete)
{
ProjectCloner.DeleteClone(cloneProjectPath);
}
}
//Offer a solution to user in-case they are stuck with deleting project
if (GUILayout.Button("?", GUILayout.Width(30)))
{
var openUrl = EditorUtility.DisplayDialog("Can't delete clone?",
"Sometime clone can't be deleted due to it's still being opened by another unity instance running in the background." +
"\nYou can read this answer from ServerFault on how to find and kill the process.", "Open Answer");
if (openUrl)
{
Application.OpenURL("https://serverfault.com/a/537762");
}
}
GUILayout.EndHorizontal();
GUILayout.EndVertical();
}
GUILayout.EndVertical();
//Have difficulty with naming
//GUILayout.Label("Other", EditorStyles.boldLabel);
if (GUILayout.Button("Add new clone"))
{
ProjectCloner.CreateCloneFromCurrent();
}
}
else
{
/// If no clone created yet, we must create it.
EditorGUILayout.HelpBox("No project clones found. Create a new one!", MessageType.Info);
if (GUILayout.Button("Create new clone"))
{
ProjectCloner.CreateCloneFromCurrent();
}
}
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a041d83486c20b84bbf5077ddfbbca37
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,110 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
using UnityProjectCloner;
namespace UnityProjectCloner
{
public class Project : System.ICloneable
{
public string name;
public string projectPath;
string rootPath;
public string assetPath;
public string projectSettingsPath;
public string libraryPath;
public string packagesPath;
public string autoBuildPath;
char[] separator = new char[1] { '/' };
/// <summary>
/// Default constructor
/// </summary>
public Project()
{
}
/// <summary>
/// Initialize the project object by parsing its full path returned by Unity into a bunch of individual folder names and paths.
/// </summary>
/// <param name="path"></param>
public Project(string path)
{
ParsePath(path);
}
/// <summary>
/// Create a new object with the same settings
/// </summary>
/// <returns></returns>
public object Clone()
{
Project newProject = new Project();
newProject.rootPath = rootPath;
newProject.projectPath = projectPath;
newProject.assetPath = assetPath;
newProject.projectSettingsPath = projectSettingsPath;
newProject.libraryPath = libraryPath;
newProject.name = name;
newProject.separator = separator;
newProject.packagesPath = packagesPath;
newProject.autoBuildPath = autoBuildPath;
return newProject;
}
/// <summary>
/// Update the project object by renaming and reparsing it. Pass in the new name of a project, and it'll update the other member variables to match.
/// </summary>
/// <param name="name"></param>
public void updateNewName(string newName)
{
name = newName;
ParsePath(rootPath + "/" + name + "/Assets");
}
/// <summary>
/// Debug override so we can quickly print out the project info.
/// </summary>
/// <returns></returns>
public override string ToString()
{
string printString = name + "\n" +
rootPath + "\n" +
projectPath + "\n" +
assetPath + "\n" +
projectSettingsPath + "\n" +
packagesPath + "\n" +
autoBuildPath + "\n" +
libraryPath;
return (printString);
}
private void ParsePath(string path)
{
//Unity's Application functions return the Assets path in the Editor.
projectPath = path;
//pop off the last part of the path for the project name, keep the rest for the root path
List<string> pathArray = projectPath.Split(separator).ToList<string>();
name = pathArray.Last();
pathArray.RemoveAt(pathArray.Count() - 1);
rootPath = string.Join(separator[0].ToString(), pathArray);
assetPath = projectPath + "/Assets";
projectSettingsPath = projectPath + "/ProjectSettings";
libraryPath = projectPath + "/Library";
packagesPath = projectPath + "/Packages";
autoBuildPath = projectPath + "/AutoBuild";
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ec8d3a1577179ef44815739178cf75b4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,15 @@
{
"name": "projectCloner",
"references": [],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 894a6cc6ed5cd2645bb542978cbed6a9
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,407 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.18028305, g: 0.22571313, b: 0.3069213, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 12
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 256
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 1
m_PVRDenoiserTypeDirect: 1
m_PVRDenoiserTypeIndirect: 1
m_PVRDenoiserTypeAO: 1
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_LightingSettings: {fileID: 0}
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &330585543
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 330585546}
- component: {fileID: 330585545}
- component: {fileID: 330585544}
- component: {fileID: 330585547}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &330585544
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 330585543}
m_Enabled: 1
--- !u!20 &330585545
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 330585543}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &330585546
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 330585543}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &330585547
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 330585543}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_RenderShadows: 1
m_RequiresDepthTextureOption: 2
m_RequiresOpaqueTextureOption: 2
m_CameraType: 0
m_Cameras: []
m_RendererIndex: -1
m_VolumeLayerMask:
serializedVersion: 2
m_Bits: 1
m_VolumeTrigger: {fileID: 0}
m_VolumeFrameworkUpdateModeOption: 2
m_RenderPostProcessing: 1
m_Antialiasing: 0
m_AntialiasingQuality: 2
m_StopNaN: 0
m_Dithering: 0
m_ClearDepth: 1
m_AllowXRRendering: 1
m_RequiresDepthTexture: 0
m_RequiresColorTexture: 0
m_Version: 2
--- !u!1 &410087039
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 410087041}
- component: {fileID: 410087040}
- component: {fileID: 410087042}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &410087040
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 410087039}
m_Enabled: 1
serializedVersion: 10
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Intensity: 2
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 4
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 5000
m_UseColorTemperature: 1
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_UseViewFrustumForShadowCasterCull: 1
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &410087041
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 410087039}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!114 &410087042
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 410087039}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Version: 1
m_UsePipelineSettings: 1
m_AdditionalLightsShadowResolutionTier: 2
m_LightLayerMask: 1
m_CustomShadowLayers: 0
m_ShadowLayerMask: 1
m_LightCookieSize: {x: 1, y: 1}
m_LightCookieOffset: {x: 0, y: 0}
--- !u!1 &832575517
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 832575519}
- component: {fileID: 832575518}
m_Layer: 0
m_Name: Global Volume
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &832575518
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 832575517}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 172515602e62fb746b5d573b38a5fe58, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IsGlobal: 1
priority: 0
blendDistance: 0
weight: 1
sharedProfile: {fileID: 11400000, guid: a6560a915ef98420e9faacc1c7438823, type: 2}
--- !u!4 &832575519
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 832575517}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 068a2cb49c53e7046b005414f1402093
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 900cdb82ea9f39a4189968168b5ee4a9
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -9,7 +9,7 @@ TagManager:
- Default - Default
- TransparentFX - TransparentFX
- Ignore Raycast - Ignore Raycast
- - Player
- Water - Water
- UI - UI
- -