Compare commits
5 Commits
06d3aaf077
...
7b62494ad5
Author | SHA1 | Date | |
---|---|---|---|
7b62494ad5 | |||
2564b4be67 | |||
d43efed5d7 | |||
![]() |
47ab5d8a0c | ||
![]() |
ddb65d9398 |
@ -18,7 +18,7 @@ private void OnPreprocessTexture()
|
|||||||
// AssetPostprocessorModel.OnPreprocessTexture(importer);
|
// AssetPostprocessorModel.OnPreprocessTexture(importer);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (upperPath.Contains("ASSETS/_DDD/_RAW/SPRITES/"))
|
if (upperPath.Contains(PathConstants.RawSpritesPathUpper))
|
||||||
{
|
{
|
||||||
AssetPostprocessorSprite.OnPreprocessTexture(importer);
|
AssetPostprocessorSprite.OnPreprocessTexture(importer);
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ public static void OnPostprocessAllAssets(string[] importedAssets, string[] dele
|
|||||||
var upperPath = toPath.ToUpper();
|
var upperPath = toPath.ToUpper();
|
||||||
|
|
||||||
// 특정 폴더일 때만 작동
|
// 특정 폴더일 때만 작동
|
||||||
if (upperPath.Contains("ASSETS/_DDD/_RAW/SPRITES/"))
|
if (upperPath.Contains(PathConstants.RawSpritesPathUpper))
|
||||||
{
|
{
|
||||||
if (AssetDatabase.LoadAssetAtPath<Sprite>(toPath) == null)
|
if (AssetDatabase.LoadAssetAtPath<Sprite>(toPath) == null)
|
||||||
{
|
{
|
||||||
|
@ -99,8 +99,8 @@ private static void TryApplyPivotAfterImport(string path)
|
|||||||
public static void OnRemove(string path, string movePath)
|
public static void OnRemove(string path, string movePath)
|
||||||
{
|
{
|
||||||
var upperPath = path.ToUpper();
|
var upperPath = path.ToUpper();
|
||||||
if (upperPath.Contains("ASSETS/_DDD/_RAW/SPRITES/") == false ||
|
if (upperPath.Contains(PathConstants.RawSpritesPathUpper) == false ||
|
||||||
upperPath.Contains(".PNG") == false) return;
|
upperPath.Contains(ExtenstionConstants.PngExtensionUpper) == false) return;
|
||||||
|
|
||||||
if (TargetPaths.Contains(path) == false)
|
if (TargetPaths.Contains(path) == false)
|
||||||
{
|
{
|
||||||
@ -111,8 +111,8 @@ public static void OnRemove(string path, string movePath)
|
|||||||
public static void OnAdd(string path)
|
public static void OnAdd(string path)
|
||||||
{
|
{
|
||||||
var upperPath = path.ToUpper();
|
var upperPath = path.ToUpper();
|
||||||
if (upperPath.Contains("ASSETS/_DDD/_RAW/SPRITES/") == false ||
|
if (upperPath.Contains(PathConstants.RawSpritesPathUpper) == false ||
|
||||||
upperPath.Contains(".PNG") == false) return;
|
upperPath.Contains(ExtenstionConstants.PngExtensionUpper) == false) return;
|
||||||
|
|
||||||
if (TargetPaths.Contains(path) == false)
|
if (TargetPaths.Contains(path) == false)
|
||||||
{
|
{
|
||||||
@ -135,15 +135,15 @@ public static void CreateAtlas(string path, string destPath)
|
|||||||
var objects = new List<Object>();
|
var objects = new List<Object>();
|
||||||
foreach (var file in di.GetFiles())
|
foreach (var file in di.GetFiles())
|
||||||
{
|
{
|
||||||
if (file.Name.ToUpper().IsRight(".PNG") == false) continue;
|
if (file.Name.ToUpper().IsRight(ExtenstionConstants.PngExtensionUpper) == false) continue;
|
||||||
var filePath = path + "/" + file.Name;
|
var filePath = path + "/" + file.Name;
|
||||||
var fileName = file.Name.Substring(0, file.Name.Length - ".png".Length);
|
var fileName = file.Name.Substring(0, file.Name.Length - ExtenstionConstants.PngExtensionLower.Length);
|
||||||
var sprite = AssetDatabase.LoadAssetAtPath<Sprite>(filePath);
|
var sprite = AssetDatabase.LoadAssetAtPath<Sprite>(filePath);
|
||||||
|
|
||||||
var maxSize = sprite.rect.size.x > sprite.rect.size.y ? sprite.rect.size.x : sprite.rect.size.y;
|
var maxSize = sprite.rect.size.x > sprite.rect.size.y ? sprite.rect.size.x : sprite.rect.size.y;
|
||||||
if (maxSize > 1024)
|
if (maxSize > 1024)
|
||||||
{
|
{
|
||||||
CreateSingleAtlas(filePath, path.Replace("/_Raw/", "/_Addressables/") + $"_{fileName}.spriteatlasv2");
|
CreateSingleAtlas(filePath, path.Replace(PathConstants.RawFolderPath, PathConstants.AddressablesFolderPath) + $"_{fileName}{ExtenstionConstants.SpriteAtlasExtenstionLower}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +243,7 @@ public static void CreatePrefab(string path, string destPath)
|
|||||||
prefab.transform.localRotation = Quaternion.identity;
|
prefab.transform.localRotation = Quaternion.identity;
|
||||||
prefab.name = sprite.name;
|
prefab.name = sprite.name;
|
||||||
|
|
||||||
GameObject visualLook = new GameObject("VisualLook");
|
GameObject visualLook = new GameObject(CommonConstants.VisualLook);
|
||||||
|
|
||||||
visualLook.transform.SetParent(prefab.transform);
|
visualLook.transform.SetParent(prefab.transform);
|
||||||
visualLook.transform.localPosition = Vector3.zero;
|
visualLook.transform.localPosition = Vector3.zero;
|
||||||
@ -253,74 +253,8 @@ public static void CreatePrefab(string path, string destPath)
|
|||||||
spriteRenderer.sprite = sprite;
|
spriteRenderer.sprite = sprite;
|
||||||
spriteRenderer.sortingOrder = 5;
|
spriteRenderer.sortingOrder = 5;
|
||||||
|
|
||||||
// var guids = AssetDatabase.FindAssets("t:Material", new string[] { Utils.FolderPath(path) });
|
|
||||||
// var materials = guids
|
|
||||||
// .Select(guid => AssetDatabase.LoadAssetAtPath<Material>(AssetDatabase.GUIDToAssetPath(guid)))
|
|
||||||
// .ToDictionary(m => m.name);
|
|
||||||
//
|
|
||||||
// foreach (var renderer in model.GetComponentsInChildren<Renderer>())
|
|
||||||
// {
|
|
||||||
// var sharedMaterials =
|
|
||||||
// new Material[renderer.sharedMaterials.Length]; // Material을 직접 엘리먼트로 대입하면 안되고 배열을 통으로 넣어야함
|
|
||||||
// for (var i = 0; i < renderer.sharedMaterials.Length; ++i)
|
|
||||||
// {
|
|
||||||
// if (materials.TryGetValue($"{renderer.name}_{i + 1}", out var numMat))
|
|
||||||
// {
|
|
||||||
// sharedMaterials[i] = numMat;
|
|
||||||
// }
|
|
||||||
// else if (materials.TryGetValue(renderer.name, out var mat))
|
|
||||||
// {
|
|
||||||
// sharedMaterials[i] = mat;
|
|
||||||
// }
|
|
||||||
// else if (materials.TryGetValue(go.name, out var defaultMat))
|
|
||||||
// {
|
|
||||||
// sharedMaterials[i] = defaultMat;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// sharedMaterials[i] = renderer.sharedMaterials[i];
|
|
||||||
// // 에러인가? 잠깐 파일 안갖다놨을뿐인가?
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// renderer.sharedMaterials = sharedMaterials;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// var res = prefab.AddComponent<SLResourceObject>();
|
|
||||||
|
|
||||||
//res.Init();
|
|
||||||
|
|
||||||
Utils.MakeFolderFromFilePath(destPath);
|
Utils.MakeFolderFromFilePath(destPath);
|
||||||
|
|
||||||
// {
|
|
||||||
// // Make Duumy(for test)
|
|
||||||
// var dummyObj = Object.Instantiate(model);
|
|
||||||
// var anim = dummyObj.GetComponentInChildren<Animator>();
|
|
||||||
// var controller =
|
|
||||||
// AnimatorController.CreateAnimatorControllerAtPath(GetPrefabPath(path)
|
|
||||||
// .Replace(".prefab", ".controller"));
|
|
||||||
//
|
|
||||||
// anim.runtimeAnimatorController = controller;
|
|
||||||
// var rootStateMachine = controller.layers[0].stateMachine;
|
|
||||||
//
|
|
||||||
// var clipids = AssetDatabase.FindAssets("t:AnimationClip",
|
|
||||||
// new string[] { SLFileUtility.FolderPath(path) });
|
|
||||||
// foreach (var guid in clipids)
|
|
||||||
// {
|
|
||||||
// var clip = AssetDatabase.LoadAssetAtPath<AnimationClip>(AssetDatabase.GUIDToAssetPath(guid));
|
|
||||||
// if (clip != null)
|
|
||||||
// {
|
|
||||||
// var state = rootStateMachine.AddState(clip.name);
|
|
||||||
// state.motion = clip;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// var dummy = PrefabUtility.SaveAsPrefabAssetAndConnect(dummyObj, GetPrefabPath(path),
|
|
||||||
// InteractionMode.AutomatedAction);
|
|
||||||
//
|
|
||||||
// Object.DestroyImmediate(dummyObj, false);
|
|
||||||
// }
|
|
||||||
|
|
||||||
AssetDatabase.DeleteAsset(destPath);
|
AssetDatabase.DeleteAsset(destPath);
|
||||||
var newPrefab =
|
var newPrefab =
|
||||||
PrefabUtility.SaveAsPrefabAssetAndConnect(prefab, destPath, InteractionMode.AutomatedAction);
|
PrefabUtility.SaveAsPrefabAssetAndConnect(prefab, destPath, InteractionMode.AutomatedAction);
|
||||||
@ -338,12 +272,9 @@ public static void BuildTarget()
|
|||||||
{
|
{
|
||||||
foreach (var path in TargetPaths)
|
foreach (var path in TargetPaths)
|
||||||
{
|
{
|
||||||
CreateAtlas(Utils.FolderPath(path),
|
CreateAtlas(Utils.FolderPath(path), Utils.FolderPath(path).Replace(PathConstants.RawFolderPath, PathConstants.AddressablesFolderPath) + ExtenstionConstants.SpriteAtlasExtenstionLower);
|
||||||
Utils.FolderPath(path).Replace("/_Raw/", "/_Addressables/") + ".spriteatlasv2");
|
|
||||||
//CreatePrefab(path, (path.Replace("/Raw/Sprites/", "/_Addressables/") + ".prefab").Replace(".png", ""));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TargetPaths.Clear();
|
TargetPaths.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public async void PostInit()
|
|||||||
{
|
{
|
||||||
if (sprite == null) continue;
|
if (sprite == null) continue;
|
||||||
|
|
||||||
var key = sprite.name.Replace("(Clone)", "").Trim();
|
var key = sprite.name.Replace(CommonConstants.Clone, string.Empty).Trim();
|
||||||
_spriteAtlas.TryAdd(key, sprite);
|
_spriteAtlas.TryAdd(key, sprite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,18 @@ public class RestaurantPlayerDataSo : ScriptableObject
|
|||||||
[Range(0f, 3f), Tooltip("슬라이딩 보정 제곱\n낮을수록 슬라이딩이 잘 됨")]
|
[Range(0f, 3f), Tooltip("슬라이딩 보정 제곱\n낮을수록 슬라이딩이 잘 됨")]
|
||||||
public float SlidingThreshold = 0.5f;
|
public float SlidingThreshold = 0.5f;
|
||||||
|
|
||||||
|
public float VelocityMinThreshold = 0.01f;
|
||||||
|
public float BoxCastExtentScale = 0.95f;
|
||||||
|
public float MinSlideFactorThreshold = 0.05f;
|
||||||
|
|
||||||
|
// 디버그
|
||||||
|
public int InputLineSortingOrder = 10;
|
||||||
|
public int VelocityLineSortingOrder = 9;
|
||||||
|
public float InputLineWidth = 0.1f;
|
||||||
|
public float VelocityLineWidth = 0.2f;
|
||||||
|
public float InputLineLength = 1.5f;
|
||||||
|
public float VelocityLineScale = 0.5f;
|
||||||
|
|
||||||
public string WalkingSfxName;
|
public string WalkingSfxName;
|
||||||
public string DashSfxName;
|
public string DashSfxName;
|
||||||
|
|
||||||
|
@ -27,6 +27,10 @@ public class RestaurantPlayerMovement : RestaurantCharacterMovement
|
|||||||
public Action<bool> OnMoving;
|
public Action<bool> OnMoving;
|
||||||
public Action<float> OnDashing;
|
public Action<float> OnDashing;
|
||||||
|
|
||||||
|
private const string InputDebugLineRenderer = "DebugLine_Input";
|
||||||
|
private const string VelocityDebugLineRenderer = "DebugLine_Velocity";
|
||||||
|
private const string SpriteDefaultShader = "Sprites/Default";
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
_rigidbody = GetComponent<Rigidbody>();
|
_rigidbody = GetComponent<Rigidbody>();
|
||||||
@ -75,17 +79,18 @@ private void OnDestroy()
|
|||||||
_playerDataSo.DashActionReference.action.performed -= OnDash;
|
_playerDataSo.DashActionReference.action.performed -= OnDash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
private void DrawLineDebug()
|
private void DrawLineDebug()
|
||||||
{
|
{
|
||||||
Vector3 origin = transform.position;
|
Vector3 origin = transform.position;
|
||||||
|
|
||||||
if (_inputDirection != Vector3.zero)
|
if (_inputDirection != Vector3.zero)
|
||||||
{
|
{
|
||||||
Vector3 target = origin + _inputDirection.normalized * 1.5f;
|
Vector3 target = origin + _inputDirection.normalized * _playerDataSo.InputLineLength;
|
||||||
if (_inputLineRenderer == null)
|
if (_inputLineRenderer == null)
|
||||||
{
|
{
|
||||||
_inputLineRenderer = CreateOrGetDebugLineRenderer("DebugLine_Input", 10, 0.1f, Color.blue);
|
_inputLineRenderer = CreateOrGetDebugLineRenderer(InputDebugLineRenderer, _playerDataSo.InputLineSortingOrder, _playerDataSo.InputLineWidth, Color.blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateLineRenderer(_inputLineRenderer, origin, target);
|
UpdateLineRenderer(_inputLineRenderer, origin, target);
|
||||||
@ -97,13 +102,13 @@ private void DrawLineDebug()
|
|||||||
}
|
}
|
||||||
|
|
||||||
float speed = _currentVelocity.magnitude;
|
float speed = _currentVelocity.magnitude;
|
||||||
if (speed > 0.01f)
|
if (speed > _playerDataSo.VelocityMinThreshold)
|
||||||
{
|
{
|
||||||
Vector3 target = origin + _currentVelocity.normalized * (speed * 0.5f);
|
Vector3 target = origin + _currentVelocity.normalized * (speed * _playerDataSo.VelocityLineScale);
|
||||||
|
|
||||||
if (_velocityLineRenderer == null)
|
if (_velocityLineRenderer == null)
|
||||||
{
|
{
|
||||||
_velocityLineRenderer = CreateOrGetDebugLineRenderer("DebugLine_Velocity", 9, 0.2f, Color.red);
|
_velocityLineRenderer = CreateOrGetDebugLineRenderer(VelocityDebugLineRenderer, _playerDataSo.VelocityLineSortingOrder, _playerDataSo.VelocityLineWidth, Color.red);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateLineRenderer(_velocityLineRenderer, origin, target);
|
UpdateLineRenderer(_velocityLineRenderer, origin, target);
|
||||||
@ -134,7 +139,7 @@ private LineRenderer CreateOrGetDebugLineRenderer(string name, int sortingIndex,
|
|||||||
|
|
||||||
var lineRenderer = newGameObject.AddComponent<LineRenderer>();
|
var lineRenderer = newGameObject.AddComponent<LineRenderer>();
|
||||||
lineRenderer.positionCount = 2;
|
lineRenderer.positionCount = 2;
|
||||||
lineRenderer.material = new Material(Shader.Find("Sprites/Default")); // URP 호환
|
lineRenderer.material = new Material(Shader.Find(SpriteDefaultShader)); // URP 호환
|
||||||
lineRenderer.sortingOrder = sortingIndex;
|
lineRenderer.sortingOrder = sortingIndex;
|
||||||
lineRenderer.startWidth = lineRenderer.endWidth = width;
|
lineRenderer.startWidth = lineRenderer.endWidth = width;
|
||||||
lineRenderer.startColor = lineRenderer.endColor = color;
|
lineRenderer.startColor = lineRenderer.endColor = color;
|
||||||
@ -148,6 +153,7 @@ private void UpdateLineRenderer(LineRenderer lr, Vector3 start, Vector3 end)
|
|||||||
lr.SetPosition(0, start);
|
lr.SetPosition(0, start);
|
||||||
lr.SetPosition(1, end);
|
lr.SetPosition(1, end);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
public void SetCurrentDirection(Vector3 normalDirection)
|
public void SetCurrentDirection(Vector3 normalDirection)
|
||||||
{
|
{
|
||||||
@ -198,14 +204,14 @@ private Vector3 GetSlideAdjustedDirection(Vector3 inputDirection)
|
|||||||
: _boxCollider.bounds.size.z;
|
: _boxCollider.bounds.size.z;
|
||||||
int layerMask = ~_playerDataSo.IgnoreSlidingLayerMask;
|
int layerMask = ~_playerDataSo.IgnoreSlidingLayerMask;
|
||||||
|
|
||||||
if (Physics.BoxCast(origin, halfExtents * 0.95f, inputDirection, out RaycastHit hit, rotation, distance, layerMask))
|
if (Physics.BoxCast(origin, halfExtents * _playerDataSo.BoxCastExtentScale, inputDirection, out RaycastHit hit, rotation, distance, layerMask))
|
||||||
{
|
{
|
||||||
Vector3 slide = Vector3.ProjectOnPlane(inputDirection, hit.normal).normalized;
|
Vector3 slide = Vector3.ProjectOnPlane(inputDirection, hit.normal).normalized;
|
||||||
|
|
||||||
float dot = Vector3.Dot(inputDirection.normalized, hit.normal);
|
float dot = Vector3.Dot(inputDirection.normalized, hit.normal);
|
||||||
float slideFactor = Mathf.Pow(1f - Mathf.Abs(dot), _playerDataSo.SlidingThreshold);
|
float slideFactor = Mathf.Pow(1f - Mathf.Abs(dot), _playerDataSo.SlidingThreshold);
|
||||||
|
|
||||||
if (slideFactor < 0.05f) return Vector3.zero;
|
if (slideFactor < _playerDataSo.MinSlideFactorThreshold) return Vector3.zero;
|
||||||
|
|
||||||
return slide * slideFactor;
|
return slide * slideFactor;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ public static class CommonConstants
|
|||||||
public const string VisualLook = "VisualLook";
|
public const string VisualLook = "VisualLook";
|
||||||
public const string RestaurantPlayer = "RestaurantPlayer";
|
public const string RestaurantPlayer = "RestaurantPlayer";
|
||||||
public const string BaseRestaurantEnvironment = "BaseRestaurantEnvironment";
|
public const string BaseRestaurantEnvironment = "BaseRestaurantEnvironment";
|
||||||
|
public const string Clone = "(Clone)";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DataConstants
|
public static class DataConstants
|
||||||
@ -24,4 +25,18 @@ public static class RestaurantPlayerAnimation
|
|||||||
public const string Walk = "RunFast";
|
public const string Walk = "RunFast";
|
||||||
public const string Dash = "Dash";
|
public const string Dash = "Dash";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class PathConstants
|
||||||
|
{
|
||||||
|
public const string RawSpritesPathUpper = "ASSETS/_DDD/_RAW/SPRITES/";
|
||||||
|
public const string RawFolderPath = "/_Raw";
|
||||||
|
public const string AddressablesFolderPath = "/_Addressables";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ExtenstionConstants
|
||||||
|
{
|
||||||
|
public const string PngExtensionUpper = ".PNG";
|
||||||
|
public const string PngExtensionLower = ".png";
|
||||||
|
public const string SpriteAtlasExtenstionLower = ".spriteatlasv2";
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user