initial commit
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class AnimationStarter : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private Animation _animation;
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
if (!_animation && TryGetComponent<Animation>(out var animation))
|
||||
{
|
||||
_animation = animation;
|
||||
}
|
||||
}
|
||||
|
||||
public void Play()
|
||||
{
|
||||
_animation.Play();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c8f8855156991894983a624be3c44582
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae7a7820fc46a784b957efb51b8d7a83
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
using JetBrains.Annotations;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace EasySharp.ReSharperCustomSourceTemplates
|
||||
{
|
||||
public static class ReSharperHelper
|
||||
{
|
||||
[SourceTemplate]
|
||||
public static void log(this object source)
|
||||
{
|
||||
//$Debug.Log($"$source$: {source}");$END$
|
||||
}
|
||||
|
||||
[SourceTemplate]
|
||||
public static void elog(this object source)
|
||||
{
|
||||
//$Debug.LogError($"$source$: {source}");$END$
|
||||
}
|
||||
|
||||
[SourceTemplate]
|
||||
public static void wlog(this object source)
|
||||
{
|
||||
//$Debug.LogWarning($"$source$: {source}");$END$
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c725f486e96d413bae1be99be3daf6ba
|
||||
timeCreated: 1735946217
|
||||
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
public class SceneSwitcherEditorWindow : EditorWindow
|
||||
{
|
||||
[MenuItem("Examples/My Editor Window")]
|
||||
public static void ShowExample()
|
||||
{
|
||||
var editorWindow = GetWindow<SceneSwitcherEditorWindow>();
|
||||
editorWindow.titleContent = new GUIContent("SceneSwitcherEditor");
|
||||
}
|
||||
|
||||
public void CreateGUI()
|
||||
{
|
||||
// Each editor window contains a root VisualElement object
|
||||
VisualElement root = rootVisualElement;
|
||||
root.Clear();
|
||||
|
||||
// Create a ScrollView
|
||||
ScrollView scrollView = new ScrollView();
|
||||
root.Add(scrollView);
|
||||
|
||||
// reload button
|
||||
Button reloadButton = new Button();
|
||||
reloadButton.text = "Reload";
|
||||
reloadButton.clicked += () => CreateGUI();
|
||||
scrollView.Add(reloadButton);
|
||||
|
||||
// space
|
||||
scrollView.Add(new Label(""));
|
||||
|
||||
// Get the SceneSwitcher component
|
||||
if (SceneSwitcher.Instance == null)
|
||||
{
|
||||
Debug.LogError("SceneSwitcher component not found in the scene.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Get the list of scenes
|
||||
List<(string name, int index)> scenes = SceneSwitcher.Instance.GetScenes();
|
||||
|
||||
// Create a button for each scene
|
||||
foreach (var scene in scenes)
|
||||
{
|
||||
Button button = new Button();
|
||||
button.text = scene.name;
|
||||
int sceneIndex = scene.index; // Capture the index in a local variable
|
||||
button.clicked += () => SceneSwitcher.Instance.SwitchScene(sceneIndex);
|
||||
scrollView.Add(button);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95394a5a901d4954a92e7ced9382dead
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
[RequireComponent(typeof(OutlineFx.OutlineFx))]
|
||||
public class MyButton : MonoBehaviour, IPointerClickHandler, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
[SerializeField]
|
||||
private UnityEvent _onClick;
|
||||
|
||||
|
||||
// references
|
||||
private OutlineFx.OutlineFx _outlineFx;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_outlineFx = GetComponent<OutlineFx.OutlineFx>();
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
_onClick.Invoke();
|
||||
}
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
_outlineFx.enabled = true;
|
||||
}
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
_outlineFx.enabled = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e545d598a5d16f4e8b9a70fedc8b7a3
|
||||
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SceneSwitcher : MonoBehaviour
|
||||
{
|
||||
// make singleton
|
||||
public static SceneSwitcher Instance { get; private set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
SetInstance();
|
||||
}
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
SetInstance();
|
||||
}
|
||||
|
||||
private void SetInstance()
|
||||
{
|
||||
|
||||
if (Instance == null)
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("SceneSwitcher Instance already exists.");
|
||||
}
|
||||
}
|
||||
|
||||
public void SwitchScene(int sceneIndex)
|
||||
{
|
||||
for (var i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
transform.GetChild(i).gameObject.SetActive(i == sceneIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public List<(string name, int index)> GetScenes()
|
||||
{
|
||||
var scenes = new List<(string name, int index)>();
|
||||
for (var i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
var child = transform.GetChild(i);
|
||||
scenes.Add((child.name, i));
|
||||
}
|
||||
return scenes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 866969868d65b5c47b6cbdfab4b4cbe3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class SwitchToScene : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
[SerializeField]
|
||||
private SwitchableScene _scene;
|
||||
|
||||
[SerializeField]
|
||||
private bool _triggerOnClick;
|
||||
|
||||
public void Switch()
|
||||
{
|
||||
SceneSwitcher.Instance.SwitchScene(_scene.index);
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
Debug.Log("Click");
|
||||
|
||||
if (_triggerOnClick)
|
||||
Switch();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e085a6bafb27f9f4abf848fdc2f073b3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
[Serializable]
|
||||
public class SwitchableScene
|
||||
{
|
||||
public int index;
|
||||
}
|
||||
|
||||
|
||||
#if UNITY_EDITOR
|
||||
// custom property drawer
|
||||
|
||||
[CustomPropertyDrawer(typeof(SwitchableScene))]
|
||||
public class SwitchableSceneDrawer : PropertyDrawer
|
||||
{
|
||||
|
||||
public override VisualElement CreatePropertyGUI(SerializedProperty property)
|
||||
{
|
||||
// Get the SceneSwitcher component
|
||||
if (SceneSwitcher.Instance == null)
|
||||
{
|
||||
return new Label("SceneSwitcher component not found in the scene.");
|
||||
}
|
||||
|
||||
// create dropdown based on the SceneSwitcher options
|
||||
var root = new VisualElement();
|
||||
|
||||
// Get the list of scenes
|
||||
List<(string name, int index)> scenes = SceneSwitcher.Instance.GetScenes();
|
||||
|
||||
// create dropdown
|
||||
var indexProperty = property.FindPropertyRelative("index");
|
||||
var dropdown = new PopupField<string>("Scene", scenes.ConvertAll(t => t.name), scenes[indexProperty.intValue].name);
|
||||
dropdown.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
indexProperty.intValue = scenes.FindIndex(t => t.name == evt.newValue);
|
||||
indexProperty.serializedObject.ApplyModifiedProperties();
|
||||
});
|
||||
|
||||
root.Add(dropdown);
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d60d724342bfc1846843fdb2775638ba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class Timeline : MonoBehaviour
|
||||
{
|
||||
[Serializable]
|
||||
public class TimelineEvent
|
||||
{
|
||||
public float waitSeconds;
|
||||
public UnityEvent unityEvent;
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private List<TimelineEvent> _events;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
StartCoroutine(PlayTimeline());
|
||||
}
|
||||
|
||||
private IEnumerator PlayTimeline()
|
||||
{
|
||||
foreach (var timelineEvent in _events)
|
||||
{
|
||||
yield return new WaitForSeconds(timelineEvent.waitSeconds);
|
||||
timelineEvent.unityEvent.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c66546d6c537064f9b7de80bc4ef5cb
|
||||
Reference in New Issue
Block a user