This commit is contained in:
2023-02-07 16:44:00 +01:00
commit aba5e89872
47 changed files with 5702 additions and 0 deletions

124
Assets/Primitives.mat Normal file
View File

@@ -0,0 +1,124 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Primitives
m_Shader: {fileID: -6465566751694194690, guid: 2217394566da195bf9195eb2101ac903, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
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_Floats:
- Vector1_9fb2dc688df04073ae34e838656f2a2e: 1
- _AlphaClip: 0
- _Blend: 0
- _BumpScale: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _EnvironmentReflections: 1
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Surface: 0
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []
--- !u!114 &5493767890441157245
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: 4

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 02a9b7f9229417a98a0790973b442b54
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Scenes.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 94496d72da36453ecbc3333242573bf3
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

1099
Assets/Scenes/Demo.unity Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 727092f3ef7cdda70ac11fd5e011d639
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Scripts.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 02a3527b6b33a924e8ec66aa805ea717
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,58 @@
using System.Collections;
using UnityEngine;
using UnityEngine.InputSystem;
public class CameraController : MonoBehaviour
{
[SerializeField]
private Camera _cam;
[SerializeField]
private InputAction pressed, axis, scroll;
private float speed = 1f;
private Vector2 rotation;
private float scrollVal;
private bool canRotate;
// Start is called before the first frame update
void Awake()
{
pressed.Enable();
axis.Enable();
scroll.Enable();
pressed.performed += _ => { StartCoroutine(Rotate()); };
pressed.canceled += _ => { canRotate = false; };
axis.performed += context => { rotation = context.ReadValue<Vector2>(); };
axis.canceled += _ => { rotation = Vector3.zero; };
scroll.performed += context =>
{
scrollVal = context.ReadValue<float>();
ZoomIn();
};
}
private void ZoomIn()
{
RaycastHit hit;
if(scrollVal < 0 && Physics.Raycast(_cam.transform.position, transform.forward, out hit, 4))
return;
if(scrollVal < 0 || Vector3.Distance(_cam.transform.position, transform.position) < 20)
_cam.transform.position += -scrollVal * transform.forward;
}
private IEnumerator Rotate()
{
canRotate = true;
while (canRotate)
{
rotation *= speed;
transform.Rotate(Vector3.up, rotation.x);
transform.Rotate(transform.right, -rotation.y, Space.World);
yield return null;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a62312a5bb77e82668e921d9e8d5c823
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

33
Assets/Scripts/Demo.cs Normal file
View File

@@ -0,0 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem.HID;
using UnityEngine.UI;
public class Demo : MonoBehaviour
{
[SerializeField]
private ObjectQ _queue;
[SerializeField] private Button previousBtn;
[SerializeField] private Button nextBtn;
void Awake()
{
GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
GameObject capsule = GameObject.CreatePrimitive(PrimitiveType.Capsule);
GameObject cylinder = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Quad);
_queue.Add(cube);
_queue.Add(sphere);
_queue.Add(capsule);
_queue.Add(cylinder);
_queue.Add(plane);
previousBtn.onClick.AddListener(() => _queue.Change(true));
nextBtn.onClick.AddListener(() => _queue.Change(false));
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3f25ae0d97fedb0c394a3a3aca1bac60
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

69
Assets/Scripts/ObjectQ.cs Normal file
View File

@@ -0,0 +1,69 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
//Handle Objects in Queue
public class ObjectQ : MonoBehaviour
{
//all objects in the Q(ueue) are stored here
[SerializeField]
private List<QableObject> queue = new List<QableObject>();
[SerializeField]
private Material material;
private QableObject currentObject = null;
private int currentIndex = 0;
private State currentState = State.Changing;
//switch to next or previous object in Q
public void Change(bool previous = false)
{
if(queue.Count < 2 || currentState != State.ViewMode)
return;
currentIndex = previous ? currentIndex - 1 : currentIndex + 1;
currentIndex = (currentIndex + queue.Count) % queue.Count;
StartCoroutine(ShowNext());
currentState = State.Changing;
}
//add Object to Q
public void Add(GameObject gameObject)
{
var o = gameObject.AddComponent<QableObject>();
gameObject.transform.SetParent(transform);
gameObject.transform.position = transform.position;
o.renderer.material = material;
queue.Add(o);
//if no object is currently visible then show the first object in Q
if(currentObject == null)
StartCoroutine(ShowNext());
}
//Show next object from currentIndex
private IEnumerator ShowNext()
{
if(currentObject != null)
yield return StartCoroutine(currentObject.Dissolve());
currentObject = queue[currentIndex];
StartCoroutine(currentObject.Dissolve(true));
currentState = State.ViewMode;
}
//States of ObjectQ
public enum State
{
ViewMode,
Changing
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4d3baca064e59ccf2af3180895601755
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections;
using UnityEngine;
using UnityEngine.PlayerLoop;
//Q(ueue)able Object used by the ObjectQ handler.
public class QableObject : MonoBehaviour
{
public float _dissolveTime = 0.5f;
public Renderer renderer;
private void Awake()
{
renderer = gameObject.GetComponent<Renderer>();
}
public IEnumerator Dissolve(bool reverse = false)
{
float timer = 0;
float from = reverse ? 1 : 0;
float to = reverse ? 0 : 1;
while (timer < _dissolveTime)
{
var val = Mathf.SmoothStep(from, to, timer/_dissolveTime);
val = Mathf.Clamp01(val);
renderer.material.SetFloat("Vector1_9fb2dc688df04073ae34e838656f2a2e", val);
timer += Time.deltaTime;
yield return new WaitForEndOfFrame();
}
yield return timer;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1386ac625c7984cdcbeec5b76b2ef968
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Shader.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8abe0340c35c353cda924733c5d16be2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 2217394566da195bf9195eb2101ac903
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}

View File

@@ -0,0 +1,57 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
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: bf2edee5c58d82540a51f03df9d42094, type: 3}
m_Name: UniversalRenderPipelineAsset
m_EditorClassIdentifier:
k_AssetVersion: 5
k_AssetPreviousVersion: 5
m_RendererType: 1
m_RendererData: {fileID: 0}
m_RendererDataList:
- {fileID: 11400000, guid: 99f17ab8145b738fda0eb6d828b7c308, type: 2}
m_DefaultRendererIndex: 0
m_RequireDepthTexture: 0
m_RequireOpaqueTexture: 0
m_OpaqueDownsampling: 1
m_SupportsTerrainHoles: 1
m_SupportsHDR: 1
m_MSAA: 1
m_RenderScale: 1
m_MainLightRenderingMode: 1
m_MainLightShadowsSupported: 1
m_MainLightShadowmapResolution: 2048
m_AdditionalLightsRenderingMode: 1
m_AdditionalLightsPerObjectLimit: 4
m_AdditionalLightShadowsSupported: 0
m_AdditionalLightsShadowmapResolution: 512
m_ShadowDistance: 50
m_ShadowCascadeCount: 1
m_Cascade2Split: 0.25
m_Cascade3Split: {x: 0.1, y: 0.3}
m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467}
m_ShadowDepthBias: 1
m_ShadowNormalBias: 1
m_SoftShadowsSupported: 0
m_UseSRPBatcher: 1
m_SupportsDynamicBatching: 0
m_MixedLightingSupported: 1
m_DebugLevel: 0
m_UseAdaptivePerformance: 1
m_ColorGradingMode: 0
m_ColorGradingLutSize: 32
m_ShadowType: 1
m_LocalShadowsSupported: 0
m_LocalShadowsAtlasResolution: 256
m_MaxPixelLights: 0
m_ShadowAtlasResolution: 256
m_ShaderVariantLogLevel: 0
m_ShadowCascades: 0

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 98a1790f8f4bd690aad0abace107a0b7
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,44 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
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: de640fe3d0db1804a85f9fc8f5cadab6, type: 3}
m_Name: UniversalRenderPipelineAsset_Renderer
m_EditorClassIdentifier:
m_RendererFeatures: []
m_RendererFeatureMap:
postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2}
xrSystemData: {fileID: 11400000, guid: 60e1133243b97e347b653163a8c01b64, type: 2}
shaders:
blitPS: {fileID: 4800000, guid: c17132b1f77d20942aa75f8429c0f8bc, type: 3}
copyDepthPS: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3}
screenSpaceShadowPS: {fileID: 4800000, guid: 0f854b35a0cf61a429bd5dcfea30eddd, type: 3}
samplingPS: {fileID: 4800000, guid: 04c410c9937594faa893a11dceb85f7e, type: 3}
tileDepthInfoPS: {fileID: 0}
tileDeferredPS: {fileID: 0}
stencilDeferredPS: {fileID: 4800000, guid: e9155b26e1bc55942a41e518703fe304, type: 3}
fallbackErrorPS: {fileID: 4800000, guid: e6e9a19c3678ded42a3bc431ebef7dbd, type: 3}
materialErrorPS: {fileID: 4800000, guid: 5fd9a8feb75a4b5894c241777f519d4e, type: 3}
m_OpaqueLayerMask:
serializedVersion: 2
m_Bits: 4294967295
m_TransparentLayerMask:
serializedVersion: 2
m_Bits: 4294967295
m_DefaultStencilState:
overrideStencilState: 0
stencilReference: 0
stencilCompareFunction: 8
passOperation: 2
failOperation: 0
zFailOperation: 0
m_ShadowTransparentReceive: 1
m_RenderingMode: 0
m_AccurateGbufferNormals: 0

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 99f17ab8145b738fda0eb6d828b7c308
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant: