Merge remote-tracking branch 'refs/remotes/origin/main'

This commit is contained in:
Sveske Juice 2024-04-20 17:31:15 +02:00
commit 3a73a81d66
6 changed files with 52 additions and 78 deletions

View File

@ -186,7 +186,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1400473914611959530}
serializedVersion: 2
m_LocalRotation: {x: -0.011396199, y: 0.98857015, z: -0.11032369, w: -0.102117166}
m_LocalRotation: {x: -0.011396202, y: 0.98857015, z: -0.11032369, w: -0.10211719}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
@ -265,7 +265,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2383950784329503899}
serializedVersion: 2
m_LocalRotation: {x: -0.008466786, y: 0.99132437, z: -0.08196477, w: -0.10240167}
m_LocalRotation: {x: -0.008466786, y: 0.99132437, z: -0.08196477, w: -0.10240169}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
@ -344,7 +344,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3339643807228368672}
serializedVersion: 2
m_LocalRotation: {x: -0.014335657, y: 0.9849784, z: -0.13877982, w: -0.101746134}
m_LocalRotation: {x: -0.014335659, y: 0.9849784, z: -0.13877982, w: -0.10174616}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
@ -585,7 +585,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6163557566655415017}
serializedVersion: 2
m_LocalRotation: {x: -0.0113961985, y: 0.98857015, z: -0.11032369, w: -0.10211714}
m_LocalRotation: {x: -0.011396202, y: 0.98857015, z: -0.1103237, w: -0.10211718}
m_LocalPosition: {x: 8.5044365, y: 3.5927956, z: 10.26652}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
@ -1031,6 +1031,7 @@ MonoBehaviour:
defaultMaterial: {fileID: 2100000, guid: 1fb12e769af8dfc4b9c47b291e1da192, type: 2}
hitMaterial: {fileID: 2100000, guid: 487f1aaeb1fd5674a8842eab66d03872, type: 2}
sphereRadius: 2
maxSphereRayDistanceOffset: {x: 0, y: 3, z: 0}
--- !u!114 &7757173428948913319
MonoBehaviour:
m_ObjectHideFlags: 0

View File

@ -222,8 +222,8 @@ Transform:
m_GameObject: {fileID: 163929259}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 2.8726685, y: 0.40448904, z: -1.4757066}
m_LocalScale: {x: 10, y: 5.455344, z: 0.5}
m_LocalPosition: {x: 2.8726685, y: 0.897, z: -1.4757066}
m_LocalScale: {x: 10, y: 4.470458, z: 0.5}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1696531492}
@ -550,8 +550,8 @@ Transform:
m_GameObject: {fileID: 1425080745}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 2.8726685, y: 0.40448904, z: -11.059507}
m_LocalScale: {x: 10, y: 5.455344, z: 0.5}
m_LocalPosition: {x: 2.8726685, y: 0.9099, z: -11.059507}
m_LocalScale: {x: 10, y: 4.444636, z: 0.5}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1696531492}
@ -921,46 +921,6 @@ PrefabInstance:
propertyPath: m_Name
value: Cinemachine
objectReference: {fileID: 0}
- target: {fileID: 2465233980315321778, guid: fd9f9b61c0ebb324ebc9f929e26706bc,
type: 3}
propertyPath: m_LocalRotation.w
value: -0.10240169
objectReference: {fileID: 0}
- target: {fileID: 2981308973353539976, guid: fd9f9b61c0ebb324ebc9f929e26706bc,
type: 3}
propertyPath: m_LocalRotation.w
value: -0.10211718
objectReference: {fileID: 0}
- target: {fileID: 2981308973353539976, guid: fd9f9b61c0ebb324ebc9f929e26706bc,
type: 3}
propertyPath: m_LocalRotation.x
value: -0.011396202
objectReference: {fileID: 0}
- target: {fileID: 2981308973353539976, guid: fd9f9b61c0ebb324ebc9f929e26706bc,
type: 3}
propertyPath: m_LocalRotation.z
value: -0.1103237
objectReference: {fileID: 0}
- target: {fileID: 5753661378891917460, guid: fd9f9b61c0ebb324ebc9f929e26706bc,
type: 3}
propertyPath: m_LocalRotation.w
value: -0.10211719
objectReference: {fileID: 0}
- target: {fileID: 5753661378891917460, guid: fd9f9b61c0ebb324ebc9f929e26706bc,
type: 3}
propertyPath: m_LocalRotation.x
value: -0.011396202
objectReference: {fileID: 0}
- target: {fileID: 7348612162646443967, guid: fd9f9b61c0ebb324ebc9f929e26706bc,
type: 3}
propertyPath: m_LocalRotation.w
value: -0.10174616
objectReference: {fileID: 0}
- target: {fileID: 7348612162646443967, guid: fd9f9b61c0ebb324ebc9f929e26706bc,
type: 3}
propertyPath: m_LocalRotation.x
value: -0.014335659
objectReference: {fileID: 0}
- target: {fileID: 8882344377078016156, guid: fd9f9b61c0ebb324ebc9f929e26706bc,
type: 3}
propertyPath: m_LocalPosition.x

View File

@ -169,7 +169,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: acef1d7c80f784543acd3e1571e99495, type: 3}
m_Name:
m_EditorClassIdentifier:
DebugTowerPrefab: {fileID: 1927189479841411320, guid: 60899c8a0efa6f74393d369a109d82c3,
DebugTowerPrefab: {fileID: 8488737342646939416, guid: 9415cb10a1bd579269301ca4f61a1554,
type: 3}
SilhouetteMaterial: {fileID: 2100000, guid: 0610eb89b05f0b546929db3664a351d8, type: 2}
--- !u!4 &268589088 stripped

View File

@ -1,3 +1,4 @@
using System.Collections.Generic;
using UnityEngine;
public class HideWall : MonoBehaviour
@ -11,48 +12,60 @@ public class HideWall : MonoBehaviour
public Material hitMaterial; // Material when hitting "Wall"
public float sphereRadius;
float maxRayDistance;
float maxSphereRayDistance;
public Vector3 maxSphereRayDistanceOffset;
private List<GameObject> prevHitObjects = new List<GameObject>();
private void Start()
{
maxRayDistance = Vector3.Distance(target.transform.position, origin.transform.position) - sphereRadius * 2;
maxSphereRayDistance = Vector3.Distance(origin.transform.position, target.transform.position) - (sphereRadius * 2 + 1);
}
void Update()
{
Vector3 direction = (target.transform.position - origin.transform.position).normalized;
Vector3 direction = ((target.transform.position + maxSphereRayDistanceOffset) - origin.transform.position).normalized;
RaycastHit[] hits = Physics.SphereCastAll(origin.transform.position, sphereRadius, direction, maxSphereRayDistance);
RaycastHit[] hit;
List<GameObject> hitObjectsThisFrame = new List<GameObject>();
hit = Physics.SphereCastAll(origin.transform.position, sphereRadius, direction, maxRayDistance);
// Change material of currently hit objects
for (int i = 0; i < hits.Length; i++)
{
if (hits[i].collider.CompareTag("Wall"))
{
var hitGameObject = hits[i].collider.gameObject;
hitObjectsThisFrame.Add(hitGameObject);
for (int i = 0; i < hit.Length; i++)
// Change material only if this object wasn't hit last frame
if (!prevHitObjects.Contains(hitGameObject))
{
if (hit[i].collider.CompareTag("Wall"))
Renderer renderer = hits[i].collider.GetComponent<Renderer>();
if (renderer != null)
{
if (prevObject != null)
if (prevObject == hit[i].collider.gameObject)
{
var renderer = hit[i].collider.GetComponent<Renderer>();
var originalMat = renderer.material;
var originalColor = originalMat.color;
originalMat.color = new Color(originalColor.r, originalColor.g, originalColor.b, 0f);
renderer.material = originalMat;
renderer.material = hitMaterial;
}
}
}
else
{
var renderer = prevObject.GetComponent<Collider>().GetComponent<Renderer>();
var originalMat = renderer.material;
var originalColor = originalMat.color;
originalMat.color = new Color(originalColor.r, originalColor.g, originalColor.b, 1f);
renderer.material = originalMat;
}
prevObject = hit[i].collider.gameObject;
}
print(hit[i].collider.gameObject.name);
// Restore the material of objects that are not hit this frame but were hit in the previous frame
for (int i = 0; i < prevHitObjects.Count; i++)
{
if (!hitObjectsThisFrame.Contains(prevHitObjects[i]))
{
Renderer renderer = prevHitObjects[i].GetComponent<Renderer>();
if (renderer != null)
{
renderer.material = defaultMaterial;
}
}
}
// Update the list of previously hit objects
prevHitObjects = hitObjectsThisFrame;
}
private void OnDrawGizmos()
{

View File

@ -89,7 +89,7 @@ public class TowerPlacementManager : MonoBehaviour
else if (typeof(Renderer).IsAssignableFrom(comp))
{
var renderer = comp as Renderer;
renderer.material = SilhouetteMaterial;
renderer.materials = new Material[] { SilhouetteMaterial , SilhouetteMaterial , SilhouetteMaterial , SilhouetteMaterial , SilhouetteMaterial };
}
}

View File

@ -37,7 +37,7 @@ TagManager:
-
-
-
-
- DoNotRender
m_SortingLayers:
- name: Default
uniqueID: 0