架构大更

This commit is contained in:
SoulliesOfficial
2026-03-20 11:56:50 -04:00
parent e60ef64d01
commit d09b58fd80
3663 changed files with 15232012 additions and 105579 deletions

View File

@@ -1,4 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -8,25 +7,22 @@ namespace SpriteShadersUltimate.Demo
{
public static Demo_Shaders instance;
public static float zoomFactor;
private Vector3 currentPosition;
GameObject environmentGO;
List<SpriteRenderer> environmentSprites;
Vector3 currentPosition;
private GameObject environmentGO;
private List<SpriteRenderer> environmentSprites;
float lastZoomFactor;
private float lastZoomFactor;
void Awake()
private void Awake()
{
//Reference:
instance = this;
//Environment:
Transform environment = GameObject.Find("Environment").transform;
var environment = GameObject.Find("Environment").transform;
environmentSprites = new List<SpriteRenderer>();
foreach(SpriteRenderer sr in environment.GetComponentsInChildren<SpriteRenderer>())
{
environmentSprites.Add(sr);
}
foreach (var sr in environment.GetComponentsInChildren<SpriteRenderer>()) environmentSprites.Add(sr);
environmentGO = environment.gameObject;
//Initialize:
@@ -36,7 +32,7 @@ namespace SpriteShadersUltimate.Demo
lastZoomFactor = -1000;
}
void Update()
private void Update()
{
//Zoom Factor:
if (Demo_Display.selected != null)
@@ -51,33 +47,27 @@ namespace SpriteShadersUltimate.Demo
}
//Scale:
float scale = 1f + 6.2f * zoomFactor;
var scale = 1f + 6.2f * zoomFactor;
transform.localScale = new Vector3(scale, scale, 1);
if (zoomFactor != lastZoomFactor)
{
//Environment:
float alpha = Mathf.Clamp01((zoomFactor - 0.75f) / 0.25f);
foreach (SpriteRenderer sprite in environmentSprites)
var alpha = Mathf.Clamp01((zoomFactor - 0.75f) / 0.25f);
foreach (var sprite in environmentSprites)
{
Color color = sprite.color;
var color = sprite.color;
color.a = alpha;
sprite.color = color;
}
if(alpha > 0f)
if (alpha > 0f)
{
if(!environmentGO.activeSelf)
{
environmentGO.SetActive(true);
}
if (!environmentGO.activeSelf) environmentGO.SetActive(true);
}
else
{
if (environmentGO.activeSelf)
{
environmentGO.SetActive(false);
}
if (environmentGO.activeSelf) environmentGO.SetActive(false);
}
//Other:
@@ -85,18 +75,18 @@ namespace SpriteShadersUltimate.Demo
}
//Position:
if(Demo_Display.selected != null)
if (Demo_Display.selected != null)
{
currentPosition = Vector3.Lerp(currentPosition, -Demo_Display.selected.transform.localPosition, Time.unscaledDeltaTime * 10f);
currentPosition = Vector3.Lerp(currentPosition, -Demo_Display.selected.transform.localPosition,
Time.unscaledDeltaTime * 10f);
}
else
{
float movement = 0f;
if(AllowMovement())
var movement = 0f;
if (AllowMovement())
{
movement = 2f * (Screen.width * 0.5f - Input.mousePosition.x) / (float)Screen.width;
if(Mathf.Abs(movement) < 0.6f)
movement = 2f * (Screen.width * 0.5f - Input.mousePosition.x) / Screen.width;
if (Mathf.Abs(movement) < 0.6f)
{
movement = 0;
}
@@ -112,18 +102,16 @@ namespace SpriteShadersUltimate.Demo
}
}
currentPosition = Vector3.Lerp(currentPosition, new Vector3(currentPosition.x + movement, 0, 0), Time.unscaledDeltaTime * 14f / scale);
currentPosition = Vector3.Lerp(currentPosition, new Vector3(currentPosition.x + movement, 0, 0),
Time.unscaledDeltaTime * 14f / scale);
}
transform.position = currentPosition * scale;
//Controls:
if(Demo_Display.selected != null)
{
if (Demo_Display.selected != null)
if (Input.GetKeyDown(KeyCode.Escape))
{
Demo_Display.selected.Deselect();
}
}
}
public bool AllowMovement()
@@ -136,4 +124,4 @@ namespace SpriteShadersUltimate.Demo
return zoomFactor > 0.9f;
}
}
}
}