导入资源

This commit is contained in:
2025-05-19 17:31:53 +08:00
parent 62886b46e9
commit 84d13e8981
816 changed files with 132844 additions and 60134 deletions

View File

@@ -0,0 +1,104 @@
// Crest Water System
// Copyright © 2024 Wave Harmonic. All rights reserved.
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace WaveHarmonic.Crest.Examples
{
#if !CREST_DEBUG
[AddComponentMenu("")]
#endif
sealed class ExamplesController : MonoBehaviour
{
[@DecoratedField, SerializeField]
KeyCode _Previous = KeyCode.Comma;
[@DecoratedField, SerializeField]
KeyCode _Next = KeyCode.Period;
[SerializeField]
List<GameObject> _Prefabs = new();
int _Index = 0;
public void Previous() => Cycle(true);
public void Next() => Cycle(false);
void OnEnable()
{
if (_Prefabs.Count == 0)
{
enabled = false;
return;
}
var prefab = Instantiate(_Prefabs[_Index]);
prefab.transform.SetParent(transform, worldPositionStays: true);
}
void OnDisable()
{
var child = transform.GetChild(0);
if (child == null)
{
return;
}
Destroy(child.gameObject);
}
void Update()
{
if (Input.GetKeyUp(_Previous))
{
Previous();
}
else if (Input.GetKeyUp(_Next))
{
Next();
}
}
internal void Cycle(bool isReverse = false)
{
_Index += isReverse ? -1 : 1;
// Wrap index.
if (_Index < 0) _Index = _Prefabs.Count - 1;
if (_Index == _Prefabs.Count) _Index = 0;
var go = transform.GetChild(0).gameObject;
go.SetActive(false);
Helpers.Destroy(go);
var prefab = Instantiate(_Prefabs[_Index]);
prefab.transform.SetParent(transform, worldPositionStays: true);
}
}
#if UNITY_EDITOR
[CustomEditor(typeof(ExamplesController))]
sealed class ExamplesControllerEditor : Editor.Inspector
{
protected override void RenderInspectorGUI()
{
base.RenderInspectorGUI();
var target = this.target as ExamplesController;
if (GUILayout.Button("Previous"))
{
target.Previous();
}
if (GUILayout.Button("Next"))
{
target.Next();
}
}
}
#endif
}

View File

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

View File

@@ -0,0 +1,33 @@
{
"name": "WaveHarmonic.Crest.Samples.Examples",
"rootNamespace": "",
"references": [
"GUID:75469ad4d38634e559750d17036d5f7c",
"GUID:7c347618730f5467f86a58f333ce21df",
"GUID:056ff2a5b2f124d468c6655552acdca5",
"GUID:1ab2a6c2a51cd4b43867788dbaee1a55"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": false,
"defineConstraints": [
"UNITY_2022_3_OR_NEWER",
"d_Crest"
],
"versionDefines": [
{
"name": "com.unity.inputsystem",
"expression": "",
"define": "d_Unity_InputSystem"
},
{
"name": "com.waveharmonic.crest",
"expression": "",
"define": "d_Crest"
}
],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 318deac13168c44f2a24fae14a38474c
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: