浏览代码

SpawnSystem active in the scene

Removed the player prefab from the scene
/main
Ciro Continisio 4 年前
当前提交
2cfc9750
共有 2 个文件被更改,包括 109 次插入107 次删除
  1. 189
      UOP1_Project/Assets/Scenes/CharController.unity
  2. 27
      UOP1_Project/Assets/Scripts/SpawnSystem.cs

189
UOP1_Project/Assets/Scenes/CharController.unity


m_StreamingVersion: 20170927
m_Priority: 10
m_StandbyUpdate: 2
m_LookAt: {fileID: 1961901426}
m_Follow: {fileID: 1961901426}
m_LookAt: {fileID: 0}
m_Follow: {fileID: 0}
m_Lens:
FieldOfView: 60
OrthographicSize: 5

m_Children:
- {fileID: 2020721999}
m_Father: {fileID: 0}
m_RootOrder: 4
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &135922106
MonoBehaviour:

m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 233317031}
m_LocalRotation: {x: 0.18994758, y: -0.20527026, z: 0.040647585, w: 0.959235}
m_LocalRotation: {x: 0.18994758, y: -0.2052703, z: 0.040647592, w: 0.959235}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:

m_LocalScale: {x: 5.7737727, y: 1.8967, z: 4.9019}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 13
m_RootOrder: 14
m_LocalEulerAnglesHint: {x: -3.5180001, y: 26.323002, z: -19.474}
--- !u!1 &353533559
GameObject:

m_LocalScale: {x: 4.8320527, y: 1, z: 4.9019}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 11
m_RootOrder: 12
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &358843509
GameObject:

m_LocalScale: {x: 7.8816566, y: 6.5043144, z: 2.0265193}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 24
m_RootOrder: 25
m_LocalEulerAnglesHint: {x: 0, y: 90.00001, z: 0}
--- !u!1001 &393067907
PrefabInstance:

- target: {fileID: 7160299325435046207, guid: fe3004506b4c6cd478eb2cca639b3713,
type: 3}
propertyPath: m_RootOrder
value: 21
value: 22
objectReference: {fileID: 0}
- target: {fileID: 7160299325435046207, guid: fe3004506b4c6cd478eb2cca639b3713,
type: 3}

m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 8
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &526256409
GameObject:

m_Name:
m_EditorClassIdentifier:
inputReader: {fileID: 11400000, guid: 945ec0365077176418488737deed54be, type: 2}
mainCamera: {fileID: 1961065789}
freeLookVCam: {fileID: 1502793901}
--- !u!4 &526256411
Transform:

m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &695792052
GameObject:

m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 9
m_RootOrder: 10
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &802198071
PrefabInstance:

- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
type: 3}
propertyPath: m_RootOrder
value: 16
value: 17
objectReference: {fileID: 0}
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
type: 3}

m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 7
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &826602623
GameObject:

m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 6
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &955504286
GameObject:

m_LocalScale: {x: 4.66705, y: 1, z: 4.9019}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 10
m_RootOrder: 11
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &982338980
GameObject:

m_LocalScale: {x: 4.66705, y: 1, z: 4.9019}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 25
m_RootOrder: 26
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 12.259001}
--- !u!1 &1057381576
GameObject:

m_LocalScale: {x: 6.068361, y: 6.5043144, z: 0.65092325}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 23
m_RootOrder: 24
m_LocalEulerAnglesHint: {x: 0, y: -34.734, z: 0}
--- !u!1 &1069143686
GameObject:

m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1069947040
GameObject:

- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
type: 3}
propertyPath: m_RootOrder
value: 17
value: 18
objectReference: {fileID: 0}
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
type: 3}

m_LocalScale: {x: 9.785265, y: 1.1941, z: 1.4703052}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 12
m_RootOrder: 13
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1424964852
GameObject:

m_LocalScale: {x: 11.689932, y: 6.5043144, z: 2.0265193}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 22
m_RootOrder: 23
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1502793900
GameObject:

m_StreamingVersion: 20170927
m_Priority: 10
m_StandbyUpdate: 2
m_LookAt: {fileID: 1961901426}
m_Follow: {fileID: 1961901426}
m_LookAt: {fileID: 0}
m_Follow: {fileID: 0}
m_CommonLens: 1
m_Lens:
FieldOfView: 40

- {fileID: 2049112421}
- {fileID: 233317033}
m_Father: {fileID: 0}
m_RootOrder: 5
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1523164311
GameObject:

m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 27
m_RootOrder: 28
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1559010558
GameObject:

m_LocalScale: {x: 4.66705, y: 1, z: 4.9019}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 26
m_RootOrder: 27
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 12.259001}
--- !u!1 &1567022179
GameObject:

m_LocalScale: {x: 5.7737727, y: 1.8967, z: 4.9019}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 15
m_RootOrder: 16
m_LocalEulerAnglesHint: {x: -3.5180001, y: 26.324001, z: 28.011002}
--- !u!1001 &1809933188
PrefabInstance:

- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
type: 3}
propertyPath: m_RootOrder
value: 20
value: 21
objectReference: {fileID: 0}
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
type: 3}

- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
type: 3}
propertyPath: m_RootOrder
value: 19
value: 20
objectReference: {fileID: 0}
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
type: 3}

m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1961065787}
m_LocalRotation: {x: 0.18778463, y: -0.20536137, z: 0.040184725, w: 0.95966077}
m_LocalRotation: {x: 0.18778464, y: -0.20536137, z: 0.040184725, w: 0.9596608}
m_RootOrder: 3
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1961065791
MonoBehaviour:

m_CameraActivatedEvent:
m_PersistentCalls:
m_Calls: []
--- !u!4 &1961901426 stripped
--- !u!4 &2006012550 stripped
m_CorrespondingSourceObject: {fileID: 3341179906418240731, guid: 0fa393e1e37bc9e4e829c25a9452bcd3,
m_CorrespondingSourceObject: {fileID: 2125786286893897154, guid: e978d53d440e0814086759404585ac32,
m_PrefabInstance: {fileID: 3341179907149091243}
m_PrefabInstance: {fileID: 2093632590}
m_PrefabAsset: {fileID: 0}
--- !u!1 &2018663598
GameObject:

m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2049112419}
m_LocalRotation: {x: 0.18778461, y: -0.20536137, z: 0.04018472, w: 0.9596608}
m_LocalRotation: {x: 0.18778461, y: -0.20536137, z: 0.040184718, w: 0.9596608}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:

m_Script: {fileID: 11500000, guid: ac0b09e7857660247b1477e93731de29, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &2370768318719443585
--- !u!1001 &2093632590
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2

- target: {fileID: 364731123117828817, guid: 1ebb75c12ef91014e94524019e01192d,
- target: {fileID: 2125786285293829329, guid: e978d53d440e0814086759404585ac32,
value: SmallBuilding
value: SpawnSystem
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
- target: {fileID: 2125786285293829334, guid: e978d53d440e0814086759404585ac32,
type: 3}
propertyPath: _spawnLocations.Array.size
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2125786285293829334, guid: e978d53d440e0814086759404585ac32,
type: 3}
propertyPath: _cameraManager
value:
objectReference: {fileID: 526256410}
- target: {fileID: 2125786285293829334, guid: e978d53d440e0814086759404585ac32,
type: 3}
propertyPath: _spawnLocations.Array.data[0]
value:
objectReference: {fileID: 2006012550}
- target: {fileID: 2125786285293829335, guid: e978d53d440e0814086759404585ac32,
value: -17.85
value: 0
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
- target: {fileID: 2125786285293829335, guid: e978d53d440e0814086759404585ac32,
value: -0.14
value: 0
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
- target: {fileID: 2125786285293829335, guid: e978d53d440e0814086759404585ac32,
value: 9.51
value: 0
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
- target: {fileID: 2125786285293829335, guid: e978d53d440e0814086759404585ac32,
value: -0
value: 0
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
- target: {fileID: 2125786285293829335, guid: e978d53d440e0814086759404585ac32,
value: -0
value: 0
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
- target: {fileID: 2125786285293829335, guid: e978d53d440e0814086759404585ac32,
value: -0.019262606
value: 0
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
- target: {fileID: 2125786285293829335, guid: e978d53d440e0814086759404585ac32,
value: 0.99981445
value: 1
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
- target: {fileID: 2125786285293829335, guid: e978d53d440e0814086759404585ac32,
value: 14
value: 1
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
- target: {fileID: 2125786285293829335, guid: e978d53d440e0814086759404585ac32,
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
- target: {fileID: 2125786285293829335, guid: e978d53d440e0814086759404585ac32,
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
- target: {fileID: 2125786285293829335, guid: e978d53d440e0814086759404585ac32,
value: -2.207
value: 0
m_SourcePrefab: {fileID: 100100000, guid: 1ebb75c12ef91014e94524019e01192d, type: 3}
--- !u!1001 &3341179907149091243
m_SourcePrefab: {fileID: 100100000, guid: e978d53d440e0814086759404585ac32, type: 3}
--- !u!1001 &2370768318719443585
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2

- target: {fileID: 211818859182309264, guid: 0fa393e1e37bc9e4e829c25a9452bcd3,
type: 3}
propertyPath: gameplayCamera
value:
objectReference: {fileID: 1961065790}
- target: {fileID: 3341179906418240709, guid: 0fa393e1e37bc9e4e829c25a9452bcd3,
- target: {fileID: 364731123117828817, guid: 1ebb75c12ef91014e94524019e01192d,
value: Pig
value: SmallBuilding
- target: {fileID: 3341179906418240731, guid: 0fa393e1e37bc9e4e829c25a9452bcd3,
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
value: 0.62
value: -17.85
- target: {fileID: 3341179906418240731, guid: 0fa393e1e37bc9e4e829c25a9452bcd3,
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
value: 0.307
value: -0.14
- target: {fileID: 3341179906418240731, guid: 0fa393e1e37bc9e4e829c25a9452bcd3,
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
value: -15.776
value: 9.51
- target: {fileID: 3341179906418240731, guid: 0fa393e1e37bc9e4e829c25a9452bcd3,
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
value: 0
value: -0
- target: {fileID: 3341179906418240731, guid: 0fa393e1e37bc9e4e829c25a9452bcd3,
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
value: 0
value: -0
- target: {fileID: 3341179906418240731, guid: 0fa393e1e37bc9e4e829c25a9452bcd3,
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
value: 0
value: -0.019262606
- target: {fileID: 3341179906418240731, guid: 0fa393e1e37bc9e4e829c25a9452bcd3,
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
value: 1
value: 0.99981445
- target: {fileID: 3341179906418240731, guid: 0fa393e1e37bc9e4e829c25a9452bcd3,
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
value: 28
value: 15
- target: {fileID: 3341179906418240731, guid: 0fa393e1e37bc9e4e829c25a9452bcd3,
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
- target: {fileID: 3341179906418240731, guid: 0fa393e1e37bc9e4e829c25a9452bcd3,
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
- target: {fileID: 3341179906418240731, guid: 0fa393e1e37bc9e4e829c25a9452bcd3,
- target: {fileID: 384383464925863578, guid: 1ebb75c12ef91014e94524019e01192d,
value: 0
value: -2.207
m_SourcePrefab: {fileID: 100100000, guid: 0fa393e1e37bc9e4e829c25a9452bcd3, type: 3}
m_SourcePrefab: {fileID: 100100000, guid: 1ebb75c12ef91014e94524019e01192d, type: 3}
--- !u!1001 &6560919939139749480
PrefabInstance:
m_ObjectHideFlags: 0

- target: {fileID: 7160299325435046207, guid: fe3004506b4c6cd478eb2cca639b3713,
type: 3}
propertyPath: m_RootOrder
value: 18
value: 19
objectReference: {fileID: 0}
- target: {fileID: 7160299325435046207, guid: fe3004506b4c6cd478eb2cca639b3713,
type: 3}

27
UOP1_Project/Assets/Scripts/SpawnSystem.cs


[SerializeField] private Protagonist _playerPrefab = null;
[Header("Scene References")]
[SerializeField] private InputReader _inputReader;
[SerializeField] private CameraManager _cameraManager;
[SerializeField] private Transform[] _spawnLocations;

[ContextMenu("Attempt Auto Fill")]
private void AutoFill()
{
if (_inputReader == null)
_inputReader = FindObjectOfType<InputReader>();
if(_cameraManager == null)
_cameraManager = FindObjectOfType<CameraManager>();

private void Spawn(int spawnIndex)
{
Transform spawnLocation = GetSpawnLocation(spawnIndex, _spawnLocations);
Protagonist playerInstance = InstantiatePlayer(_playerPrefab, spawnLocation, _inputReader, _cameraManager);
Protagonist playerInstance = InstantiatePlayer(_playerPrefab, spawnLocation, _cameraManager);
SetupCameras(playerInstance);
}
private Transform GetSpawnLocation(int index, Transform[] spawnLocations)

return spawnLocations[index];
}
private Protagonist InstantiatePlayer(Protagonist playerPrefab, Transform spawnLocation, InputReader inputReader, CameraManager _cameraManager)
private Protagonist InstantiatePlayer(Protagonist playerPrefab, Transform spawnLocation, CameraManager _cameraManager)
bool originalState = playerPrefab.enabled;
// Prevents playerInstance's Protagonist.OnEnable from running now
playerPrefab.enabled = false;
playerPrefab.enabled = originalState;
playerInstance.inputReader = inputReader;
playerInstance.gameplayCamera = _cameraManager.mainCamera.transform;
// Since the prefab's script was disabled it need to be enabled here
playerInstance.enabled = true;
return playerInstance;
}
//Feed the player to the CameraManager
_cameraManager.SetupProtagonistVirtualCamera(playerInstance.transform);
return playerInstance;
private void SetupCameras(Protagonist player)
{
player.gameplayCamera = _cameraManager.mainCamera.transform;
_cameraManager.SetupProtagonistVirtualCamera(player.transform);
}
}
正在加载...
取消
保存