액체 쉐이더 테스트 중3
This commit is contained in:
parent
b7c333f477
commit
599951614b
@ -780,56 +780,6 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
propertyName: _OffsetX
|
||||
propertyValue: -1
|
||||
--- !u!1 &52394159
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 52394161}
|
||||
- component: {fileID: 52394160}
|
||||
m_Layer: 0
|
||||
m_Name: LiquidController (2)
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &52394160
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 52394159}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 278ab2f13d3f1e24594035530325c0ac, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_liquidRenderer: {fileID: 2105041734}
|
||||
_liquidObject: {fileID: -7612237390858616641, guid: 231c2f369e2946745a955eb49243702b, type: 3}
|
||||
_spawnTransform: {fileID: 427482135}
|
||||
_spawnLocation: {fileID: 218784750}
|
||||
_objectPoolCount: 10000
|
||||
_liquidColor: {r: 0, g: 0.7294118, b: 1, a: 1}
|
||||
--- !u!4 &52394161
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 52394159}
|
||||
serializedVersion: 2
|
||||
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_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &62548174
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -3877,7 +3827,7 @@ GameObject:
|
||||
- component: {fileID: 400400200}
|
||||
- component: {fileID: 400400199}
|
||||
m_Layer: 7
|
||||
m_Name: Square (8)
|
||||
m_Name: Reached
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -3999,56 +3949,6 @@ SpriteRenderer:
|
||||
m_WasSpriteAssigned: 1
|
||||
m_MaskInteraction: 0
|
||||
m_SpriteSortPoint: 0
|
||||
--- !u!1 &414124756
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 414124758}
|
||||
- component: {fileID: 414124757}
|
||||
m_Layer: 0
|
||||
m_Name: LiquidController (1)
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &414124757
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 414124756}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 278ab2f13d3f1e24594035530325c0ac, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_liquidRenderer: {fileID: 379763496}
|
||||
_liquidObject: {fileID: -7612237390858616641, guid: 231c2f369e2946745a955eb49243702b, type: 3}
|
||||
_spawnTransform: {fileID: 1511911897}
|
||||
_spawnLocation: {fileID: 218784750}
|
||||
_objectPoolCount: 10000
|
||||
_liquidColor: {r: 0, g: 0.7294118, b: 1, a: 1}
|
||||
--- !u!4 &414124758
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 414124756}
|
||||
serializedVersion: 2
|
||||
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_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &414363377
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -4225,7 +4125,7 @@ GameObject:
|
||||
m_Component:
|
||||
- component: {fileID: 427482135}
|
||||
m_Layer: 0
|
||||
m_Name: Spawn1
|
||||
m_Name: Spawn
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: -5442936267250999957, guid: 0000000000000000d000000000000000, type: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -4240,11 +4140,11 @@ Transform:
|
||||
m_GameObject: {fileID: 427482134}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 287.36, y: 13.01, z: 0}
|
||||
m_LocalPosition: {x: 331.56, y: 13.01, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_Father: {fileID: 522284550}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1001 &428517717
|
||||
PrefabInstance:
|
||||
@ -4927,13 +4827,14 @@ GameObject:
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 522284550}
|
||||
- component: {fileID: 522284551}
|
||||
m_Layer: 7
|
||||
m_Name: Cup (1)
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!4 &522284550
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -4950,8 +4851,33 @@ Transform:
|
||||
- {fileID: 1035979622}
|
||||
- {fileID: 1159534954}
|
||||
- {fileID: 1674889822}
|
||||
- {fileID: 1625870577}
|
||||
- {fileID: 427482135}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &522284551
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 522284549}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 278ab2f13d3f1e24594035530325c0ac, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_renderTexture: {fileID: 0}
|
||||
_liquidRenderer: {fileID: 2105041734}
|
||||
_liquidObject: {fileID: -7612237390858616641, guid: 231c2f369e2946745a955eb49243702b, type: 3}
|
||||
_spawnTransform: {fileID: 427482135}
|
||||
_spawnLocation: {fileID: 218784750}
|
||||
_reachedCollider: {fileID: 1035979623}
|
||||
_objectPoolCount: 10000
|
||||
_liquidColor: {r: 0, g: 0.7294118, b: 1, a: 1}
|
||||
_pouringRate: 20
|
||||
_liquidsPerSecond: 100
|
||||
_currentLiquidAmount: 0
|
||||
--- !u!1 &523582524
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -6620,7 +6546,7 @@ GameObject:
|
||||
- component: {fileID: 734598540}
|
||||
- component: {fileID: 734598539}
|
||||
m_Layer: 7
|
||||
m_Name: Square (7)
|
||||
m_Name: Wall
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -8550,7 +8476,7 @@ GameObject:
|
||||
- component: {fileID: 1035979624}
|
||||
- component: {fileID: 1035979623}
|
||||
m_Layer: 7
|
||||
m_Name: Square (8)
|
||||
m_Name: Reached
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -8807,6 +8733,7 @@ GameObject:
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1045118482}
|
||||
- component: {fileID: 1045118483}
|
||||
m_Layer: 7
|
||||
m_Name: Cup
|
||||
m_TagString: Untagged
|
||||
@ -8830,9 +8757,34 @@ Transform:
|
||||
- {fileID: 400400198}
|
||||
- {fileID: 734598538}
|
||||
- {fileID: 1788669765}
|
||||
- {fileID: 1757976623}
|
||||
- {fileID: 379763495}
|
||||
- {fileID: 1511911897}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1045118483
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1045118481}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 278ab2f13d3f1e24594035530325c0ac, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_renderTexture: {fileID: 2105041734}
|
||||
_liquidRenderer: {fileID: 379763496}
|
||||
_liquidObject: {fileID: -7612237390858616641, guid: 231c2f369e2946745a955eb49243702b, type: 3}
|
||||
_spawnTransform: {fileID: 1511911897}
|
||||
_spawnLocation: {fileID: 218784750}
|
||||
_reachedCollider: {fileID: 400400199}
|
||||
_objectPoolCount: 10000
|
||||
_liquidColor: {r: 0, g: 0.7294118, b: 1, a: 1}
|
||||
_pouringRate: 20
|
||||
_liquidsPerSecond: 100
|
||||
_currentLiquidAmount: 0
|
||||
--- !u!1 &1049919588
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -9738,7 +9690,7 @@ GameObject:
|
||||
- component: {fileID: 1159534956}
|
||||
- component: {fileID: 1159534955}
|
||||
m_Layer: 7
|
||||
m_Name: Square (7)
|
||||
m_Name: Wall
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -13391,7 +13343,7 @@ GameObject:
|
||||
m_Component:
|
||||
- component: {fileID: 1511911897}
|
||||
m_Layer: 0
|
||||
m_Name: Spawn2
|
||||
m_Name: Spawn
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: -5442936267250999957, guid: 0000000000000000d000000000000000, type: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -13410,7 +13362,7 @@ Transform:
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_Father: {fileID: 1045118482}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1527652764
|
||||
GameObject:
|
||||
@ -14147,12 +14099,12 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1625870574}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: 0, z: -0.38268343, w: 0.92387956}
|
||||
m_LocalPosition: {x: 289.4, y: 12.3, z: 0}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0.38268343, w: 0.92387956}
|
||||
m_LocalPosition: {x: 333.6, y: 12.3, z: 0}
|
||||
m_LocalScale: {x: 2, y: 10, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_Father: {fileID: 522284550}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: -45}
|
||||
--- !u!1001 &1628404463
|
||||
PrefabInstance:
|
||||
@ -14869,7 +14821,7 @@ GameObject:
|
||||
- component: {fileID: 1674889824}
|
||||
- component: {fileID: 1674889823}
|
||||
m_Layer: 7
|
||||
m_Name: Square (9)
|
||||
m_Name: Wall (1)
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -16148,12 +16100,12 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1757976620}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: 0, z: -0.38268343, w: 0.92387956}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0.38268343, w: 0.92387956}
|
||||
m_LocalPosition: {x: 334.06, y: 12.3, z: 0}
|
||||
m_LocalScale: {x: 2, y: 10, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_Father: {fileID: 1045118482}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: -45}
|
||||
--- !u!1 &1759838089
|
||||
GameObject:
|
||||
@ -16827,7 +16779,7 @@ GameObject:
|
||||
- component: {fileID: 1788669767}
|
||||
- component: {fileID: 1788669766}
|
||||
m_Layer: 7
|
||||
m_Name: Square (9)
|
||||
m_Name: Wall (1)
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -21487,11 +21439,11 @@ PrefabInstance:
|
||||
- target: {fileID: 3235314206077419821, guid: 981817fdc4897a34bafc0040f15656b9, type: 3}
|
||||
propertyPath: _liquidController
|
||||
value:
|
||||
objectReference: {fileID: 414124757}
|
||||
objectReference: {fileID: 1045118483}
|
||||
- target: {fileID: 3235314206077419821, guid: 981817fdc4897a34bafc0040f15656b9, type: 3}
|
||||
propertyPath: _liquidController2
|
||||
value:
|
||||
objectReference: {fileID: 52394160}
|
||||
objectReference: {fileID: 522284551}
|
||||
- target: {fileID: 9041926907780427371, guid: 981817fdc4897a34bafc0040f15656b9, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: TycoonMap
|
||||
@ -21532,11 +21484,5 @@ SceneRoots:
|
||||
- {fileID: 20736010}
|
||||
- {fileID: 5626406452199475265}
|
||||
- {fileID: 218784750}
|
||||
- {fileID: 1045118482}
|
||||
- {fileID: 522284550}
|
||||
- {fileID: 414124758}
|
||||
- {fileID: 52394161}
|
||||
- {fileID: 1757976623}
|
||||
- {fileID: 1625870577}
|
||||
- {fileID: 427482135}
|
||||
- {fileID: 1511911897}
|
||||
- {fileID: 1045118482}
|
||||
|
@ -7,11 +7,41 @@ namespace BlueWater
|
||||
{
|
||||
[SerializeField]
|
||||
private SpriteRenderer _spriteRenderer;
|
||||
|
||||
[SerializeField, Range(0f, 2f)]
|
||||
private float _distanceThreshold = 0.5f;
|
||||
|
||||
private IObjectPool<Liquid> _managedPool;
|
||||
|
||||
public void SetColor(Color color) => _spriteRenderer.color = color;
|
||||
private LiquidController _liquidController;
|
||||
private Collider2D _targetCollider;
|
||||
|
||||
public void SetManagedPool(IObjectPool<Liquid> pool) => _managedPool = pool;
|
||||
public void Destroy() => _managedPool.Release(this);
|
||||
|
||||
public void Initialize(LiquidController liquidController, Collider2D targetCollider, Color color)
|
||||
{
|
||||
_liquidController = liquidController;
|
||||
_targetCollider = targetCollider;
|
||||
_spriteRenderer.color = color;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!_targetCollider) return;
|
||||
|
||||
var closestPoint = _targetCollider.ClosestPoint(transform.position);
|
||||
var distance = Vector2.Distance(transform.position, closestPoint);
|
||||
|
||||
if (distance < _distanceThreshold)
|
||||
{
|
||||
OnReached();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnReached()
|
||||
{
|
||||
Destroy();
|
||||
_liquidController.OnLiquidReached();
|
||||
}
|
||||
}
|
||||
}
|
@ -8,6 +8,9 @@ namespace BlueWater
|
||||
{
|
||||
public class LiquidController : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private Renderer _renderTexture;
|
||||
|
||||
[SerializeField]
|
||||
private Renderer _liquidRenderer;
|
||||
|
||||
@ -20,22 +23,37 @@ namespace BlueWater
|
||||
[SerializeField]
|
||||
private Transform _spawnLocation;
|
||||
|
||||
[SerializeField]
|
||||
private Collider2D _reachedCollider;
|
||||
|
||||
[SerializeField]
|
||||
private int _objectPoolCount = 1000;
|
||||
|
||||
[SerializeField]
|
||||
private Color _liquidColor = new(0f, 0.7294118f, 1f, 1f);
|
||||
|
||||
[SerializeField, Tooltip("1초에 차는 %")]
|
||||
private float _pouringRate = 20f;
|
||||
|
||||
[SerializeField]
|
||||
private int _liquidsPerSecond = 100;
|
||||
|
||||
[SerializeField, Range(0f, 100f)]
|
||||
private float _currentLiquidAmount;
|
||||
|
||||
private IObjectPool<Liquid> _objectPool;
|
||||
private List<Liquid> _activeLiquids = new();
|
||||
private Dictionary<Color, float> _colorTimes = new();
|
||||
|
||||
private Material _instanceMaterial;
|
||||
private bool _isPouring;
|
||||
private float _startTime = float.PositiveInfinity;
|
||||
private Material _material;
|
||||
private float _timeInterval;
|
||||
private float _liquidPerObject;
|
||||
|
||||
// Hashes
|
||||
private static readonly int _colorHash = Shader.PropertyToID("_Color");
|
||||
private static readonly int _liquidAmountHash = Shader.PropertyToID("_LiquidAmount");
|
||||
private static readonly int _liquidColorHash = Shader.PropertyToID("_LiquidColor");
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@ -44,28 +62,39 @@ namespace BlueWater
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_material = Instantiate(_liquidRenderer.material);
|
||||
_liquidRenderer.material = _material;
|
||||
_instanceMaterial = Instantiate(_liquidRenderer.material);
|
||||
_liquidRenderer.material = _instanceMaterial;
|
||||
|
||||
_timeInterval = 1f / _liquidsPerSecond;
|
||||
_liquidPerObject = _pouringRate / _liquidsPerSecond;
|
||||
_instanceMaterial.SetFloat(_liquidAmountHash, 0f);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_isPouring)
|
||||
{
|
||||
_objectPool.Get();
|
||||
|
||||
if (_colorTimes.ContainsKey(_liquidColor))
|
||||
if (_currentLiquidAmount >= 100f)
|
||||
{
|
||||
_colorTimes[_liquidColor] += Time.time - _startTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
_colorTimes[_liquidColor] = Time.time - _startTime;
|
||||
InActiveIsPouring();
|
||||
return;
|
||||
}
|
||||
|
||||
_startTime = Time.time;
|
||||
|
||||
_liquidRenderer.material.SetColor(_colorHash, MixColorsByTime());
|
||||
if (Time.time - _startTime >= _timeInterval)
|
||||
{
|
||||
_objectPool.Get();
|
||||
|
||||
if (_colorTimes.ContainsKey(_liquidColor))
|
||||
{
|
||||
_colorTimes[_liquidColor] += _timeInterval;
|
||||
}
|
||||
else
|
||||
{
|
||||
_colorTimes[_liquidColor] = _timeInterval;
|
||||
}
|
||||
|
||||
_startTime = Time.time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,7 +102,7 @@ namespace BlueWater
|
||||
{
|
||||
var instance = Instantiate(_liquidObject, _spawnTransform.position, Quaternion.identity, _spawnLocation);
|
||||
instance.SetManagedPool(_objectPool);
|
||||
instance.SetColor(_liquidColor);
|
||||
instance.Initialize(this, _reachedCollider, _liquidColor);
|
||||
return instance;
|
||||
}
|
||||
|
||||
@ -81,6 +110,11 @@ namespace BlueWater
|
||||
{
|
||||
liquid.transform.position = _spawnTransform.position;
|
||||
liquid.transform.rotation = Quaternion.identity;
|
||||
liquid.Initialize(this, _reachedCollider, _liquidColor);
|
||||
if (_renderTexture && _renderTexture.material.GetColor("_Color") != _liquidColor)
|
||||
{
|
||||
_renderTexture.material.SetColor("_Color", _liquidColor);
|
||||
}
|
||||
liquid.gameObject.SetActive(true);
|
||||
_activeLiquids.Add(liquid);
|
||||
}
|
||||
@ -97,31 +131,6 @@ namespace BlueWater
|
||||
_activeLiquids.Remove(liquid);
|
||||
}
|
||||
|
||||
[Button("기본 색상")]
|
||||
private void DefaultColor() => _liquidColor = new Color(0f, 0.7294118f, 1f, 1f);
|
||||
|
||||
public void ReleaseAllObject()
|
||||
{
|
||||
// 뒤에서부터 Remove해야 오류가 없음
|
||||
for (var i = _activeLiquids.Count - 1; i >= 0; i--)
|
||||
{
|
||||
_activeLiquids[i].Destroy();
|
||||
}
|
||||
|
||||
_colorTimes.Clear();
|
||||
}
|
||||
|
||||
public void ActiveIsPouring()
|
||||
{
|
||||
_startTime = Time.time;
|
||||
_isPouring = true;
|
||||
}
|
||||
|
||||
public void InActiveIsPouring()
|
||||
{
|
||||
_isPouring = false;
|
||||
}
|
||||
|
||||
private Color MixColorsByTime()
|
||||
{
|
||||
var totalTime = _colorTimes.Values.Sum();
|
||||
@ -143,5 +152,48 @@ namespace BlueWater
|
||||
|
||||
return mixedColor;
|
||||
}
|
||||
|
||||
[Button("기본 색상")]
|
||||
private void DefaultColor() => _liquidColor = new Color(0f, 0.7294118f, 1f, 1f);
|
||||
|
||||
public void ReleaseAllObject()
|
||||
{
|
||||
// 뒤에서부터 Remove해야 오류가 없음
|
||||
for (var i = _activeLiquids.Count - 1; i >= 0; i--)
|
||||
{
|
||||
_activeLiquids[i].Destroy();
|
||||
}
|
||||
|
||||
_colorTimes.Clear();
|
||||
_currentLiquidAmount = 0f;
|
||||
_instanceMaterial.SetFloat(_liquidAmountHash, 0f);
|
||||
}
|
||||
|
||||
public void ActiveIsPouring()
|
||||
{
|
||||
_startTime = Time.time;
|
||||
_isPouring = true;
|
||||
}
|
||||
|
||||
public void InActiveIsPouring()
|
||||
{
|
||||
_isPouring = false;
|
||||
}
|
||||
|
||||
public void OnLiquidReached()
|
||||
{
|
||||
// 컵에 채워진 액체의 양을 증가시킴
|
||||
_currentLiquidAmount += _liquidPerObject;
|
||||
_currentLiquidAmount = Mathf.Clamp(_currentLiquidAmount, 0f, 100f);
|
||||
var liquidAmount = _currentLiquidAmount * 0.01f;
|
||||
_instanceMaterial.SetFloat(_liquidAmountHash, liquidAmount);
|
||||
_instanceMaterial.SetColor(_liquidColorHash, MixColorsByTime());
|
||||
|
||||
// 액체가 100%에 도달하면 pouring을 멈춤
|
||||
if (_currentLiquidAmount >= 100f)
|
||||
{
|
||||
InActiveIsPouring();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -166,3 +166,4 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_spriteRenderer: {fileID: 3772201455671009312}
|
||||
_distanceThreshold: 0.5
|
||||
|
@ -1902,7 +1902,7 @@
|
||||
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
|
||||
"m_ObjectId": "21c97d80381a4c9990e1a9a372eab8bc",
|
||||
"m_Id": 0,
|
||||
"m_DisplayName": "WaterLevel",
|
||||
"m_DisplayName": "LiquidAmount",
|
||||
"m_SlotType": 1,
|
||||
"m_Hidden": false,
|
||||
"m_ShaderOutputName": "Out",
|
||||
@ -2131,10 +2131,10 @@
|
||||
"m_Guid": {
|
||||
"m_GuidSerialized": "050b9b3e-f147-4d66-9d58-6916f3716d43"
|
||||
},
|
||||
"m_Name": "WaterColor",
|
||||
"m_Name": "LiquidColor",
|
||||
"m_DefaultRefNameVersion": 1,
|
||||
"m_RefNameGeneratedByDisplayName": "WaterColor",
|
||||
"m_DefaultReferenceName": "_WaterColor",
|
||||
"m_RefNameGeneratedByDisplayName": "LiquidColor",
|
||||
"m_DefaultReferenceName": "_LiquidColor",
|
||||
"m_OverrideReferenceName": "",
|
||||
"m_GeneratePropertyBlock": true,
|
||||
"m_UseCustomSlotLabel": false,
|
||||
@ -2344,10 +2344,10 @@
|
||||
"m_Guid": {
|
||||
"m_GuidSerialized": "0c389213-635a-46cd-a9e8-4676d09f1d18"
|
||||
},
|
||||
"m_Name": "WaterTopColor",
|
||||
"m_Name": "LiquidTopColor",
|
||||
"m_DefaultRefNameVersion": 1,
|
||||
"m_RefNameGeneratedByDisplayName": "WaterTopColor",
|
||||
"m_DefaultReferenceName": "_WaterTopColor",
|
||||
"m_RefNameGeneratedByDisplayName": "LiquidTopColor",
|
||||
"m_DefaultReferenceName": "_LiquidTopColor",
|
||||
"m_OverrideReferenceName": "",
|
||||
"m_GeneratePropertyBlock": true,
|
||||
"m_UseCustomSlotLabel": false,
|
||||
@ -2359,8 +2359,8 @@
|
||||
"m_Hidden": false,
|
||||
"m_Value": {
|
||||
"r": 1.0,
|
||||
"g": 0.0,
|
||||
"b": 0.0,
|
||||
"g": 1.0,
|
||||
"b": 1.0,
|
||||
"a": 0.0
|
||||
},
|
||||
"isMainColor": false,
|
||||
@ -2577,7 +2577,7 @@
|
||||
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
|
||||
"m_ObjectId": "46ea82f4e76c43b2ac7f7968c8cbaace",
|
||||
"m_Id": 0,
|
||||
"m_DisplayName": "WaterLevel",
|
||||
"m_DisplayName": "LiquidAmount",
|
||||
"m_SlotType": 1,
|
||||
"m_Hidden": false,
|
||||
"m_ShaderOutputName": "Out",
|
||||
@ -2632,7 +2632,7 @@
|
||||
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
|
||||
"m_ObjectId": "4ba0e43fae7b44ccadeed62600f2d87d",
|
||||
"m_Id": 0,
|
||||
"m_DisplayName": "WaterTopColor",
|
||||
"m_DisplayName": "LiquidTopColor",
|
||||
"m_SlotType": 1,
|
||||
"m_Hidden": false,
|
||||
"m_ShaderOutputName": "Out",
|
||||
@ -2969,10 +2969,10 @@
|
||||
"m_Guid": {
|
||||
"m_GuidSerialized": "63648f52-4c36-457a-b67e-d6b466d1f2cb"
|
||||
},
|
||||
"m_Name": "WaterLevel",
|
||||
"m_Name": "LiquidAmount",
|
||||
"m_DefaultRefNameVersion": 1,
|
||||
"m_RefNameGeneratedByDisplayName": "WaterLevel",
|
||||
"m_DefaultReferenceName": "_WaterLevel",
|
||||
"m_RefNameGeneratedByDisplayName": "LiquidAmount",
|
||||
"m_DefaultReferenceName": "_LiquidAmount",
|
||||
"m_OverrideReferenceName": "",
|
||||
"m_GeneratePropertyBlock": true,
|
||||
"m_UseCustomSlotLabel": false,
|
||||
@ -3362,10 +3362,10 @@
|
||||
"m_Guid": {
|
||||
"m_GuidSerialized": "801a0bee-3fc7-4ec5-9ea5-eacac91dd714"
|
||||
},
|
||||
"m_Name": "WaterTopWidth",
|
||||
"m_Name": "LiquidTopWidth",
|
||||
"m_DefaultRefNameVersion": 1,
|
||||
"m_RefNameGeneratedByDisplayName": "WaterTopWidth",
|
||||
"m_DefaultReferenceName": "_WaterTopWidth",
|
||||
"m_RefNameGeneratedByDisplayName": "LiquidTopWidth",
|
||||
"m_DefaultReferenceName": "_LiquidTopWidth",
|
||||
"m_OverrideReferenceName": "",
|
||||
"m_GeneratePropertyBlock": true,
|
||||
"m_UseCustomSlotLabel": false,
|
||||
@ -3499,7 +3499,7 @@
|
||||
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
|
||||
"m_ObjectId": "733fdee3dc36465eafbd529b4cf3cb0a",
|
||||
"m_Id": 0,
|
||||
"m_DisplayName": "WaterSpeed",
|
||||
"m_DisplayName": "LiquidSpeed",
|
||||
"m_SlotType": 1,
|
||||
"m_Hidden": false,
|
||||
"m_ShaderOutputName": "Out",
|
||||
@ -3801,7 +3801,7 @@
|
||||
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
|
||||
"m_ObjectId": "818f3e4570d04528b4826e6f3ee4019e",
|
||||
"m_Id": 0,
|
||||
"m_DisplayName": "WaterColor",
|
||||
"m_DisplayName": "LiquidColor",
|
||||
"m_SlotType": 1,
|
||||
"m_Hidden": false,
|
||||
"m_ShaderOutputName": "Out",
|
||||
@ -4131,10 +4131,10 @@
|
||||
"m_Guid": {
|
||||
"m_GuidSerialized": "1894d5b4-fd22-4ffa-974d-d712a063bc6f"
|
||||
},
|
||||
"m_Name": "WaterFrequency",
|
||||
"m_Name": "LiquidFrequency",
|
||||
"m_DefaultRefNameVersion": 1,
|
||||
"m_RefNameGeneratedByDisplayName": "WaterFrequency",
|
||||
"m_DefaultReferenceName": "_WaterFrequency",
|
||||
"m_RefNameGeneratedByDisplayName": "LiquidFrequency",
|
||||
"m_DefaultReferenceName": "_LiquidFrequency",
|
||||
"m_OverrideReferenceName": "",
|
||||
"m_GeneratePropertyBlock": true,
|
||||
"m_UseCustomSlotLabel": false,
|
||||
@ -4656,10 +4656,10 @@
|
||||
"m_Guid": {
|
||||
"m_GuidSerialized": "81417847-e8dc-4c50-afd2-c75cc2e484ce"
|
||||
},
|
||||
"m_Name": "WaterSpeed",
|
||||
"m_Name": "LiquidSpeed",
|
||||
"m_DefaultRefNameVersion": 1,
|
||||
"m_RefNameGeneratedByDisplayName": "WaterSpeed",
|
||||
"m_DefaultReferenceName": "_WaterSpeed",
|
||||
"m_RefNameGeneratedByDisplayName": "LiquidSpeed",
|
||||
"m_DefaultReferenceName": "_LiquidSpeed",
|
||||
"m_OverrideReferenceName": "",
|
||||
"m_GeneratePropertyBlock": true,
|
||||
"m_UseCustomSlotLabel": false,
|
||||
@ -5049,7 +5049,7 @@
|
||||
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
|
||||
"m_ObjectId": "b1f3ee8083864b9382ccaf96b6ea45fe",
|
||||
"m_Id": 0,
|
||||
"m_DisplayName": "WaterFrequency",
|
||||
"m_DisplayName": "LiquidFrequency",
|
||||
"m_SlotType": 1,
|
||||
"m_Hidden": false,
|
||||
"m_ShaderOutputName": "Out",
|
||||
@ -5088,7 +5088,7 @@
|
||||
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
|
||||
"m_ObjectId": "b671d2def40f42019502a3941ec0bf08",
|
||||
"m_Id": 0,
|
||||
"m_DisplayName": "WaterTopWidth",
|
||||
"m_DisplayName": "LiquidTopWidth",
|
||||
"m_SlotType": 1,
|
||||
"m_Hidden": false,
|
||||
"m_ShaderOutputName": "Out",
|
||||
|
@ -30,6 +30,11 @@
|
||||
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
|
||||
"key": "lightmapping.autoUnwrapLightmapUV",
|
||||
"value": "{\"m_Value\":true}"
|
||||
},
|
||||
{
|
||||
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
|
||||
"key": "experimental.enabled",
|
||||
"value": "{\"m_Value\":false}"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user