Added "ToSilhuette" function
This commit is contained in:
parent
c229215211
commit
fab1cba417
|
@ -0,0 +1,138 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: SilhouetteMaterial
|
||||
m_Shader: {fileID: 4800000, guid: 650dd9526735d5b46b79224bc6e94025, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords:
|
||||
- _SURFACE_TYPE_TRANSPARENT
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: 3000
|
||||
stringTagMap:
|
||||
RenderType: Transparent
|
||||
disabledShaderPasses:
|
||||
- DepthOnly
|
||||
- SHADOWCASTER
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BaseMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SpecGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_Lightmaps:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_LightmapsInd:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_ShadowMasks:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _AlphaClip: 0
|
||||
- _AlphaToMask: 0
|
||||
- _Blend: 0
|
||||
- _BlendModePreserveSpecular: 1
|
||||
- _BlendOp: 0
|
||||
- _BumpScale: 1
|
||||
- _ClearCoatMask: 0
|
||||
- _ClearCoatSmoothness: 0
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 10
|
||||
- _DstBlendAlpha: 10
|
||||
- _EnvironmentReflections: 1
|
||||
- _GlossMapScale: 0
|
||||
- _Glossiness: 0
|
||||
- _GlossyReflections: 0
|
||||
- _Metallic: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.005
|
||||
- _QueueOffset: 0
|
||||
- _ReceiveShadows: 1
|
||||
- _SampleGI: 0
|
||||
- _Smoothness: 0.5
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 5
|
||||
- _SrcBlendAlpha: 1
|
||||
- _Surface: 1
|
||||
- _WorkflowMode: 1
|
||||
- _ZWrite: 0
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 0, g: 0.8041401, b: 1, a: 0.6784314}
|
||||
- _Color: {r: 0, g: 0.8041401, b: 1, a: 0.6784314}
|
||||
- _EmissionColor: {r: 0, g: 0.43417406, b: 1, a: 1}
|
||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
--- !u!114 &3420804456520092899
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 11
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 7
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0610eb89b05f0b546929db3664a351d8
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -171,6 +171,7 @@ MonoBehaviour:
|
|||
m_EditorClassIdentifier:
|
||||
DebugTowerPrefab: {fileID: 1927189479841411320, guid: 60899c8a0efa6f74393d369a109d82c3,
|
||||
type: 3}
|
||||
SilhouetteMaterial: {fileID: 2100000, guid: 0610eb89b05f0b546929db3664a351d8, type: 2}
|
||||
--- !u!4 &268589088 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 2739991145043243501, guid: 0c13e24f92c86f84a85c76e0bca22830,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
|
@ -18,6 +19,8 @@ public class TowerPlacementManager : MonoBehaviour
|
|||
// Section: Debug
|
||||
public GameObject DebugTowerPrefab;
|
||||
|
||||
private bool IsPlacing = true; // Show silluette or nothing
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (Singleton != this)
|
||||
|
@ -25,6 +28,8 @@ public class TowerPlacementManager : MonoBehaviour
|
|||
Singleton = this;
|
||||
|
||||
OnSpawnGridRequested?.Invoke(this);
|
||||
|
||||
ToSilhouette(DebugTowerPrefab);
|
||||
}
|
||||
|
||||
public void OnSlotClicked(SlotManager slot, GridManager grid, int x, int y)
|
||||
|
@ -56,4 +61,38 @@ public class TowerPlacementManager : MonoBehaviour
|
|||
{
|
||||
Instantiate(towerPrefab, CurrentSelected.transform);
|
||||
}
|
||||
|
||||
public void OnSlotHovered()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[Space(10)]
|
||||
public Material SilhouetteMaterial;
|
||||
public GameObject ToSilhouette(GameObject obj)
|
||||
{
|
||||
// if prefab, then spawn it
|
||||
if (obj.scene.name == null)
|
||||
obj = Instantiate(obj);
|
||||
|
||||
Component[] objScripts = obj.GetComponents<Component>();
|
||||
objScripts = objScripts.Concat(obj.GetComponentsInChildren<Component>()).ToArray();
|
||||
|
||||
for (int i = 0; i < objScripts.Length; i++)
|
||||
{
|
||||
var comp = objScripts[i];
|
||||
|
||||
if (comp is not Renderer && comp is not Transform && comp is not MeshFilter)
|
||||
{
|
||||
Destroy(comp);
|
||||
}
|
||||
else if (typeof(Renderer).IsAssignableFrom(comp))
|
||||
{
|
||||
var renderer = comp as Renderer;
|
||||
renderer.material = SilhouetteMaterial;
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue