[Fix] All in one + add dice
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "AllIn13DShaderDemoScriptsAssembly",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:6055be8ebefd69e48b49212b09b47b2f",
|
||||
"GUID:75469ad4d38634e559750d17036d5f7c",
|
||||
"GUID:d60799ab2a985554ea1a39cd38695018",
|
||||
"GUID:15fc0a57446b3144c949da3e2b9737a9",
|
||||
"GUID:df380645f10b7bc4b97d4f5eb6303d95"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 45f8f6a73d5d2e943865243c3694a339
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/AllIn13DShaderDemoScriptsAssembly.asmdef
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,125 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class AllIn13DShaderShaderPropertyCurveAnim : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private string numericPropertyName = "_HsvShift";
|
||||
|
||||
[SerializeField] private AnimationCurve animationCurve = AnimationCurve.Linear(0f, 0f, 1f, 1f);
|
||||
[SerializeField] private float animationDuration = 1f;
|
||||
[SerializeField] private float waitDuration = 0.5f;
|
||||
[SerializeField] private float minValue = 0f;
|
||||
[SerializeField] private float maxValue = 1f;
|
||||
|
||||
[Space, SerializeField, Header("If empty uses instances of currently used Materials")]
|
||||
private Material[] materials;
|
||||
private Material[] originalMaterials;
|
||||
private bool restoreMaterialsOnDisable = false;
|
||||
|
||||
private int propertyShaderID;
|
||||
private float timer = 0f;
|
||||
private bool isAnimating = true;
|
||||
private bool isValid = true;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if(materials == null || materials.Length == 0)
|
||||
{
|
||||
Renderer renderer = GetComponent<Renderer>();
|
||||
if(renderer != null) materials = renderer.materials;
|
||||
}
|
||||
else
|
||||
{
|
||||
originalMaterials = new Material[materials.Length];
|
||||
for(int i = 0; i < materials.Length; i++)
|
||||
if(materials[i] != null) originalMaterials[i] = new Material(materials[i]);
|
||||
restoreMaterialsOnDisable = true;
|
||||
}
|
||||
|
||||
if(materials == null || materials.Length == 0) DestroyComponentAndLogError(gameObject.name + " has no valid Materials, deleting AllIn1VfxScrollShaderProperty component");
|
||||
else
|
||||
{
|
||||
bool allValid = true;
|
||||
for(int i = 0; i < materials.Length; i++)
|
||||
{
|
||||
if(materials[i] == null || !materials[i].HasProperty(numericPropertyName))
|
||||
{
|
||||
allValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(allValid)
|
||||
propertyShaderID = Shader.PropertyToID(numericPropertyName);
|
||||
else
|
||||
DestroyComponentAndLogError(gameObject.name + "'s Material(s) don't all have a " + numericPropertyName + " property");
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if(materials == null || materials.Length == 0)
|
||||
{
|
||||
if(isValid)
|
||||
{
|
||||
Debug.LogError("The object " + gameObject.name + " has no Materials and you are trying to access them. Please take a look");
|
||||
isValid = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
timer += Time.deltaTime;
|
||||
|
||||
if(isAnimating)
|
||||
{
|
||||
if(timer < animationDuration)
|
||||
{
|
||||
float normalizedTime = timer / animationDuration;
|
||||
float curveValue = animationCurve.Evaluate(normalizedTime);
|
||||
float remappedValue = Mathf.Lerp(minValue, maxValue, curveValue);
|
||||
|
||||
for(int i = 0; i < materials.Length; i++)
|
||||
if(materials[i] != null) materials[i].SetFloat(propertyShaderID, remappedValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
isAnimating = false;
|
||||
timer = 0f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(timer >= waitDuration)
|
||||
{
|
||||
isAnimating = true;
|
||||
timer = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DestroyComponentAndLogError(string logError)
|
||||
{
|
||||
Debug.LogError(logError);
|
||||
Destroy(this);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if(restoreMaterialsOnDisable && materials != null && originalMaterials != null)
|
||||
{
|
||||
for(int i = 0; i < materials.Length; i++)
|
||||
if(materials[i] != null && originalMaterials[i] != null)
|
||||
materials[i].CopyPropertiesFromMaterial(originalMaterials[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if(originalMaterials != null)
|
||||
for(int i = 0; i < originalMaterials.Length; i++)
|
||||
if(originalMaterials[i] != null) Destroy(originalMaterials[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a847b867911545f42a402db444415b1f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/AllIn13DShaderShaderPropertyCurveAnim.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,296 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
#endif
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class AllIn13dShaderDemoController : MonoBehaviour
|
||||
{
|
||||
public DemoExpositor CurrentExpositor
|
||||
{
|
||||
get
|
||||
{
|
||||
return demoExpositors[currentExpositorIndex];
|
||||
}
|
||||
}
|
||||
|
||||
public DemoElement CurrentDemoElement
|
||||
{
|
||||
get
|
||||
{
|
||||
return CurrentExpositor.CurrentDemoElement;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public DemoSceneConfiguration demoSceneConfig;
|
||||
public DemoUI demoUI;
|
||||
public Transform initPosition;
|
||||
|
||||
[SerializeField] private SkyController skyController;
|
||||
[SerializeField] private AllIn1MainLightController mainLightController;
|
||||
|
||||
[SerializeField] private DemoExpositor[] demoExpositors;
|
||||
[SerializeField] private GameObject expositorNameGo;
|
||||
|
||||
[SerializeField] private DemoCameraController cameraController;
|
||||
|
||||
[SerializeField] private GameObject environmentsParentGo;
|
||||
|
||||
|
||||
//private DemoElement currentDemoElement;
|
||||
private DemoElement previousDemoElement;
|
||||
|
||||
[Space, Header("Start Index")]
|
||||
[SerializeField] private int startExpositorIndex;
|
||||
[SerializeField] private int startDemoIndex;
|
||||
|
||||
[Space, Header("Event Systems")]
|
||||
[SerializeField] private EventSystem oldInputEventSystem;
|
||||
[SerializeField] private EventSystem newInputEventSystem;
|
||||
|
||||
[Space, Header("Input Handlers")]
|
||||
[SerializeField] private InputHandler showDemoInfoHandler;
|
||||
|
||||
[Space, Header("Scale Tweens")]
|
||||
[SerializeField] private AllIn1DemoScaleTween demoLabelScaleTween;
|
||||
[SerializeField] private AllIn1DemoScaleTween expositorLabelScaleTween;
|
||||
[SerializeField] private AllIn1DemoScaleTween infoPanelScaleTween;
|
||||
|
||||
private int currentExpositorIndex;
|
||||
private Vector3 targetCameraPosition;
|
||||
|
||||
private EnvironmentController currentEnvironmentController;
|
||||
private bool moveCurrentEnvironment;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
for(int i = 0; i < demoExpositors.Length; i++)
|
||||
{
|
||||
demoExpositors[i].Init(demoSceneConfig);
|
||||
}
|
||||
|
||||
int childCount = environmentsParentGo.transform.childCount;
|
||||
for(int i = childCount - 1; i >= 0; i--) Destroy(environmentsParentGo.transform.GetChild(i).gameObject);
|
||||
|
||||
EnableCorrectInputSystem();
|
||||
demoExpositors[startExpositorIndex].SetDemoExpositor(startDemoIndex);
|
||||
|
||||
demoUI.Refresh(CurrentExpositor);
|
||||
|
||||
previousDemoElement = null;
|
||||
|
||||
skyController.Init();
|
||||
|
||||
cameraController.Init(demoSceneConfig);
|
||||
|
||||
DemoChanged();
|
||||
|
||||
CurrentDemoElement.Show();
|
||||
|
||||
expositorNameGo.SetActive(demoExpositors.Length > 1);
|
||||
}
|
||||
|
||||
public void NavigateToNextExpositor()
|
||||
{
|
||||
previousDemoElement = CurrentDemoElement;
|
||||
Vector3 nextDemoPos = previousDemoElement.transform.position + cameraController.cam.transform.up * demoSceneConfig.distanceBetweenDemos;
|
||||
|
||||
CurrentDemoElement.Hide();
|
||||
ChangeExpositor(1);
|
||||
|
||||
moveCurrentEnvironment = false;
|
||||
|
||||
CurrentDemoElement.transform.position = nextDemoPos;
|
||||
CurrentDemoElement.Show();
|
||||
|
||||
expositorLabelScaleTween.ScaleDownTween();
|
||||
infoPanelScaleTween.ScaleUpTween();
|
||||
DemoChanged();
|
||||
}
|
||||
|
||||
public void NavigateToPreviousExpositor()
|
||||
{
|
||||
previousDemoElement = CurrentDemoElement;
|
||||
Vector3 nextDemoPos = previousDemoElement.transform.position - cameraController.cam.transform.up * demoSceneConfig.distanceBetweenDemos;
|
||||
|
||||
CurrentDemoElement.Hide();
|
||||
ChangeExpositor(-1);
|
||||
|
||||
moveCurrentEnvironment = false;
|
||||
|
||||
CurrentDemoElement.transform.position = nextDemoPos;
|
||||
CurrentDemoElement.Show();
|
||||
|
||||
expositorLabelScaleTween.ScaleDownTween();
|
||||
infoPanelScaleTween.ScaleUpTween();
|
||||
DemoChanged();
|
||||
}
|
||||
|
||||
public void NavigateToPreviousDemo()
|
||||
{
|
||||
previousDemoElement = CurrentDemoElement;
|
||||
|
||||
DemoElement nextDemoElement = demoExpositors[currentExpositorIndex].GetPreviousDemoElement();
|
||||
Vector3 nextDemoPos = GetNextDemoPos(previousDemoElement, nextDemoElement, -cameraController.cam.transform.right);
|
||||
|
||||
moveCurrentEnvironment = previousDemoElement.demoElementData.environment == nextDemoElement.demoElementData.environment;
|
||||
|
||||
demoExpositors[currentExpositorIndex].PreviousDemoElement(nextDemoPos);
|
||||
demoLabelScaleTween.ScaleDownTween();
|
||||
infoPanelScaleTween.ScaleUpTween();
|
||||
DemoChanged();
|
||||
}
|
||||
|
||||
public void NavigateToNextDemo()
|
||||
{
|
||||
previousDemoElement = CurrentDemoElement;
|
||||
|
||||
DemoElement nextDemoElement = demoExpositors[currentExpositorIndex].GetNextDemoElement();
|
||||
Vector3 nextDemoPos = GetNextDemoPos(previousDemoElement, nextDemoElement, cameraController.cam.transform.right);
|
||||
|
||||
moveCurrentEnvironment = previousDemoElement.demoElementData.environment == nextDemoElement.demoElementData.environment;
|
||||
|
||||
demoExpositors[currentExpositorIndex].NextDemoElement(nextDemoPos);
|
||||
demoLabelScaleTween.ScaleDownTween();
|
||||
infoPanelScaleTween.ScaleUpTween();
|
||||
DemoChanged();
|
||||
}
|
||||
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (moveCurrentEnvironment && currentEnvironmentController != null)
|
||||
{
|
||||
currentEnvironmentController.transform.position += cameraController.GetDeltaMovement();
|
||||
}
|
||||
}
|
||||
|
||||
private void DemoChanged()
|
||||
{
|
||||
demoUI.Refresh(CurrentExpositor);
|
||||
|
||||
mainLightController.DemoChanged(CurrentDemoElement.demoElementData);
|
||||
skyController.DemoChanged(CurrentDemoElement.demoElementData);
|
||||
|
||||
cameraController.DemoChanged(CurrentDemoElement);
|
||||
|
||||
CheckCurrentEnvironment();
|
||||
}
|
||||
|
||||
private Vector3 GetNextDemoPos(DemoElement previousDemo, DemoElement nextDemo, Vector3 dir)
|
||||
{
|
||||
//Vector3 res = previousDemo.transform.position;
|
||||
|
||||
//if(previousDemo.demoElementData.environment != nextDemo.demoElementData.environment)
|
||||
//{
|
||||
// res += dir * demoSceneConfig.distanceBetweenDemos;
|
||||
//}
|
||||
|
||||
Vector3 res = previousDemo.transform.position + dir * demoSceneConfig.distanceBetweenDemos;
|
||||
return res;
|
||||
}
|
||||
|
||||
private void CheckCurrentEnvironment()
|
||||
{
|
||||
DemoEnvironment currentEnvironment = CurrentDemoElement.demoElementData.environment;
|
||||
|
||||
DemoEnvironment previousEnvironment = previousDemoElement?.demoElementData.environment;
|
||||
|
||||
if(currentEnvironment != previousEnvironment)
|
||||
{
|
||||
if (currentEnvironmentController != null)
|
||||
{
|
||||
currentEnvironmentController.Hide();
|
||||
}
|
||||
|
||||
if(currentEnvironment != null)
|
||||
{
|
||||
ChangeEnvironment(currentEnvironment);
|
||||
}
|
||||
|
||||
moveCurrentEnvironment = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
moveCurrentEnvironment = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeEnvironment(DemoEnvironment environment)
|
||||
{
|
||||
GameObject newEnvironmentGo = Instantiate(environment.prefab);
|
||||
newEnvironmentGo.transform.parent = environmentsParentGo.transform;
|
||||
newEnvironmentGo.transform.position = CurrentDemoElement.transform.position;
|
||||
newEnvironmentGo.transform.rotation = Quaternion.identity;
|
||||
newEnvironmentGo.transform.localScale = Vector3.zero;
|
||||
|
||||
|
||||
currentEnvironmentController = newEnvironmentGo.GetComponent<EnvironmentController>();
|
||||
currentEnvironmentController.Init(demoSceneConfig);
|
||||
|
||||
currentEnvironmentController.Show(CurrentDemoElement);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[ContextMenu("Setup Demo Scene")]
|
||||
public void Setup()
|
||||
{
|
||||
RemoveOldElements();
|
||||
|
||||
for(int i = 0; i < demoSceneConfig.expositors.Length; i++)
|
||||
{
|
||||
DemoExpositorData expositorData = demoSceneConfig.expositors[i];
|
||||
|
||||
GameObject goExpositor = new GameObject($"Expositor {i + 1}");
|
||||
goExpositor.transform.parent = transform;
|
||||
goExpositor.transform.localPosition = new Vector3(0f, i * -25f, 0f);
|
||||
goExpositor.transform.localRotation = Quaternion.identity;
|
||||
|
||||
DemoExpositor expositor = goExpositor.AddComponent<DemoExpositor>();
|
||||
expositor.Setup(expositorData, demoSceneConfig);
|
||||
|
||||
ArrayUtility.Add(ref demoExpositors, expositor);
|
||||
}
|
||||
|
||||
currentExpositorIndex = 0;
|
||||
|
||||
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
|
||||
}
|
||||
|
||||
private void RemoveOldElements()
|
||||
{
|
||||
DemoExpositor[] expositorsToDestroy = transform.GetComponentsInChildren<DemoExpositor>();
|
||||
for(int i = 0; i < expositorsToDestroy.Length; i++)
|
||||
{
|
||||
DestroyImmediate(expositorsToDestroy[i].gameObject);
|
||||
}
|
||||
|
||||
ArrayUtility.Clear(ref demoExpositors);
|
||||
}
|
||||
#endif
|
||||
|
||||
private void ChangeExpositor(int changeAmount)
|
||||
{
|
||||
currentExpositorIndex += changeAmount;
|
||||
if(currentExpositorIndex >= demoExpositors.Length) currentExpositorIndex = 0;
|
||||
if(currentExpositorIndex < 0) currentExpositorIndex = demoExpositors.Length - 1;
|
||||
}
|
||||
|
||||
public int GetCurrentExpositorIndex() => currentExpositorIndex;
|
||||
|
||||
private void EnableCorrectInputSystem()
|
||||
{
|
||||
bool newInputSystemEnabled = false;
|
||||
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
|
||||
newInputSystemEnabled = true;
|
||||
#endif
|
||||
oldInputEventSystem.gameObject.SetActive(!newInputSystemEnabled);
|
||||
newInputEventSystem.gameObject.SetActive(newInputSystemEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 412bc66d707f9c54e9f47717d21f77ae
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/AllIn13dShaderDemoController.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,15 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class AllIn1AutoRotate : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float rotationSpeed = 30f;
|
||||
[SerializeField] private Vector3 rotationAxis = Vector3.up;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
transform.Rotate(rotationAxis * (rotationSpeed * Time.deltaTime), Space.World);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c87fcb4b45b61be46bdb72dcaa09c6f2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/AllIn1AutoRotate.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,53 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class AllIn1CanvasFader : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private KeyCode fadeToggleKey = KeyCode.U;
|
||||
[SerializeField] private float tweenSpeed = 1f;
|
||||
[SerializeField] private AllIn1DemoScaleTween hideUiButtonTween;
|
||||
|
||||
private bool isTweening = false;
|
||||
private float currentAlpha = 1f;
|
||||
private float targetAlpha = 1f;
|
||||
private CanvasGroup canvasGroup;
|
||||
private bool hideUiButtonTweenNotNull;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
canvasGroup = GetComponent<CanvasGroup>();
|
||||
canvasGroup.alpha = 1f;
|
||||
hideUiButtonTweenNotNull = hideUiButtonTween != null;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if(Input.GetKeyDown(fadeToggleKey)) HideUiButtonPressed();
|
||||
|
||||
if(!isTweening) return;
|
||||
currentAlpha = Mathf.MoveTowards(currentAlpha, targetAlpha, Time.unscaledDeltaTime * tweenSpeed);
|
||||
canvasGroup.alpha = currentAlpha;
|
||||
if(targetAlpha == currentAlpha) isTweening = false;
|
||||
}
|
||||
|
||||
public void HideUiButtonPressed()
|
||||
{
|
||||
if(currentAlpha < 0.01f) MakeCanvasVisibleTween();
|
||||
else MakeCanvasInvisibleTween();
|
||||
if(hideUiButtonTweenNotNull) hideUiButtonTween.ScaleUpTween();
|
||||
}
|
||||
|
||||
private void MakeCanvasVisibleTween()
|
||||
{
|
||||
isTweening = true;
|
||||
targetAlpha = 1f;
|
||||
}
|
||||
|
||||
private void MakeCanvasInvisibleTween()
|
||||
{
|
||||
isTweening = true;
|
||||
targetAlpha = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82afebb9958e7ff4b817915f67b326af
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/AllIn1CanvasFader.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,65 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
[RequireComponent(typeof(InputHandler))]
|
||||
public class AllIn1DemoButtonPress : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private InputHandler inputHandler;
|
||||
[SerializeField] private AllIn1DemoScaleTween scaleTween;
|
||||
[SerializeField] private Button button;
|
||||
|
||||
[Space, Header("Label Settings")]
|
||||
[SerializeField] private bool completelyIgnoreLabel;
|
||||
[SerializeField] private bool showKeyLabel = true;
|
||||
[SerializeField] private TextMeshProUGUI keyLabel;
|
||||
|
||||
private Coroutine resetButtonColorCr;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if(!completelyIgnoreLabel)
|
||||
{
|
||||
if(!showKeyLabel)
|
||||
{
|
||||
keyLabel.enabled = false;
|
||||
enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
keyLabel.text = $"(Key {inputHandler.GetTargetKey().ToString()})";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if(inputHandler.IsKeyPressed())
|
||||
{
|
||||
SimulateClick();
|
||||
}
|
||||
}
|
||||
|
||||
private void SimulateClick()
|
||||
{
|
||||
if(button != null)
|
||||
{
|
||||
ColorBlock colors = button.colors;
|
||||
button.targetGraphic.color = colors.pressedColor;
|
||||
button.onClick.Invoke();
|
||||
|
||||
if(resetButtonColorCr != null) StopCoroutine(resetButtonColorCr);
|
||||
resetButtonColorCr = StartCoroutine(ResetButtonColor());
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator ResetButtonColor()
|
||||
{
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
button.targetGraphic.color = button.colors.normalColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0e6b5525608b2546bdd773ea2bdc6b8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/AllIn1DemoButtonPress.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,49 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class AllIn1DemoScaleTween : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float maxTweenScale = 1.25f;
|
||||
[SerializeField] private float minTweenScale = 0.5f;
|
||||
[SerializeField] private float tweenSpeed = 15f;
|
||||
|
||||
private bool isTweening = false;
|
||||
private float currentScale = 1f;
|
||||
private Vector3 scaleToApply = Vector3.one;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if(!isTweening) return;
|
||||
currentScale = Mathf.Lerp(currentScale, 1f, Time.unscaledDeltaTime * tweenSpeed);
|
||||
UpdateScaleToApply();
|
||||
ApplyScale();
|
||||
if(Mathf.Abs(currentScale - 1f) < 0.02f) isTweening = false;
|
||||
}
|
||||
|
||||
private void UpdateScaleToApply()
|
||||
{
|
||||
scaleToApply.x = currentScale;
|
||||
scaleToApply.y = currentScale;
|
||||
}
|
||||
|
||||
private void ApplyScale()
|
||||
{
|
||||
transform.localScale = scaleToApply;
|
||||
}
|
||||
|
||||
public void ScaleUpTween()
|
||||
{
|
||||
isTweening = true;
|
||||
currentScale = maxTweenScale;
|
||||
UpdateScaleToApply();
|
||||
}
|
||||
|
||||
public void ScaleDownTween()
|
||||
{
|
||||
isTweening = true;
|
||||
currentScale = minTweenScale;
|
||||
UpdateScaleToApply();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d8639573e99fb143ab0f4e90c44e1e7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/AllIn1DemoScaleTween.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,27 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
[RequireComponent(typeof(Light))]
|
||||
public class AllIn1FadeLight : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float fadeDuration = 0.1f;
|
||||
[SerializeField] private bool destroyWhenFaded = true;
|
||||
private Light targetLight;
|
||||
private float animationRatioRemaining = 1f;
|
||||
private float iniLightIntensity;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
targetLight = GetComponent<Light>();
|
||||
iniLightIntensity = targetLight.intensity;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
targetLight.intensity = Mathf.Lerp(0f, iniLightIntensity, animationRatioRemaining);
|
||||
animationRatioRemaining -= Time.deltaTime / fadeDuration;
|
||||
if(destroyWhenFaded && animationRatioRemaining <= 0f) Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 558b99d21ed97e74b91d33cbf6d03183
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/AllIn1FadeLight.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,15 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class AllIn1MainLightController : MonoBehaviour
|
||||
{
|
||||
public Light mainDirectionalLight;
|
||||
|
||||
public void DemoChanged(DemoElementData demoElementData)
|
||||
{
|
||||
mainDirectionalLight.enabled = demoElementData.directionalLightEnabled;
|
||||
mainDirectionalLight.intensity = demoElementData.mainLightIntensity;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 706d6c9c96c757141aab2f13eaf4c90f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/AllIn1MainLightController.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,104 @@
|
||||
using UnityEngine;
|
||||
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
|
||||
using UnityEngine.InputSystem;
|
||||
#endif
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class AllIn1MouseTransformRotator : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float rotationSpeedHorizontal = 10f;
|
||||
[SerializeField] private float verticalSpeed = 5f;
|
||||
[SerializeField] private bool rightClickRequired = true;
|
||||
|
||||
[Header("Movement Constraints")]
|
||||
[SerializeField] private float maxVerticalAngle = 80f;
|
||||
[SerializeField] private float minVerticalAngle = -60f;
|
||||
|
||||
[Space, Header("Zoom")]
|
||||
[SerializeField] private bool enableZoom = true;
|
||||
[SerializeField] private float zoomSpeed = 5f;
|
||||
[SerializeField] private float maxZoomDistance = 20f;
|
||||
[SerializeField] private float minZoomDistance = 2f;
|
||||
|
||||
private Transform zoomTargetTransform;
|
||||
private float currentVerticalRotation = 0f;
|
||||
private float currentHorizontalRotation = 0f;
|
||||
private float currentZoomDistance = 10f;
|
||||
private float dt;
|
||||
|
||||
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
|
||||
private Mouse mouse;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
mouse = Mouse.current;
|
||||
Initialize();
|
||||
}
|
||||
#else
|
||||
private void Awake()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
#endif
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
Vector3 currentRotation = transform.eulerAngles;
|
||||
currentHorizontalRotation = currentRotation.y;
|
||||
currentVerticalRotation = currentRotation.x;
|
||||
zoomTargetTransform = transform.GetChild(0);
|
||||
currentZoomDistance = zoomTargetTransform.localPosition.z;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
dt = Time.deltaTime;
|
||||
HandleRotation();
|
||||
if(enableZoom) HandleZoom();
|
||||
}
|
||||
|
||||
private void HandleRotation()
|
||||
{
|
||||
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
|
||||
if(mouse == null) return;
|
||||
float mouseX = mouse.delta.ReadValue().x * dt * rotationSpeedHorizontal;
|
||||
float mouseY = mouse.delta.ReadValue().y * dt * verticalSpeed;
|
||||
bool isRightMousePressed = mouse.rightButton.isPressed;
|
||||
#else
|
||||
float mouseX = Input.GetAxis("Mouse X") * dt * rotationSpeedHorizontal;
|
||||
float mouseY = Input.GetAxis("Mouse Y") * dt * verticalSpeed;
|
||||
bool isRightMousePressed = Input.GetMouseButton(1);
|
||||
#endif
|
||||
if((!rightClickRequired && !isRightMousePressed) || (rightClickRequired && isRightMousePressed))
|
||||
{
|
||||
// Update rotations
|
||||
currentHorizontalRotation += mouseX;
|
||||
currentVerticalRotation += mouseY;
|
||||
|
||||
// Clamp vertical rotation
|
||||
currentVerticalRotation = Mathf.Clamp(currentVerticalRotation, minVerticalAngle, maxVerticalAngle);
|
||||
|
||||
// Apply rotations
|
||||
transform.rotation = Quaternion.Euler(currentVerticalRotation, currentHorizontalRotation, 0f);
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleZoom()
|
||||
{
|
||||
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
|
||||
if(mouse == null) return;
|
||||
float scrollDelta = mouse.scroll.ReadValue().y * dt * zoomSpeed;
|
||||
#else
|
||||
float scrollDelta = Input.GetAxis("Mouse ScrollWheel") * dt * zoomSpeed * 100f;
|
||||
#endif
|
||||
// Update zoom distance
|
||||
currentZoomDistance = Mathf.Clamp(currentZoomDistance + scrollDelta, minZoomDistance, maxZoomDistance);
|
||||
|
||||
// Apply new position
|
||||
Vector3 localPos = zoomTargetTransform.localPosition;
|
||||
localPos.z = currentZoomDistance;
|
||||
zoomTargetTransform.localPosition = localPos;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9e8e28469a910c418e1840fabdaab78
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/AllIn1MouseTransformRotator.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,87 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class AllIn1TimeControl : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private KeyCode increaseTimeScale = KeyCode.UpArrow;
|
||||
[SerializeField] private KeyCode increaseTimeScaleAlt = KeyCode.W;
|
||||
[SerializeField] private KeyCode decreaseTimeScale = KeyCode.DownArrow;
|
||||
[SerializeField] private KeyCode decreaseTimeScaleAlt = KeyCode.S;
|
||||
[SerializeField] private KeyCode pauseKey = KeyCode.P;
|
||||
[SerializeField, Range(0f, 1f)] private float timeScaleInterval = 0.05f;
|
||||
[SerializeField] private Slider timeScaleSlider;
|
||||
[SerializeField] private Image pausedButtonImage;
|
||||
[SerializeField] private Color pausedButtonColor;
|
||||
private bool timeScaleSliderNotNull;
|
||||
private float lastChangeTime;
|
||||
private AllIn1DemoScaleTween pausedButtonTween;
|
||||
private Text pausedButtonText;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
timeScaleSliderNotNull = timeScaleSlider != null;
|
||||
pausedButtonTween = pausedButtonImage.GetComponent<AllIn1DemoScaleTween>();
|
||||
pausedButtonText = pausedButtonImage.GetComponentInChildren<Text>();
|
||||
UpdateTimeScaleUI();
|
||||
if(timeScaleSliderNotNull) timeScaleSlider.onValueChanged.AddListener(delegate { ChangeTimeScale(timeScaleSlider.value - Time.timeScale); });
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if(Input.GetKeyDown(increaseTimeScale) || Input.GetKeyDown(increaseTimeScaleAlt)) ChangeTimeScale(timeScaleInterval);
|
||||
if(Input.GetKeyDown(decreaseTimeScale) || Input.GetKeyDown(decreaseTimeScaleAlt)) ChangeTimeScale(-timeScaleInterval);
|
||||
if(Input.GetKeyDown(pauseKey))
|
||||
{
|
||||
if(Time.timeScale < 0.01f) ChangeTimeScale(1f - Time.timeScale);
|
||||
else ChangeTimeScale(-Time.timeScale);
|
||||
pausedButtonTween.ScaleUpTween();
|
||||
}
|
||||
|
||||
float timeScaleChangeInterval = 0.1f;
|
||||
if(!(Time.unscaledTime - lastChangeTime > timeScaleChangeInterval)) return;
|
||||
if(Input.GetKey(increaseTimeScale) || Input.GetKey(increaseTimeScaleAlt)) ChangeTimeScale(timeScaleInterval);
|
||||
if(Input.GetKey(decreaseTimeScale) || Input.GetKey(decreaseTimeScaleAlt)) ChangeTimeScale(-timeScaleInterval);
|
||||
}
|
||||
|
||||
private void ChangeTimeScale(float changeAmount)
|
||||
{
|
||||
Time.timeScale = Mathf.Clamp(Time.timeScale + changeAmount, 0.0f, 1f);
|
||||
lastChangeTime = Time.unscaledTime;
|
||||
UpdateTimeScaleUI();
|
||||
}
|
||||
|
||||
private void UpdateTimeScaleUI()
|
||||
{
|
||||
if(timeScaleSliderNotNull) timeScaleSlider.value = Time.timeScale;
|
||||
if(Time.timeScale < 0.01f)
|
||||
{
|
||||
pausedButtonText.text = "Unpause";
|
||||
pausedButtonImage.color = pausedButtonColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
pausedButtonText.text = "Pause";
|
||||
pausedButtonImage.color = Color.white;
|
||||
}
|
||||
}
|
||||
|
||||
public void PauseUiButton()
|
||||
{
|
||||
if(Time.timeScale < 0.01f) Time.timeScale = 1f;
|
||||
else Time.timeScale = 0f;
|
||||
|
||||
UpdateTimeScaleUI();
|
||||
}
|
||||
|
||||
public void CurrentEffectChanged()
|
||||
{
|
||||
if(Time.timeScale < 0.01f)
|
||||
{
|
||||
Time.timeScale = 0.1f;
|
||||
UpdateTimeScaleUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55cb4f27152d94a4890b9107d0da14f2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/AllIn1TimeControl.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,113 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles billboard behavior to face camera either on Y-axis only or all axes
|
||||
/// Can follow either editor scene view camera or main camera with cached reference
|
||||
/// </summary>
|
||||
[ExecuteAlways]
|
||||
public class Billboard : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private bool yAxisOnly = true;
|
||||
|
||||
[SerializeField, Tooltip("If true, will update rotation every frame. If false, only on camera movement")]
|
||||
private bool continuousUpdate = true;
|
||||
|
||||
[SerializeField, Tooltip("If true, follows editor scene view camera. If false, follows main camera")]
|
||||
private bool useEditorCamera = false;
|
||||
|
||||
private Transform targetCameraTransform;
|
||||
private Vector3 previousCameraPosition;
|
||||
private Quaternion initialRotation;
|
||||
private bool wasUsingEditorCamera;
|
||||
|
||||
// Static cached reference to main camera
|
||||
private static Camera mainCameraCache;
|
||||
private static bool mainCameraSearched = false;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
// Reset camera search if re-enabled
|
||||
if (!useEditorCamera && !mainCameraSearched)
|
||||
{
|
||||
UpdateCameraReference();
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
bool shouldUpdateCamera = targetCameraTransform == null || wasUsingEditorCamera != useEditorCamera;
|
||||
|
||||
if(shouldUpdateCamera)
|
||||
{
|
||||
UpdateCameraReference();
|
||||
}
|
||||
|
||||
if(targetCameraTransform == null) return;
|
||||
|
||||
if(!continuousUpdate && previousCameraPosition == targetCameraTransform.position)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(yAxisOnly)
|
||||
{
|
||||
// Only rotate around Y axis
|
||||
Vector3 directionToCamera = targetCameraTransform.position - transform.position;
|
||||
directionToCamera.y = 0;
|
||||
|
||||
if(directionToCamera != Vector3.zero)
|
||||
{
|
||||
transform.rotation = Quaternion.LookRotation(directionToCamera) * initialRotation;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Full billboard - face camera completely
|
||||
transform.LookAt(transform.position + targetCameraTransform.rotation * Vector3.forward,
|
||||
targetCameraTransform.rotation * Vector3.up);
|
||||
}
|
||||
|
||||
previousCameraPosition = targetCameraTransform.position;
|
||||
}
|
||||
|
||||
private void UpdateCameraReference()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if(useEditorCamera)
|
||||
{
|
||||
SceneView sceneView = SceneView.lastActiveSceneView;
|
||||
if(sceneView == null || sceneView.camera == null) return;
|
||||
|
||||
targetCameraTransform = sceneView.camera.transform;
|
||||
wasUsingEditorCamera = true;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// Use cached camera reference if available
|
||||
if (mainCameraCache == null || !mainCameraCache.isActiveAndEnabled)
|
||||
{
|
||||
mainCameraCache = Camera.main;
|
||||
mainCameraSearched = true;
|
||||
}
|
||||
|
||||
if(mainCameraCache == null) return;
|
||||
targetCameraTransform = mainCameraCache.transform;
|
||||
wasUsingEditorCamera = false;
|
||||
}
|
||||
|
||||
initialRotation = Quaternion.identity;
|
||||
}
|
||||
|
||||
// Handle scene changes or camera destruction
|
||||
private void OnValidate()
|
||||
{
|
||||
// Force update of camera reference when properties change in inspector
|
||||
targetCameraTransform = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ed080149842b6b44bb6eec1735711ba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/Billboard.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,120 @@
|
||||
using UnityEngine;
|
||||
|
||||
#if ALLIN13DSHADER_BIRP && UNITY_POST_PROCESSING_STACK_V2
|
||||
using UnityEngine.Rendering.PostProcessing;
|
||||
#endif
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class DemoCameraController : MonoBehaviour
|
||||
{
|
||||
public enum TransitionState
|
||||
{
|
||||
NONE = 0,
|
||||
MOVING = 1,
|
||||
}
|
||||
|
||||
private Vector3 srcPosition;
|
||||
private Quaternion srcRotation;
|
||||
|
||||
private Vector3 dstPosition;
|
||||
private Quaternion dstRotation;
|
||||
|
||||
private AnimationCurve cameraCurve;
|
||||
|
||||
private TransitionState transitionState;
|
||||
private float timer;
|
||||
private float transitionDuration;
|
||||
|
||||
private Vector3 deltaMovement;
|
||||
|
||||
public Transform target;
|
||||
public float lerpSpeed;
|
||||
|
||||
[Header("Camera")]
|
||||
public Camera cam;
|
||||
|
||||
#if ALLIN13DSHADER_BIRP && UNITY_POST_PROCESSING_STACK_V2
|
||||
[Header("Postprocess")]
|
||||
public PostProcessLayer postProcessLayer;
|
||||
public PostProcessVolume postProcessVolume;
|
||||
#endif
|
||||
|
||||
public void Init(DemoSceneConfiguration demoSceneConfig)
|
||||
{
|
||||
this.cameraCurve = demoSceneConfig.cameraCurve;
|
||||
this.transitionState = TransitionState.NONE;
|
||||
this.transitionDuration = demoSceneConfig.cameraTransitionDuration;
|
||||
}
|
||||
|
||||
public void DemoChanged(DemoElement demoElement)
|
||||
{
|
||||
transitionState = TransitionState.MOVING;
|
||||
|
||||
srcPosition = target.position;
|
||||
srcRotation = target.rotation;
|
||||
|
||||
dstPosition = demoElement.transform.position;
|
||||
dstRotation = Quaternion.identity;
|
||||
|
||||
#if ALLIN13DSHADER_BIRP && UNITY_POST_PROCESSING_STACK_V2
|
||||
if (postProcessLayer != null)
|
||||
{
|
||||
postProcessLayer.enabled = demoElement.demoElementData.postProcessEnabled;
|
||||
}
|
||||
|
||||
if(postProcessVolume != null)
|
||||
{
|
||||
postProcessVolume.enabled = demoElement.demoElementData.postProcessEnabled;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public void GoTo(Transform tr)
|
||||
{
|
||||
transitionState = TransitionState.MOVING;
|
||||
|
||||
dstPosition = tr.position;
|
||||
dstRotation = tr.rotation;
|
||||
|
||||
srcPosition = target.position;
|
||||
srcRotation = target.rotation;
|
||||
}
|
||||
|
||||
public Vector3 GetDeltaMovement()
|
||||
{
|
||||
return deltaMovement;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if(transitionState == TransitionState.MOVING)
|
||||
{
|
||||
Update_Moving();
|
||||
}
|
||||
else
|
||||
{
|
||||
deltaMovement = Vector3.zero;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update_Moving()
|
||||
{
|
||||
timer += Time.deltaTime;
|
||||
float t = timer / transitionDuration;
|
||||
float curveT = cameraCurve.Evaluate(t);
|
||||
|
||||
Vector3 newPosition = Vector3.LerpUnclamped(srcPosition, dstPosition, curveT);
|
||||
deltaMovement = newPosition - target.transform.position;
|
||||
|
||||
target.transform.position = newPosition;
|
||||
target.transform.rotation = Quaternion.SlerpUnclamped(srcRotation, dstRotation, curveT);
|
||||
|
||||
if(t >= 1f)
|
||||
{
|
||||
transitionState = TransitionState.NONE;
|
||||
timer = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 559c47b838b33484d9e24d155c754de2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/DemoCameraController.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class DemoElement : MonoBehaviour
|
||||
{
|
||||
public MeshRenderer[] renderers;
|
||||
|
||||
public DemoElementData demoElementData;
|
||||
|
||||
public TransformScaler transformScaler;
|
||||
|
||||
public PropertyTweenCollection tweenCollection;
|
||||
|
||||
public int demoIndex { get; private set; }
|
||||
|
||||
|
||||
public virtual void Init(DemoSceneConfiguration demoSceneConfig, int demoIndex)
|
||||
{
|
||||
transform.localScale = Vector3.zero;
|
||||
gameObject.SetActive(false);
|
||||
|
||||
transformScaler.Init(demoSceneConfig, ScaleFinishedCallback);
|
||||
|
||||
tweenCollection.Init();
|
||||
|
||||
this.demoIndex = demoIndex;
|
||||
}
|
||||
|
||||
public virtual void Update()
|
||||
{
|
||||
tweenCollection.Update(Time.deltaTime);
|
||||
}
|
||||
|
||||
public void Show()
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
transformScaler.ScaleUp();
|
||||
}
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
transformScaler.ScaleDown();
|
||||
}
|
||||
|
||||
public void ScaleFinishedCallback(TransformScaler.ScalingType scalingOperation)
|
||||
{
|
||||
if(scalingOperation == TransformScaler.ScalingType.SCALING_DOWN)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsScaling()
|
||||
{
|
||||
bool res = transformScaler.IsScaling();
|
||||
return res;
|
||||
}
|
||||
|
||||
// #if UNITY_EDITOR
|
||||
// private void OnValidate()
|
||||
// {
|
||||
// if(demoElementData == null)
|
||||
// {
|
||||
// string goName = gameObject.name;
|
||||
// if(goName.StartsWith("P_Demo_")) goName = goName.Substring(7);
|
||||
//
|
||||
// string[] guids = UnityEditor.AssetDatabase.FindAssets("t:DemoElementData");
|
||||
// foreach(string guid in guids)
|
||||
// {
|
||||
// string path = UnityEditor.AssetDatabase.GUIDToAssetPath(guid);
|
||||
// DemoElementData data = UnityEditor.AssetDatabase.LoadAssetAtPath<DemoElementData>(path);
|
||||
// if(data != null && data.prefab != null && data.prefab.name.Contains(goName))
|
||||
// {
|
||||
// demoElementData = data;
|
||||
// UnityEditor.EditorUtility.SetDirty(this);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// #endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1698d847b7bb109498dbc7867667a6f6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/DemoElement.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,32 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class DemoElementColorRamp : DemoElement
|
||||
{
|
||||
private static int COLOR_RAMP_MATPROP_ID = Shader.PropertyToID("_ColorRampTex");
|
||||
|
||||
private float timer;
|
||||
private int currentTextureIndex;
|
||||
|
||||
public Texture[] colorRamps;
|
||||
public float timeBetweenTextures;
|
||||
|
||||
public Material mat;
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
timer += Time.deltaTime;
|
||||
|
||||
if(timer >= timeBetweenTextures)
|
||||
{
|
||||
timer = 0f;
|
||||
currentTextureIndex = currentTextureIndex < colorRamps.Length - 1 ? currentTextureIndex + 1 : 0;
|
||||
|
||||
mat.SetTexture(COLOR_RAMP_MATPROP_ID, colorRamps[currentTextureIndex]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0453bc847f79848469a4203b1ce8b7cf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/DemoElementColorRamp.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class DemoElementData : ScriptableObject
|
||||
{
|
||||
public string demoName;
|
||||
public GameObject prefab;
|
||||
public DemoEnvironment environment;
|
||||
|
||||
[Header("Info")]
|
||||
[TextArea] public string info;
|
||||
|
||||
[Header("Min Directional Light")]
|
||||
public bool directionalLightEnabled = true;
|
||||
public float mainLightIntensity = 1.0f;
|
||||
|
||||
[Header("Skybox")]
|
||||
public bool skyboxEnabled = true;
|
||||
|
||||
[Header("Postprocess")]
|
||||
public bool postProcessEnabled = false;
|
||||
|
||||
// private void OnValidate()
|
||||
// {
|
||||
// if(string.IsNullOrEmpty(demoName)) demoName = GetFormattedName();
|
||||
// }
|
||||
//
|
||||
// private string GetFormattedName()
|
||||
// {
|
||||
// if(prefab == null) return string.Empty;
|
||||
//
|
||||
// string prefabName = prefab.name;
|
||||
// if(prefabName.StartsWith("P_Demo_")) prefabName = prefabName.Substring(7);
|
||||
//
|
||||
// if(prefabName.Length > 1)
|
||||
// {
|
||||
// int i = 1;
|
||||
// while(i < prefabName.Length)
|
||||
// {
|
||||
// if(char.IsUpper(prefabName[i]) && !char.IsWhiteSpace(prefabName[i-1]))
|
||||
// {
|
||||
// prefabName = prefabName.Insert(i, " ");
|
||||
// i++;
|
||||
// }
|
||||
// i++;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return prefabName;
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94ddca8ef013926408780e6e292bad16
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/DemoElementData.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,38 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class DemoElementIntersectionGlow : DemoElement
|
||||
{
|
||||
private float timer;
|
||||
|
||||
public float speed;
|
||||
public float minY;
|
||||
public float maxY;
|
||||
|
||||
public Transform target;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
timer = 0f;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
timer = 0f;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
timer += Time.deltaTime;
|
||||
|
||||
float sin01 = (Mathf.Sin(timer * speed) + 1f) * 0.5f;
|
||||
Vector3 localPos = target.localPosition;
|
||||
localPos.y = Mathf.Lerp(minY, maxY, sin01);
|
||||
|
||||
target.localPosition = localPos;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3bdcc7aefbba4b1428221d91f5435083
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/DemoElementIntersectionGlow.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,10 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class DemoEnvironment : ScriptableObject
|
||||
{
|
||||
public GameObject prefab;
|
||||
public int sceneIndex;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c4205413819227748acd4e41a3ce684e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/DemoEnvironment.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,162 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class DemoExpositor : MonoBehaviour
|
||||
{
|
||||
public DemoExpositorData expositorData;
|
||||
[SerializeField] private DemoElement[] demoElements;
|
||||
|
||||
private int currentDemoIndex;
|
||||
|
||||
public DemoElement CurrentDemoElement => demoElements[currentDemoIndex];
|
||||
public int CurrentDemoElementIndex => currentDemoIndex;
|
||||
|
||||
public void Init(DemoSceneConfiguration demoSceneConfig)
|
||||
{
|
||||
for (int i = 0; i < demoElements.Length; i++)
|
||||
{
|
||||
demoElements[i].Init(demoSceneConfig, i);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDemoExpositor(int newIndex)
|
||||
{
|
||||
currentDemoIndex = newIndex;
|
||||
}
|
||||
|
||||
public DemoElement GetNextDemoElement()
|
||||
{
|
||||
int nextIndex = currentDemoIndex + 1;
|
||||
if (nextIndex >= demoElements.Length)
|
||||
{
|
||||
nextIndex = 0;
|
||||
}
|
||||
|
||||
DemoElement res = demoElements[nextIndex];
|
||||
return res;
|
||||
}
|
||||
|
||||
public DemoElement GetPreviousDemoElement()
|
||||
{
|
||||
int nextIndex = currentDemoIndex - 1;
|
||||
if (nextIndex < 0)
|
||||
{
|
||||
nextIndex = demoElements.Length - 1;
|
||||
}
|
||||
|
||||
DemoElement res = demoElements[nextIndex];
|
||||
return res;
|
||||
}
|
||||
|
||||
public void NextDemoElement(Vector3 demoPos)
|
||||
{
|
||||
CurrentDemoElement.Hide();
|
||||
|
||||
currentDemoIndex++;
|
||||
if (currentDemoIndex >= demoElements.Length)
|
||||
{
|
||||
currentDemoIndex = 0;
|
||||
}
|
||||
|
||||
CurrentDemoElement.transform.position = demoPos;
|
||||
CurrentDemoElement.Show();
|
||||
}
|
||||
|
||||
public void PreviousDemoElement(Vector3 demoPos)
|
||||
{
|
||||
CurrentDemoElement.Hide();
|
||||
|
||||
currentDemoIndex--;
|
||||
if (currentDemoIndex < 0)
|
||||
{
|
||||
currentDemoIndex = demoElements.Length - 1;
|
||||
}
|
||||
|
||||
CurrentDemoElement.transform.position = demoPos;
|
||||
CurrentDemoElement.Show();
|
||||
}
|
||||
|
||||
public void SetElementDemoIndex(int demoIndex)
|
||||
{
|
||||
currentDemoIndex = Mathf.Min(demoIndex, demoElements.Length - 1);
|
||||
}
|
||||
|
||||
public DemoElement FindNearestElement(Vector3 referencePosition, out int demoIndex)
|
||||
{
|
||||
DemoElement res = null;
|
||||
|
||||
float minSqrDistance = float.MaxValue;
|
||||
demoIndex = 0;
|
||||
|
||||
Vector3 referencePositionWithoutY = referencePosition;
|
||||
referencePositionWithoutY.y = 0f;
|
||||
|
||||
|
||||
for (int i = 0; i < demoElements.Length; i++)
|
||||
{
|
||||
Vector3 demoElementWithoutY = demoElements[i].transform.position;
|
||||
demoElementWithoutY.y = 0f;
|
||||
|
||||
float sqrDistance = (referencePositionWithoutY - demoElementWithoutY).sqrMagnitude;
|
||||
if (sqrDistance <= minSqrDistance)
|
||||
{
|
||||
minSqrDistance = sqrDistance;
|
||||
res = demoElements[i];
|
||||
demoIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
if(CurrentDemoElement.demoElementData.environment == res.demoElementData.environment &&
|
||||
res.demoElementData.environment != null)
|
||||
{
|
||||
res = CurrentDemoElement;
|
||||
demoIndex = CurrentDemoElement.demoIndex;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public void Setup(DemoExpositorData expositorData, DemoSceneConfiguration demoSceneConfig)
|
||||
{
|
||||
this.expositorData = expositorData;
|
||||
|
||||
if (demoElements != null)
|
||||
{
|
||||
ArrayUtility.Clear(ref demoElements);
|
||||
}
|
||||
else
|
||||
{
|
||||
demoElements = new DemoElement[0];
|
||||
}
|
||||
|
||||
DemoEnvironment lastEnvironment = null;
|
||||
Vector3 lastLocalPosition = new Vector3(-demoSceneConfig.distanceBetweenDemos, 0f, 0f);
|
||||
for (int i = 0; i < expositorData.demos.Length; i++)
|
||||
{
|
||||
DemoElementData demoElementData = expositorData.demos[i];
|
||||
GameObject demoElementGo = (GameObject)PrefabUtility.InstantiatePrefab(demoElementData.prefab, transform);
|
||||
|
||||
lastLocalPosition.x += demoSceneConfig.distanceBetweenDemos;
|
||||
lastEnvironment = demoElementData.environment;
|
||||
|
||||
demoElementGo.transform.localPosition = lastLocalPosition;
|
||||
demoElementGo.transform.localRotation = Quaternion.identity;
|
||||
Debug.LogError($"{gameObject.name} - {demoElementGo.name} at {demoElementGo.transform.localPosition} -t:{Time.time}", demoElementGo);
|
||||
|
||||
DemoElement demoElement = demoElementGo.GetComponent<DemoElement>();
|
||||
|
||||
ArrayUtility.Add(ref demoElements, demoElement);
|
||||
}
|
||||
|
||||
currentDemoIndex = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 684c2ea481da2714ea0aed60ea54c2fe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/DemoExpositor.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,10 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class DemoExpositorData : ScriptableObject
|
||||
{
|
||||
public string expositorName;
|
||||
public DemoElementData[] demos;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e717b5696b9da764094cc1b224cb9b72
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/DemoExpositorData.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class DemoInfoUI : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private RectTransform offScreenT, initialT;
|
||||
[SerializeField] private float smoothingAmount;
|
||||
[SerializeField] private TMP_Text txtDemoInfo;
|
||||
|
||||
private RectTransform myT, currentTargetT;
|
||||
private bool isClosed;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
myT = transform as RectTransform;
|
||||
CopyRectTransform(myT, initialT);
|
||||
currentTargetT = offScreenT;
|
||||
myT.position = currentTargetT.position;
|
||||
isClosed = true;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if(currentTargetT == null) return;
|
||||
myT.position = Vector3.Lerp(myT.position, currentTargetT.position, smoothingAmount * Time.deltaTime);
|
||||
}
|
||||
|
||||
public void DemoChanged(DemoElementData demoElementdata)
|
||||
{
|
||||
txtDemoInfo.text = demoElementdata.info;
|
||||
}
|
||||
|
||||
public void ShowHideToggle()
|
||||
{
|
||||
isClosed = !isClosed;
|
||||
currentTargetT = isClosed ? offScreenT : initialT;
|
||||
}
|
||||
|
||||
private void CopyRectTransform(RectTransform source, RectTransform target)
|
||||
{
|
||||
if(source == null || target == null)
|
||||
{
|
||||
Debug.LogError("Source or target RectTransform is null");
|
||||
return;
|
||||
}
|
||||
|
||||
// Copy anchoring
|
||||
target.anchorMin = source.anchorMin;
|
||||
target.anchorMax = source.anchorMax;
|
||||
target.pivot = source.pivot;
|
||||
|
||||
// Copy positioning
|
||||
target.anchoredPosition = source.anchoredPosition;
|
||||
target.anchoredPosition3D = source.anchoredPosition3D;
|
||||
target.sizeDelta = source.sizeDelta;
|
||||
|
||||
// Copy rotation and scale
|
||||
target.rotation = source.rotation;
|
||||
target.localRotation = source.localRotation;
|
||||
target.localScale = source.localScale;
|
||||
|
||||
// Copy offset values
|
||||
target.offsetMin = source.offsetMin;
|
||||
target.offsetMax = source.offsetMax;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43bb1bdec3d56ff44ab3d28f90bfbf76
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/DemoInfoUI.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,28 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class DemoLightUrpIntensity : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Light thisLight;
|
||||
[SerializeField] private float urpIntensityMultiplier = 5f;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
#if ALLIN13DSHADER_URP
|
||||
thisLight.intensity *= urpIntensityMultiplier;
|
||||
#else
|
||||
float t = urpIntensityMultiplier; //This is preventing a compilation warning in the editor
|
||||
#endif
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
if(thisLight == null)
|
||||
{
|
||||
thisLight = GetComponent<Light>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: afc39b4cbc1e00449b2ff0c95caeba62
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/DemoLightUrpIntensity.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class DemoMaterialSinEffect : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Renderer targetRenderer;
|
||||
[SerializeField] private string propertyName = "_AlphaCutoffValue";
|
||||
[SerializeField] private float minValue = 0f;
|
||||
[SerializeField] private float maxValue = 1f;
|
||||
[SerializeField] private float speed = 1f;
|
||||
|
||||
private Material currMaterial;
|
||||
private int propertyId;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
currMaterial = new Material(targetRenderer.material);
|
||||
targetRenderer.material = currMaterial;
|
||||
propertyId = Shader.PropertyToID(propertyName);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float sinValue = Mathf.Sin(Time.unscaledTime * speed);
|
||||
float mappedValue = Mathf.Lerp(minValue, maxValue, (sinValue + 1f) * 0.5f);
|
||||
currMaterial.SetFloat(propertyId, mappedValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 313bb0b62ef216644a2bcb247758fdb2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/DemoMaterialSinEffect.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,20 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class DemoSceneConfiguration : ScriptableObject
|
||||
{
|
||||
public float scaleDuration = 0.4f;
|
||||
public float distanceBetweenDemos = 25f;
|
||||
public float cameraTransitionDuration = 1f;
|
||||
public float alphaDuration = 0.25f;
|
||||
|
||||
[Header("Curves")]
|
||||
public AnimationCurve scalingCurve;
|
||||
public AnimationCurve cameraCurve;
|
||||
public AnimationCurve alphaCurve;
|
||||
|
||||
[Header("Expositors")]
|
||||
public DemoExpositorData[] expositors;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff5f3343548edfb4687065aa80ba2a44
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/DemoSceneConfiguration.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,37 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class DemoUI : MonoBehaviour
|
||||
{
|
||||
public AllIn13dShaderDemoController demoController;
|
||||
public TMP_Text txtExpositorName, txtDemoName, txtDemoViewing;
|
||||
public AllIn1DemoScaleTween viewingTween;
|
||||
|
||||
public DemoInfoUI demoInfoUI;
|
||||
|
||||
public void Refresh(DemoExpositor currentExpositor)
|
||||
{
|
||||
Refresh(currentExpositor.expositorData, currentExpositor.CurrentDemoElement.demoElementData);
|
||||
}
|
||||
|
||||
private void Refresh(DemoExpositorData expositorData, DemoElementData demoElementData)
|
||||
{
|
||||
int currentExpositorIndex = demoController.GetCurrentExpositorIndex() + 1;
|
||||
int currentDemoElementIndex = demoController.CurrentExpositor.CurrentDemoElementIndex + 1;
|
||||
txtExpositorName.text = $"{currentExpositorIndex}. {expositorData.expositorName}";
|
||||
txtDemoName.text = $"{currentDemoElementIndex}. {demoElementData.demoName}";
|
||||
|
||||
demoInfoUI.DemoChanged(demoElementData);
|
||||
|
||||
txtDemoViewing.text = $"Viewing: {currentExpositorIndex} - {currentDemoElementIndex}";
|
||||
viewingTween.ScaleUpTween();
|
||||
}
|
||||
|
||||
public void ShowOrHideDemoInfo()
|
||||
{
|
||||
demoInfoUI.ShowHideToggle();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 192a33b5e551b1a4bad83252c99ec644
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/DemoUI.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public static class DemoUtils
|
||||
{
|
||||
public static float EaseOutBack(float progress)
|
||||
{
|
||||
const float overshootBase = 2.7f;
|
||||
float overshootModifier = overshootBase + 1f;
|
||||
|
||||
float res = 1f + overshootModifier * Mathf.Pow(progress - 1f, 3f) + overshootBase * Mathf.Pow(progress - 1f, 2f);
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void SetMaterialTransparent(Material mat)
|
||||
{
|
||||
mat.renderQueue = 3000;
|
||||
mat.SetFloat("_BlendSrc", (float)UnityEngine.Rendering.BlendMode.SrcAlpha);
|
||||
mat.SetFloat("_BlendDst", (float)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
|
||||
}
|
||||
|
||||
public static void SetMaterialOpaque(Material mat)
|
||||
{
|
||||
mat.renderQueue = 2000;
|
||||
mat.SetFloat("_BlendSrc", (float)UnityEngine.Rendering.BlendMode.One);
|
||||
mat.SetFloat("_BlendDst", (float)UnityEngine.Rendering.BlendMode.Zero);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 96ac2215b217c5c42994dd053daf7e27
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/DemoUtils.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,71 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor.SceneManagement;
|
||||
#endif
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class EnvironmentController : MonoBehaviour
|
||||
{
|
||||
public DemoElement linkedDemoElement;
|
||||
public TransformScaler transformScaler;
|
||||
public AlphaTween alphaTween;
|
||||
|
||||
public MeshRenderer[] renderers;
|
||||
|
||||
public void Init(DemoSceneConfiguration demoSceneConfig)
|
||||
{
|
||||
transformScaler.Init(demoSceneConfig, ScaleFinishedCallback);
|
||||
alphaTween.Init(demoSceneConfig, renderers);
|
||||
}
|
||||
|
||||
private void ScaleFinishedCallback(TransformScaler.ScalingType scalingOperation)
|
||||
{
|
||||
if(scalingOperation == TransformScaler.ScalingType.SCALING_DOWN)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
public void Show(DemoElement linkedDemoElement)
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
this.linkedDemoElement = linkedDemoElement;
|
||||
|
||||
transformScaler.ScaleUp();
|
||||
alphaTween.FadeIn();
|
||||
}
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
for(int i = 0; i < renderers.Length; i++)
|
||||
{
|
||||
Material mat = renderers[i].material;
|
||||
DemoUtils.SetMaterialTransparent(mat);
|
||||
}
|
||||
|
||||
transformScaler.ScaleDown();
|
||||
alphaTween.FadeOut();
|
||||
}
|
||||
|
||||
protected virtual void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[ContextMenu("Setup Renderers")]
|
||||
public void SetupRenderers()
|
||||
{
|
||||
|
||||
PrefabStage prefabStage = PrefabStageUtility.GetPrefabStage(gameObject);
|
||||
|
||||
if(prefabStage != null)
|
||||
{
|
||||
this.renderers = transform.GetComponentsInChildren<MeshRenderer>(true);
|
||||
EditorSceneManager.MarkSceneDirty(prefabStage.scene);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1cc14354005b97848bd03e676e4e2f75
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/EnvironmentController.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class EnvironmentSpotlightController : EnvironmentController
|
||||
{
|
||||
public Transform lightsParent;
|
||||
public float rotationSpeed;
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
Quaternion quat = lightsParent.rotation;
|
||||
lightsParent.rotation = quat * Quaternion.AngleAxis(rotationSpeed * Time.deltaTime, lightsParent.up);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3a1024b9f4c6f140b730bdc467420cc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/EnvironmentSpotlightController.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,65 @@
|
||||
using UnityEngine;
|
||||
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
|
||||
using UnityEngine.InputSystem;
|
||||
#endif
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class InputHandler : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private KeyCode targetKey = KeyCode.A;
|
||||
[SerializeField] private KeyCode altKey = KeyCode.None;
|
||||
|
||||
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
|
||||
private Key targetNewInputKey;
|
||||
private Key altNewInputKey;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
targetNewInputKey = ConvertKeyCodeToKey(targetKey);
|
||||
altNewInputKey = ConvertKeyCodeToKey(altKey);
|
||||
}
|
||||
#endif
|
||||
|
||||
public bool IsKeyPressed()
|
||||
{
|
||||
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
|
||||
if(altKey == KeyCode.None)
|
||||
{
|
||||
return Keyboard.current != null && Keyboard.current[targetNewInputKey].wasPressedThisFrame;
|
||||
}
|
||||
return Keyboard.current != null && (Keyboard.current[targetNewInputKey].wasPressedThisFrame ||
|
||||
Keyboard.current[altNewInputKey].wasPressedThisFrame);
|
||||
#else
|
||||
if(altKey == KeyCode.None)
|
||||
{
|
||||
return Input.GetKeyDown(targetKey);
|
||||
}
|
||||
return Input.GetKeyDown(targetKey) || Input.GetKeyDown(altKey);
|
||||
#endif
|
||||
}
|
||||
|
||||
public KeyCode GetTargetKey() => targetKey;
|
||||
public KeyCode GetAltKey() => altKey;
|
||||
|
||||
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
|
||||
private Key ConvertKeyCodeToKey(KeyCode keyCode)
|
||||
{
|
||||
switch(keyCode)
|
||||
{
|
||||
case KeyCode.None: return Key.None;
|
||||
case KeyCode.Return: return Key.Enter;
|
||||
case KeyCode.KeypadEnter: return Key.NumpadEnter;
|
||||
}
|
||||
|
||||
if(System.Enum.TryParse(keyCode.ToString(), true, out Key key))
|
||||
{
|
||||
return key;
|
||||
}
|
||||
|
||||
Debug.LogWarning($"Failed to convert KeyCode {keyCode} to Key. Using default Key.None.");
|
||||
return Key.None;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d1c3e379bdb46340b44363dd6b8800a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/InputHandler.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,67 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
public class MaterialPrewarmer : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Material[] materialsToPrewarm;
|
||||
[SerializeField] private GameObject[] objectsToPrewarm;
|
||||
[SerializeField] private Transform spawnPosT;
|
||||
[SerializeField] private GameObject overlayUI;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
StartRuntime();
|
||||
}
|
||||
|
||||
private IEnumerator PrewarmMaterials()
|
||||
{
|
||||
overlayUI.SetActive(true);
|
||||
|
||||
// Graphics.DrawMesh uses Matrix4x4 instead of spawn position
|
||||
Matrix4x4 matrix = Matrix4x4.TRS(spawnPosT.position, Quaternion.identity, Vector3.one * 0.01f);
|
||||
Mesh quadMesh = CreateQuadMesh();
|
||||
for(int i = 0; i < materialsToPrewarm.Length; i++) Graphics.DrawMesh(quadMesh, matrix, materialsToPrewarm[i], 0);
|
||||
DestroyImmediate(quadMesh);
|
||||
|
||||
// Only use spawn position for complex prefabs that still need instantiation
|
||||
for(int i = 0; i < objectsToPrewarm.Length; i++)
|
||||
{
|
||||
GameObject temp = Instantiate(objectsToPrewarm[i], spawnPosT.position, Quaternion.identity);
|
||||
temp.transform.localScale = Vector3.one * 0.01f;
|
||||
DestroyImmediate(temp);
|
||||
}
|
||||
|
||||
yield return null;
|
||||
overlayUI.SetActive(false);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
private void StartRuntime()
|
||||
{
|
||||
if(!Application.isPlaying) return;
|
||||
StartCoroutine(PrewarmMaterials());
|
||||
}
|
||||
|
||||
private Mesh CreateQuadMesh()
|
||||
{
|
||||
Mesh mesh = new Mesh
|
||||
{
|
||||
vertices = new Vector3[] {
|
||||
new Vector3(-0.5f, -0.5f, 0),
|
||||
new Vector3(0.5f, -0.5f, 0),
|
||||
new Vector3(0.5f, 0.5f, 0),
|
||||
new Vector3(-0.5f, 0.5f, 0)
|
||||
},
|
||||
triangles = new int[] { 0, 1, 2, 0, 2, 3 },
|
||||
uv = new Vector2[] {
|
||||
new Vector2(0, 0), new Vector2(1, 0),
|
||||
new Vector2(1, 1), new Vector2(0, 1)
|
||||
}
|
||||
};
|
||||
return mesh;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e4e063f035a58d54ab72254372789149
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/MaterialPrewarmer.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,103 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class OptionsDemo : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Color lockedColor = Color.red;
|
||||
|
||||
[Space, Header("Lock Camera")]
|
||||
[SerializeField] private AllIn1MouseTransformRotator allIn1MouseRotate;
|
||||
[SerializeField] private TextMeshProUGUI lockCamText;
|
||||
[SerializeField] private Image lockCamButtonImage;
|
||||
|
||||
[Space, Header("Lock Cursor")]
|
||||
[SerializeField] private bool lockCursor = true;
|
||||
[SerializeField] private TextMeshProUGUI lockCursorText;
|
||||
[SerializeField] private Image lockCursorButtonImage;
|
||||
|
||||
[Space, Header("Hide Ui")]
|
||||
[SerializeField] private CanvasGroup uiCanvasGroup;
|
||||
[SerializeField] private float uiCanvasSmoothing = 5f;
|
||||
|
||||
[Space, Header("Demo Info")]
|
||||
[SerializeField] private bool showingDemoInfo = false;
|
||||
[SerializeField] private Image showDemoInfoButtonImage;
|
||||
|
||||
private bool cursorIsLocked, camIsLocked, uiIsHidden;
|
||||
private float uiCanvasAlpha;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
cursorIsLocked = lockCursor;
|
||||
SetCursorLock();
|
||||
|
||||
camIsLocked = false;
|
||||
SetCamLock();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
uiCanvasGroup.alpha = Mathf.Lerp(uiCanvasGroup.alpha, uiIsHidden ? 0f : 1f, Time.unscaledDeltaTime * uiCanvasSmoothing);
|
||||
}
|
||||
|
||||
public void ToggleCursorButtonPress()
|
||||
{
|
||||
cursorIsLocked = !cursorIsLocked;
|
||||
SetCursorLock();
|
||||
}
|
||||
|
||||
public void ToggleShowInfo()
|
||||
{
|
||||
showingDemoInfo = !showingDemoInfo;
|
||||
showDemoInfoButtonImage.color = showingDemoInfo ? lockedColor : Color.clear;
|
||||
}
|
||||
|
||||
private void SetCursorLock()
|
||||
{
|
||||
if(cursorIsLocked)
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
Cursor.visible = false;
|
||||
lockCursorText.text = "Unlock Cursor";
|
||||
lockCursorButtonImage.color = lockedColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
Cursor.visible = true;
|
||||
lockCursorText.text = "Lock Cursor";
|
||||
lockCursorButtonImage.color = Color.clear;
|
||||
}
|
||||
}
|
||||
|
||||
public void CamLockButtonPress()
|
||||
{
|
||||
camIsLocked = !camIsLocked;
|
||||
SetCamLock();
|
||||
}
|
||||
|
||||
|
||||
private void SetCamLock()
|
||||
{
|
||||
allIn1MouseRotate.enabled = !camIsLocked;
|
||||
if(camIsLocked)
|
||||
{
|
||||
lockCamText.text = "Unlock Camera";
|
||||
lockCamButtonImage.color = lockedColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
lockCamText.text = "Lock Camera";
|
||||
lockCamButtonImage.color = Color.clear;
|
||||
}
|
||||
}
|
||||
|
||||
public void HideUiButtonPress()
|
||||
{
|
||||
uiIsHidden = !uiIsHidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6388e133eaa564a4ebfa90fcbd40c6f1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/OptionsDemo.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,116 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
#endif
|
||||
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
#if ALLIN13DSHADER_BIRP && UNITY_POST_PROCESSING_STACK_V2
|
||||
using UnityEngine.Rendering.PostProcessing;
|
||||
#elif ALLIN13DSHADER_URP
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
#endif
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
public class PostProcessConfigurator : MonoBehaviour
|
||||
{
|
||||
private Camera cam;
|
||||
|
||||
#if ALLIN13DSHADER_BIRP && UNITY_POST_PROCESSING_STACK_V2
|
||||
public PostProcessProfile postProcessProfileBIRP;
|
||||
#elif ALLIN13DSHADER_URP
|
||||
public VolumeProfile postProcessProfileURP;
|
||||
#endif
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
cam = GetComponent<Camera>();
|
||||
|
||||
if(cam == null)
|
||||
{
|
||||
Debug.LogError("Camera not found in this object!", gameObject);
|
||||
return;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
GameObjectUtility.RemoveMonoBehavioursWithMissingScript(gameObject);
|
||||
#if ALLIN13DSHADER_BIRP && UNITY_POST_PROCESSING_STACK_V2
|
||||
ConfigurePostprocessBIRP();
|
||||
#elif ALLIN13DSHADER_URP
|
||||
ConfigurePostprocessURP();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
#if ALLIN13DSHADER_BIRP && UNITY_POST_PROCESSING_STACK_V2
|
||||
private void ConfigurePostprocessBIRP()
|
||||
{
|
||||
PostProcessLayer postProcessLayer;
|
||||
if (!cam.gameObject.TryGetComponent<PostProcessLayer>(out postProcessLayer))
|
||||
{
|
||||
postProcessLayer = cam.gameObject.AddComponent<PostProcessLayer>();
|
||||
}
|
||||
|
||||
PostProcessVolume volume;
|
||||
if(!cam.gameObject.TryGetComponent<PostProcessVolume>(out volume))
|
||||
{
|
||||
volume = cam.gameObject.AddComponent<PostProcessVolume>();
|
||||
}
|
||||
|
||||
postProcessLayer.volumeTrigger = cam.transform;
|
||||
|
||||
if(postProcessProfileBIRP == null)
|
||||
{
|
||||
string rootFolder = SessionState.GetString("AllIn13DShader_RootPluginFolder", "Assets/AllIn13DShader");
|
||||
string profilePath = Path.Combine(rootFolder, "Demo/PostProcessingProfile/3DShaderPP.asset");
|
||||
postProcessProfileBIRP = AssetDatabase.LoadAssetAtPath<PostProcessProfile>(profilePath);
|
||||
}
|
||||
|
||||
postProcessLayer.volumeLayer = ~0;
|
||||
volume.profile = postProcessProfileBIRP;
|
||||
volume.isGlobal = true;
|
||||
|
||||
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ALLIN13DSHADER_URP
|
||||
private void ConfigurePostprocessURP()
|
||||
{
|
||||
Volume volume;
|
||||
if (!cam.gameObject.TryGetComponent<Volume>(out volume))
|
||||
{
|
||||
volume = cam.gameObject.AddComponent<Volume>();
|
||||
}
|
||||
|
||||
if(postProcessProfileURP == null)
|
||||
{
|
||||
string rootFolder = SessionState.GetString("AllIn13DShader_RootPluginFolder", "Assets/AllIn13DShader");
|
||||
string profilePath = Path.Combine(rootFolder, "Demo/PostProcessingProfile/3DShaderPP_URP.asset");
|
||||
postProcessProfileURP = AssetDatabase.LoadAssetAtPath<VolumeProfile>(profilePath);
|
||||
}
|
||||
|
||||
volume.sharedProfile = (VolumeProfile)postProcessProfileURP;
|
||||
EditorUtility.SetDirty(volume);
|
||||
|
||||
UniversalAdditionalCameraData cameraData;
|
||||
if(!cam.gameObject.TryGetComponent<UniversalAdditionalCameraData>(out cameraData))
|
||||
{
|
||||
cameraData = cam.gameObject.AddComponent<UniversalAdditionalCameraData>();
|
||||
}
|
||||
cameraData.renderPostProcessing = true;
|
||||
|
||||
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb8522dc440232841aa60648309c8fd7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/PostProcessConfigurator.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,48 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class SkyController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Material[] skyMaterials;
|
||||
[SerializeField] private int firstSkyIndex = 0;
|
||||
[SerializeField] private InputHandler skyChangeInputHandler;
|
||||
|
||||
private int currentSkyIndex;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
currentSkyIndex = firstSkyIndex;
|
||||
|
||||
RenderSettings.defaultReflectionMode = UnityEngine.Rendering.DefaultReflectionMode.Skybox;
|
||||
RenderSettings.skybox = skyMaterials[currentSkyIndex];
|
||||
}
|
||||
|
||||
public void NextSky()
|
||||
{
|
||||
currentSkyIndex++;
|
||||
if(currentSkyIndex >= skyMaterials.Length)
|
||||
{
|
||||
currentSkyIndex = 0;
|
||||
}
|
||||
|
||||
// Directly set the skybox to the new material
|
||||
RenderSettings.skybox = skyMaterials[currentSkyIndex];
|
||||
DynamicGI.UpdateEnvironment();
|
||||
}
|
||||
|
||||
public void DemoChanged(DemoElementData demoElementData)
|
||||
{
|
||||
if(demoElementData.skyboxEnabled)
|
||||
{
|
||||
RenderSettings.skybox = skyMaterials[currentSkyIndex];
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderSettings.skybox = null;
|
||||
}
|
||||
|
||||
DynamicGI.UpdateEnvironment();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc976fd2f3a5382418cd80faae769e86
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/SkyController.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 34f8cb34dae749448a396c7f8f84dae7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,93 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class AlphaTween : MonoBehaviour
|
||||
{
|
||||
private static int MATPROP_ID_GENERAL_ALPHA = Shader.PropertyToID("_GeneralAlpha");
|
||||
|
||||
public enum State
|
||||
{
|
||||
NONE = 0,
|
||||
FADE_IN = 1,
|
||||
FADE_OUT = 2,
|
||||
}
|
||||
|
||||
private MeshRenderer[] meshRenderers;
|
||||
|
||||
private bool IsTweening
|
||||
{
|
||||
get
|
||||
{
|
||||
bool res = state != State.NONE;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
private AnimationCurve alphaCurve;
|
||||
private float duration;
|
||||
private float timer;
|
||||
|
||||
private State state;
|
||||
|
||||
private float alphaSrc;
|
||||
private float alphaDst;
|
||||
|
||||
public void Init(DemoSceneConfiguration demoSceneConfig, MeshRenderer[] meshRenderers)
|
||||
{
|
||||
alphaCurve = demoSceneConfig.alphaCurve;
|
||||
duration = demoSceneConfig.alphaDuration;
|
||||
timer = 0f;
|
||||
|
||||
this.meshRenderers = meshRenderers;
|
||||
|
||||
state = State.NONE;
|
||||
}
|
||||
|
||||
public void FadeIn()
|
||||
{
|
||||
timer = 0f;
|
||||
state = State.FADE_IN;
|
||||
|
||||
alphaSrc = 0f;
|
||||
alphaDst = 1f;
|
||||
}
|
||||
|
||||
public void FadeOut()
|
||||
{
|
||||
timer = 0f;
|
||||
state = State.FADE_OUT;
|
||||
|
||||
alphaSrc = 1f;
|
||||
alphaDst = 0f;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (IsTweening)
|
||||
{
|
||||
UpdateTweening();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateTweening()
|
||||
{
|
||||
timer += Time.deltaTime;
|
||||
float t = timer / duration;
|
||||
float curveT = alphaCurve.Evaluate(t);
|
||||
|
||||
float alpha = Mathf.Lerp(alphaSrc, alphaDst, curveT);
|
||||
|
||||
for(int i = 0; i < meshRenderers.Length; i++)
|
||||
{
|
||||
meshRenderers[i].sharedMaterial.SetFloat(MATPROP_ID_GENERAL_ALPHA, alpha);
|
||||
}
|
||||
|
||||
if(t >= 1f)
|
||||
{
|
||||
state = State.NONE;
|
||||
timer = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9808fa4c0fb72f24992e04c8617c3cf6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/Tweens/AlphaTween.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class PositionTween : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55365ba5f8752694da63758c0d7d993f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/Tweens/PositionTween.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,35 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class PropertyTween
|
||||
{
|
||||
protected int propID;
|
||||
protected Material mat;
|
||||
protected float currentValue;
|
||||
|
||||
[SerializeField] protected string propertyName;
|
||||
|
||||
public virtual void Init(Material mat)
|
||||
{
|
||||
this.mat = mat;
|
||||
propID = Shader.PropertyToID(propertyName);
|
||||
}
|
||||
|
||||
public virtual void Update(float deltaTime)
|
||||
{
|
||||
Tween(deltaTime);
|
||||
UpdateMaterial();
|
||||
}
|
||||
|
||||
protected virtual void Tween(float deltaTime)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void UpdateMaterial()
|
||||
{
|
||||
mat.SetFloat(propID, currentValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c901b6122eaa4db44878b49f5d994634
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/Tweens/PropertyTween.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,41 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
[System.Serializable]
|
||||
public class PropertyTweenCollection
|
||||
{
|
||||
public Material mat;
|
||||
|
||||
public PropertyTweenFader[] faderTweens;
|
||||
public PropertyTweenSinWave[] sinWaveTweens;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
if(mat == null) return;
|
||||
|
||||
for (int i = 0; i < faderTweens.Length; i++)
|
||||
{
|
||||
faderTweens[i].Init(mat);
|
||||
}
|
||||
|
||||
for (int i = 0; i < sinWaveTweens.Length; i++)
|
||||
{
|
||||
sinWaveTweens[i].Init(mat);
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(float deltaTime)
|
||||
{
|
||||
for(int i = 0; i < faderTweens.Length; i++)
|
||||
{
|
||||
faderTweens[i].Update(deltaTime);
|
||||
}
|
||||
|
||||
for (int i = 0; i < sinWaveTweens.Length; i++)
|
||||
{
|
||||
sinWaveTweens[i].Update(deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eab8b01b4c9522440b3c4c308e49ae16
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/Tweens/PropertyTweenCollection.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,102 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
[System.Serializable]
|
||||
public class PropertyTweenFader : PropertyTween
|
||||
{
|
||||
public enum State
|
||||
{
|
||||
WAITING_FOR_FADE_IN = 0,
|
||||
FADING_IN = 1,
|
||||
WAITING_FOR_FADE_OUT = 2,
|
||||
FADING_OUT = 3,
|
||||
}
|
||||
|
||||
private float timer;
|
||||
private State state;
|
||||
|
||||
[Header("Config")]
|
||||
public float waitingForFadeInTime;
|
||||
public float fadeInDuration;
|
||||
public float waitingForFadeOutTime;
|
||||
public float fadeOutDuration;
|
||||
|
||||
public override void Init(Material mat)
|
||||
{
|
||||
base.Init(mat);
|
||||
|
||||
state = State.WAITING_FOR_FADE_IN;
|
||||
timer = 0f;
|
||||
}
|
||||
|
||||
protected override void Tween(float deltaTime)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case State.WAITING_FOR_FADE_IN:
|
||||
UpdateWaitingForFadeIn();
|
||||
break;
|
||||
case State.FADING_IN:
|
||||
UpdateFadingIn();
|
||||
break;
|
||||
case State.WAITING_FOR_FADE_OUT:
|
||||
UpdateWaitingForFadeOut();
|
||||
break;
|
||||
case State.FADING_OUT:
|
||||
UpdateFadingOut();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateWaitingForFadeIn()
|
||||
{
|
||||
timer += Time.deltaTime;
|
||||
|
||||
if (timer >= waitingForFadeInTime)
|
||||
{
|
||||
state = State.FADING_IN;
|
||||
timer = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateFadingIn()
|
||||
{
|
||||
timer += Time.deltaTime;
|
||||
|
||||
float t = timer / fadeInDuration;
|
||||
currentValue = t;
|
||||
|
||||
if (timer >= fadeInDuration)
|
||||
{
|
||||
state = State.WAITING_FOR_FADE_OUT;
|
||||
timer = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateWaitingForFadeOut()
|
||||
{
|
||||
timer += Time.deltaTime;
|
||||
|
||||
if (timer >= waitingForFadeOutTime)
|
||||
{
|
||||
state = State.FADING_OUT;
|
||||
timer = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateFadingOut()
|
||||
{
|
||||
timer += Time.deltaTime;
|
||||
|
||||
float t = timer / fadeOutDuration;
|
||||
currentValue = 1 - t;
|
||||
|
||||
if (timer >= fadeOutDuration)
|
||||
{
|
||||
state = State.WAITING_FOR_FADE_IN;
|
||||
timer = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 977c8373a22e2be4b8f17402a41cf8e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/Tweens/PropertyTweenFader.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,19 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
[System.Serializable]
|
||||
public class PropertyTweenSinWave : PropertyTween
|
||||
{
|
||||
[Header("Configuration")]
|
||||
public float minValue;
|
||||
public float maxValue;
|
||||
public float speed;
|
||||
|
||||
protected override void Tween(float deltaTime)
|
||||
{
|
||||
float sin01 = (Mathf.Sin(Time.time * speed) + 1f) * 0.5f;
|
||||
currentValue = Mathf.Lerp(minValue, maxValue, sin01);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 109d7bd9dbc4170448a098f3590a932c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/Tweens/PropertyTweenSinWave.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class SinVerticalPositionTween : MonoBehaviour
|
||||
{
|
||||
private float timer;
|
||||
|
||||
public float speed = 5;
|
||||
public float minY = -1;
|
||||
public float maxY = 1;
|
||||
|
||||
public Transform target;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
timer = 0f;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
timer = 0f;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
timer += Time.deltaTime;
|
||||
|
||||
float sin01 = (Mathf.Sin(timer * speed) + 1f) * 0.5f;
|
||||
Vector3 localPos = target.localPosition;
|
||||
localPos.y = Mathf.Lerp(minY, maxY, sin01);
|
||||
|
||||
target.localPosition = localPos;
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
if(target == null) target = transform;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bfd62d9a148e2cf47ad5cddb1f76c278
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/Tweens/SinVerticalPositionTween.cs
|
||||
uploadId: 865720
|
||||
@@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AllIn13DShader
|
||||
{
|
||||
public class TransformScaler : MonoBehaviour
|
||||
{
|
||||
public enum ScalingType
|
||||
{
|
||||
NONE,
|
||||
SCALING_UP,
|
||||
SCALING_DOWN,
|
||||
}
|
||||
|
||||
private float scaleDuration;
|
||||
private AnimationCurve scaleCurve;
|
||||
|
||||
private Vector3 localScaleSrc;
|
||||
private Vector3 localScaleDst;
|
||||
|
||||
private float timer;
|
||||
private ScalingType scalingType;
|
||||
|
||||
private Action<ScalingType> scaleFinishedCallback;
|
||||
|
||||
public void Init(DemoSceneConfiguration demoSceneConfig)
|
||||
{
|
||||
Init(demoSceneConfig, null);
|
||||
}
|
||||
|
||||
public void Init(DemoSceneConfiguration demoSceneConfig, Action<ScalingType> scaleFinishedCallback)
|
||||
{
|
||||
scaleDuration = demoSceneConfig.scaleDuration;
|
||||
scaleCurve = demoSceneConfig.scalingCurve;
|
||||
|
||||
this.scaleFinishedCallback = scaleFinishedCallback;
|
||||
}
|
||||
|
||||
public void ScaleUp()
|
||||
{
|
||||
transform.localScale = Vector3.zero;
|
||||
timer = 0f;
|
||||
scalingType = ScalingType.SCALING_UP;
|
||||
|
||||
localScaleSrc = Vector3.zero;
|
||||
localScaleDst = Vector3.one;
|
||||
}
|
||||
|
||||
public void ScaleDown()
|
||||
{
|
||||
transform.localScale = Vector3.one;
|
||||
timer = 0f;
|
||||
scalingType = ScalingType.SCALING_DOWN;
|
||||
|
||||
localScaleSrc = Vector3.one;
|
||||
localScaleDst = Vector3.zero;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (IsScaling())
|
||||
{
|
||||
UpdateScaling();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateScaling()
|
||||
{
|
||||
timer += Time.deltaTime;
|
||||
float t = timer / scaleDuration;
|
||||
float curveT = t;
|
||||
|
||||
if (scalingType == ScalingType.SCALING_UP)
|
||||
{
|
||||
curveT = scaleCurve.Evaluate(t);
|
||||
}
|
||||
else if (scalingType == ScalingType.SCALING_DOWN)
|
||||
{
|
||||
curveT = 1 - scaleCurve.Evaluate(1 - t);
|
||||
}
|
||||
|
||||
float scale = Mathf.LerpUnclamped(localScaleSrc.x, localScaleDst.x, curveT);
|
||||
scale = Mathf.Max(0f, scale);
|
||||
|
||||
transform.localScale = Vector3.one * scale;
|
||||
|
||||
if (t >= 1f)
|
||||
{
|
||||
timer = 0f;
|
||||
|
||||
if (scalingType == ScalingType.SCALING_DOWN)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
if(scaleFinishedCallback != null)
|
||||
{
|
||||
scaleFinishedCallback(scalingType);
|
||||
}
|
||||
|
||||
scalingType = ScalingType.NONE;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsScaling()
|
||||
{
|
||||
return scalingType != ScalingType.NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 71c6c2d242f3c2243bf1fcaa88c90071
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 316173
|
||||
packageName: All In 1 3D-Shader
|
||||
packageVersion: 2.72
|
||||
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/Tweens/TransformScaler.cs
|
||||
uploadId: 865720
|
||||
Reference in New Issue
Block a user