Imported basic unity packages yeehaw
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace StarterAssets
|
||||
{
|
||||
public partial class StarterAssetsDeployMenu : ScriptableObject
|
||||
{
|
||||
// prefab paths
|
||||
private const string FirstPersonPrefabPath = "/FirstPersonController/Prefabs/";
|
||||
|
||||
#if STARTER_ASSETS_PACKAGES_CHECKED
|
||||
/// <summary>
|
||||
/// Check the capsule, main camera, cinemachine virtual camera, camera target and references
|
||||
/// </summary>
|
||||
[MenuItem(MenuRoot + "/Reset First Person Controller", false)]
|
||||
static void ResetFirstPersonControllerCapsule()
|
||||
{
|
||||
var firstPersonControllers = FindObjectsOfType<FirstPersonController>();
|
||||
var player = firstPersonControllers.FirstOrDefault(controller => controller.CompareTag(PlayerTag));
|
||||
GameObject playerGameObject;
|
||||
|
||||
// player
|
||||
if (player == null)
|
||||
HandleInstantiatingPrefab(StarterAssetsPath + FirstPersonPrefabPath,
|
||||
PlayerCapsulePrefabName, out playerGameObject);
|
||||
else
|
||||
playerGameObject = player.gameObject;
|
||||
|
||||
// cameras
|
||||
CheckCameras(FirstPersonPrefabPath, playerGameObject.transform);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9387ada430244cac953616bcaca61424
|
||||
timeCreated: 1621533817
|
||||
8
Assets/StarterAssets/Editor/PackageChecker.meta
Normal file
8
Assets/StarterAssets/Editor/PackageChecker.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 14bd68b8c6966124487020c02c9b7f9d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
269
Assets/StarterAssets/Editor/PackageChecker/PackageChecker.cs
Normal file
269
Assets/StarterAssets/Editor/PackageChecker/PackageChecker.cs
Normal file
@@ -0,0 +1,269 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEditor.PackageManager;
|
||||
using UnityEditor.PackageManager.Requests;
|
||||
using UnityEngine;
|
||||
using PackageInfo = UnityEditor.PackageManager.PackageInfo;
|
||||
|
||||
namespace StarterAssets
|
||||
{
|
||||
public static class PackageChecker
|
||||
{
|
||||
private static ListRequest clientList;
|
||||
private static SearchRequest compatibleList;
|
||||
private static List<PackageEntry> packagesToAdd;
|
||||
|
||||
private static AddRequest[] addRequests;
|
||||
private static bool[] installRequired;
|
||||
|
||||
private static readonly string EditorFolderRoot = "Assets/StarterAssets/";
|
||||
private static readonly string PackagesToImportDataFile = "PackageImportList.txt";
|
||||
public static readonly string PackageCheckerScriptingDefine = "STARTER_ASSETS_PACKAGES_CHECKED";
|
||||
|
||||
[InitializeOnLoadMethod]
|
||||
private static void CheckPackage()
|
||||
{
|
||||
// if we dont have the scripting define, it means the check has not been done
|
||||
if (!ScriptingDefineUtils.CheckScriptingDefine(PackageCheckerScriptingDefine))
|
||||
{
|
||||
packagesToAdd = new List<PackageEntry>();
|
||||
clientList = null;
|
||||
compatibleList = null;
|
||||
|
||||
// find the projects required package list
|
||||
var requiredPackagesListFile = Directory.GetFiles(Application.dataPath, PackagesToImportDataFile,
|
||||
SearchOption.AllDirectories);
|
||||
|
||||
// if no PackageImportList.txt exists
|
||||
if (requiredPackagesListFile.Length == 0)
|
||||
{
|
||||
Debug.LogError(
|
||||
"[Auto Package] : Couldn't find the packages list. Be sure there is a file called PackageImportList in your project");
|
||||
}
|
||||
else
|
||||
{
|
||||
packagesToAdd = new List<PackageEntry>();
|
||||
|
||||
string packageListPath = requiredPackagesListFile[0];
|
||||
string[] content = File.ReadAllLines(packageListPath);
|
||||
|
||||
foreach (string line in content)
|
||||
{
|
||||
string[] split = line.Split('@');
|
||||
|
||||
// if no version is given, return null
|
||||
PackageEntry entry = new PackageEntry
|
||||
{name = split[0], version = split.Length > 1 ? split[1] : null};
|
||||
|
||||
packagesToAdd.Add(entry);
|
||||
}
|
||||
|
||||
// Create a file in library that is queried to see if CheckPackage() has been run already
|
||||
ScriptingDefineUtils.SetScriptingDefine(PackageCheckerScriptingDefine);
|
||||
|
||||
// create a list of compatible packages for current engine version
|
||||
compatibleList = Client.SearchAll();
|
||||
|
||||
while (!compatibleList.IsCompleted)
|
||||
{
|
||||
if (compatibleList.Status == StatusCode.Failure || compatibleList.Error != null)
|
||||
{
|
||||
Debug.LogError(compatibleList.Error.message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// create a list of packages found in the engine
|
||||
clientList = Client.List();
|
||||
|
||||
while (!clientList.IsCompleted)
|
||||
{
|
||||
if (clientList.Status == StatusCode.Failure || clientList.Error != null)
|
||||
{
|
||||
Debug.LogError(clientList.Error.message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
addRequests = new AddRequest[packagesToAdd.Count];
|
||||
installRequired = new bool[packagesToAdd.Count];
|
||||
|
||||
// default new packages to install = false. we will mark true after validating they're required
|
||||
for (int i = 0; i < installRequired.Length; i++)
|
||||
{
|
||||
installRequired[i] = false;
|
||||
}
|
||||
|
||||
// build data collections compatible packages for this project, and packages within the project
|
||||
List<PackageInfo> compatiblePackages =
|
||||
new List<PackageInfo>();
|
||||
List<PackageInfo> clientPackages =
|
||||
new List<PackageInfo>();
|
||||
|
||||
foreach (var result in compatibleList.Result)
|
||||
{
|
||||
compatiblePackages.Add(result);
|
||||
}
|
||||
|
||||
foreach (var result in clientList.Result)
|
||||
{
|
||||
clientPackages.Add(result);
|
||||
}
|
||||
|
||||
// check for the latest verified package version for each package that is missing a version
|
||||
for (int i = 0; i < packagesToAdd.Count; i++)
|
||||
{
|
||||
// if a version number is not provided
|
||||
if (packagesToAdd[i].version == null)
|
||||
{
|
||||
foreach (var package in compatiblePackages)
|
||||
{
|
||||
// if no latest verified version found, PackageChecker will just install latest release
|
||||
if (packagesToAdd[i].name == package.name && package.versions.verified != string.Empty)
|
||||
{
|
||||
// add latest verified version number to the packagetoadd list version
|
||||
// so that we get the latest verified version only
|
||||
packagesToAdd[i].version = package.versions.verified;
|
||||
|
||||
// add to our install list
|
||||
installRequired[i] = true;
|
||||
|
||||
//Debug.Log(string.Format("Requested {0}. Latest verified compatible package found: {1}",
|
||||
// packagesToAdd[i].name, packagesToAdd[i].version));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// we don't need to catch packages that are not installed as their latest version has been collected
|
||||
// from the campatiblelist result
|
||||
foreach (var package in clientPackages)
|
||||
{
|
||||
if (packagesToAdd[i].name == package.name)
|
||||
{
|
||||
// see what version we have installed
|
||||
switch (CompareVersion(packagesToAdd[i].version, package.version))
|
||||
{
|
||||
// latest verified is ahead of installed version
|
||||
case 1:
|
||||
installRequired[i] = EditorUtility.DisplayDialog("Confirm Package Upgrade",
|
||||
$"The version of \"{packagesToAdd[i].name}\" in this project is {package.version}. The latest verified " +
|
||||
$"version is {packagesToAdd[i].version}. Would you like to upgrade it to the latest version? (Recommended)",
|
||||
"Yes", "No");
|
||||
|
||||
Debug.Log(
|
||||
$"<b>Package version behind</b>: {package.packageId} is behind latest verified " +
|
||||
$"version {package.versions.verified}. prompting user install");
|
||||
break;
|
||||
|
||||
// latest verified matches installed version
|
||||
case 0:
|
||||
installRequired[i] = false;
|
||||
|
||||
Debug.Log(
|
||||
$"<b>Package version match</b>: {package.packageId} matches latest verified version " +
|
||||
$"{package.versions.verified}. Skipped install");
|
||||
break;
|
||||
|
||||
// latest verified is behind installed version
|
||||
case -1:
|
||||
installRequired[i] = EditorUtility.DisplayDialog("Confirm Package Downgrade",
|
||||
$"The version of \"{packagesToAdd[i].name}\" in this project is {package.version}. The latest verified version is {packagesToAdd[i].version}. " +
|
||||
$"{package.version} is unverified. Would you like to downgrade it to the latest verified version? " +
|
||||
"(Recommended)", "Yes", "No");
|
||||
|
||||
Debug.Log(
|
||||
$"<b>Package version ahead</b>: {package.packageId} is newer than latest verified " +
|
||||
$"version {package.versions.verified}, skipped install");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// install our packages and versions
|
||||
for (int i = 0; i < packagesToAdd.Count; i++)
|
||||
{
|
||||
if (installRequired[i])
|
||||
{
|
||||
addRequests[i] = InstallSelectedPackage(packagesToAdd[i].name, packagesToAdd[i].version);
|
||||
}
|
||||
}
|
||||
|
||||
ReimportPackagesByKeyword();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static AddRequest InstallSelectedPackage(string packageName, string packageVersion)
|
||||
{
|
||||
if (packageVersion != null)
|
||||
{
|
||||
packageName = packageName + "@" + packageVersion;
|
||||
Debug.Log($"<b>Adding package</b>: {packageName}");
|
||||
}
|
||||
|
||||
AddRequest newPackage = Client.Add(packageName);
|
||||
|
||||
while (!newPackage.IsCompleted)
|
||||
{
|
||||
if (newPackage.Status == StatusCode.Failure || newPackage.Error != null)
|
||||
{
|
||||
Debug.LogError(newPackage.Error.message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return newPackage;
|
||||
}
|
||||
|
||||
private static void ReimportPackagesByKeyword()
|
||||
{
|
||||
AssetDatabase.Refresh();
|
||||
AssetDatabase.ImportAsset(EditorFolderRoot, ImportAssetOptions.ImportRecursive);
|
||||
}
|
||||
|
||||
public static int CompareVersion(string latestVerifiedVersion, string projectVersion)
|
||||
{
|
||||
string[] latestVersionSplit = latestVerifiedVersion.Split('.');
|
||||
string[] projectVersionSplit = projectVersion.Split('.');
|
||||
int iteratorA = 0;
|
||||
int iteratorB = 0;
|
||||
|
||||
while (iteratorA < latestVersionSplit.Length || iteratorB < projectVersionSplit.Length)
|
||||
{
|
||||
int latestVerified = 0;
|
||||
int installed = 0;
|
||||
|
||||
if (iteratorA < latestVersionSplit.Length)
|
||||
{
|
||||
latestVerified = Convert.ToInt32(latestVersionSplit[iteratorA]);
|
||||
}
|
||||
|
||||
if (iteratorB < projectVersionSplit.Length)
|
||||
{
|
||||
installed = Convert.ToInt32(projectVersionSplit[iteratorB]);
|
||||
}
|
||||
|
||||
// latest verified is ahead of installed version
|
||||
if (latestVerified > installed) return 1;
|
||||
|
||||
// latest verified is behind installed version
|
||||
if (latestVerified < installed) return -1;
|
||||
|
||||
iteratorA++;
|
||||
iteratorB++;
|
||||
}
|
||||
|
||||
// if the version is the same
|
||||
return 0;
|
||||
}
|
||||
|
||||
public class PackageEntry
|
||||
{
|
||||
public string name;
|
||||
public string version;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7315d24058889bb4da8c959c3f2ebaa2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,2 @@
|
||||
com.unity.cinemachine
|
||||
com.unity.inputsystem
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 77db531f6c7d0ce4da51f6017f51c622
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
36
Assets/StarterAssets/Editor/ScriptingDefineUtils.cs
Normal file
36
Assets/StarterAssets/Editor/ScriptingDefineUtils.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using UnityEditor;
|
||||
|
||||
namespace StarterAssets
|
||||
{
|
||||
public static class ScriptingDefineUtils
|
||||
{
|
||||
public static bool CheckScriptingDefine(string scriptingDefine)
|
||||
{
|
||||
BuildTargetGroup buildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup;
|
||||
var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup);
|
||||
return defines.Contains(scriptingDefine);
|
||||
}
|
||||
|
||||
public static void SetScriptingDefine(string scriptingDefine)
|
||||
{
|
||||
BuildTargetGroup buildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup;
|
||||
var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup);
|
||||
if (!defines.Contains(scriptingDefine))
|
||||
{
|
||||
defines += $";{scriptingDefine}";
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, defines);
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveScriptingDefine(string scriptingDefine)
|
||||
{
|
||||
BuildTargetGroup buildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup;
|
||||
var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup);
|
||||
if (defines.Contains(scriptingDefine))
|
||||
{
|
||||
string newDefines = defines.Replace(scriptingDefine, "");
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, newDefines);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/StarterAssets/Editor/ScriptingDefineUtils.cs.meta
Normal file
3
Assets/StarterAssets/Editor/ScriptingDefineUtils.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 19d5e2567c974ac6817cbc0ae63e638c
|
||||
timeCreated: 1620921242
|
||||
140
Assets/StarterAssets/Editor/StarterAssetsDeployMenu.cs
Normal file
140
Assets/StarterAssets/Editor/StarterAssetsDeployMenu.cs
Normal file
@@ -0,0 +1,140 @@
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
#if STARTER_ASSETS_PACKAGES_CHECKED
|
||||
using Cinemachine;
|
||||
#endif
|
||||
|
||||
namespace StarterAssets
|
||||
{
|
||||
// This class needs to be a scriptable object to support dynamic determination of StarterAssets install path
|
||||
public partial class StarterAssetsDeployMenu : ScriptableObject
|
||||
{
|
||||
public const string MenuRoot = "Tools/Starter Assets";
|
||||
|
||||
// prefab names
|
||||
private const string MainCameraPrefabName = "MainCamera";
|
||||
private const string PlayerCapsulePrefabName = "PlayerCapsule";
|
||||
|
||||
// names in hierarchy
|
||||
private const string CinemachineVirtualCameraName = "PlayerFollowCamera";
|
||||
|
||||
// tags
|
||||
private const string PlayerTag = "Player";
|
||||
private const string MainCameraTag = "MainCamera";
|
||||
private const string CinemachineTargetTag = "CinemachineTarget";
|
||||
|
||||
// Get the path to the template prefabs
|
||||
private static string StarterAssetsPath => PathToThisFile;
|
||||
|
||||
private static GameObject _cinemachineVirtualCamera;
|
||||
|
||||
/// <summary>
|
||||
/// Get the relative root path of the StarterAssets install - works even if user has
|
||||
/// moved it within Assets, so long as user does not mess with the internal hierarchy
|
||||
/// of the StarterAssets folder
|
||||
/// </summary>
|
||||
public static string StarterAssetsInstallPath
|
||||
{
|
||||
get
|
||||
{
|
||||
string path = PathToThisFile;
|
||||
// where this file is relative to install path:
|
||||
return path.Substring(0, path.LastIndexOf("StarterAssets"));
|
||||
}
|
||||
}
|
||||
|
||||
private static string PathToThisFile
|
||||
{
|
||||
get
|
||||
{
|
||||
var dummy = CreateInstance<StarterAssetsDeployMenu>();
|
||||
string path = AssetDatabase.GetAssetPath(MonoScript.FromScriptableObject(dummy));
|
||||
DestroyImmediate(dummy);
|
||||
return path.Substring(0, path.LastIndexOf("/Editor/StarterAssetsDeployMenu.cs"));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the scripting define set by the Package Checker.
|
||||
/// See Assets/Editor/PackageChecker/PackageChecker.cs for more information
|
||||
/// </summary>
|
||||
[MenuItem(MenuRoot + "/Reinstall Dependencies", false)]
|
||||
static void ResetPackageChecker()
|
||||
{
|
||||
ScriptingDefineUtils.RemoveScriptingDefine(PackageChecker.PackageCheckerScriptingDefine);
|
||||
}
|
||||
|
||||
#if STARTER_ASSETS_PACKAGES_CHECKED
|
||||
private static void CheckCameras(string prefabPath, Transform targetParent)
|
||||
{
|
||||
CheckMainCamera(prefabPath);
|
||||
|
||||
GameObject vcam = GameObject.Find(CinemachineVirtualCameraName);
|
||||
|
||||
if (!vcam)
|
||||
{
|
||||
HandleInstantiatingPrefab(StarterAssetsPath + prefabPath,
|
||||
CinemachineVirtualCameraName,
|
||||
out GameObject vcamPrefab);
|
||||
_cinemachineVirtualCamera = vcamPrefab;
|
||||
}
|
||||
else
|
||||
{
|
||||
_cinemachineVirtualCamera = vcam;
|
||||
}
|
||||
|
||||
GameObject[] targets = GameObject.FindGameObjectsWithTag(CinemachineTargetTag);
|
||||
GameObject target = targets.FirstOrDefault(t => t.transform.IsChildOf(targetParent));
|
||||
if (target == null)
|
||||
{
|
||||
target = new GameObject("PlayerCameraRoot");
|
||||
target.transform.SetParent(targetParent);
|
||||
target.transform.localPosition = new Vector3(0f, 1.375f, 0f);
|
||||
target.tag = CinemachineTargetTag;
|
||||
Undo.RegisterCreatedObjectUndo(target, "Created new cinemachine target");
|
||||
}
|
||||
CheckVirtualCameraFollowReference(target, _cinemachineVirtualCamera);
|
||||
}
|
||||
|
||||
private static void CheckMainCamera(string prefabPath)
|
||||
{
|
||||
GameObject[] mainCameras = GameObject.FindGameObjectsWithTag(MainCameraTag);
|
||||
|
||||
if (mainCameras.Length < 1)
|
||||
{
|
||||
// if there are no MainCameras, add one
|
||||
HandleInstantiatingPrefab(StarterAssetsPath + prefabPath, MainCameraPrefabName,
|
||||
out _);
|
||||
}
|
||||
else
|
||||
{
|
||||
// make sure the found camera has a cinemachine brain (we only need 1)
|
||||
if (!mainCameras[0].TryGetComponent(out CinemachineBrain cinemachineBrain))
|
||||
mainCameras[0].AddComponent<CinemachineBrain>();
|
||||
}
|
||||
}
|
||||
|
||||
private static void CheckVirtualCameraFollowReference(GameObject target,
|
||||
GameObject cinemachineVirtualCamera)
|
||||
{
|
||||
var serializedObject =
|
||||
new SerializedObject(cinemachineVirtualCamera.GetComponent<CinemachineVirtualCamera>());
|
||||
var serializedProperty = serializedObject.FindProperty("m_Follow");
|
||||
serializedProperty.objectReferenceValue = target.transform;
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private static void HandleInstantiatingPrefab(string path, string prefabName, out GameObject prefab)
|
||||
{
|
||||
prefab = (GameObject) PrefabUtility.InstantiatePrefab(
|
||||
AssetDatabase.LoadAssetAtPath<Object>($"{path}{prefabName}.prefab"));
|
||||
Undo.RegisterCreatedObjectUndo(prefab, "Instantiate Starter Asset Prefab");
|
||||
|
||||
prefab.transform.localPosition = Vector3.zero;
|
||||
prefab.transform.localEulerAngles = Vector3.zero;
|
||||
prefab.transform.localScale = Vector3.one;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
11
Assets/StarterAssets/Editor/StarterAssetsDeployMenu.cs.meta
Normal file
11
Assets/StarterAssets/Editor/StarterAssetsDeployMenu.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e75357183ea302c4d998136de2cc9669
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,54 @@
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace StarterAssets
|
||||
{
|
||||
public partial class StarterAssetsDeployMenu : ScriptableObject
|
||||
{
|
||||
// prefab paths
|
||||
private const string ThirdPersonPrefabPath = "/ThirdPersonController/Prefabs/";
|
||||
private const string PlayerArmaturePrefabName = "PlayerArmature";
|
||||
|
||||
#if STARTER_ASSETS_PACKAGES_CHECKED
|
||||
/// <summary>
|
||||
/// Check the Armature, main camera, cinemachine virtual camera, camera target and references
|
||||
/// </summary>
|
||||
[MenuItem(MenuRoot + "/Reset Third Person Controller Armature", false)]
|
||||
static void ResetThirdPersonControllerArmature()
|
||||
{
|
||||
var thirdPersonControllers = FindObjectsOfType<ThirdPersonController>();
|
||||
var player = thirdPersonControllers.FirstOrDefault(controller => controller.GetComponent<Animator>() && controller.CompareTag(PlayerTag));
|
||||
GameObject playerGameObject;
|
||||
|
||||
// player
|
||||
if (player == null)
|
||||
HandleInstantiatingPrefab(StarterAssetsPath + ThirdPersonPrefabPath,
|
||||
PlayerArmaturePrefabName, out playerGameObject);
|
||||
else
|
||||
playerGameObject = player.gameObject;
|
||||
|
||||
// cameras
|
||||
CheckCameras(ThirdPersonPrefabPath, playerGameObject.transform);
|
||||
}
|
||||
|
||||
[MenuItem(MenuRoot + "/Reset Third Person Controller Capsule", false)]
|
||||
static void ResetThirdPersonControllerCapsule()
|
||||
{
|
||||
var thirdPersonControllers = FindObjectsOfType<ThirdPersonController>();
|
||||
var player = thirdPersonControllers.FirstOrDefault(controller => !controller.GetComponent<Animator>() && controller.CompareTag(PlayerTag));
|
||||
GameObject playerGameObject;
|
||||
|
||||
// player
|
||||
if (player == null)
|
||||
HandleInstantiatingPrefab(StarterAssetsPath + ThirdPersonPrefabPath,
|
||||
PlayerCapsulePrefabName, out playerGameObject);
|
||||
else
|
||||
playerGameObject = player.gameObject;
|
||||
|
||||
// cameras
|
||||
CheckCameras(ThirdPersonPrefabPath, playerGameObject.transform);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b70f45aa92a641feb261c5d55ce46edf
|
||||
timeCreated: 1621532436
|
||||
Reference in New Issue
Block a user