diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..da291f6 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [0.1.0] - 2020-07-19 + +### Added +- View +- RepeatView \ No newline at end of file diff --git a/CHANGELOG.md.meta b/CHANGELOG.md.meta new file mode 100644 index 0000000..4ada5ac --- /dev/null +++ b/CHANGELOG.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 6c14f45d1563342839e97c45cf81183b +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..c23acad --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,8 @@ +Copyright 2020 Neil Sarkar + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/LICENSE.md.meta b/LICENSE.md.meta new file mode 100644 index 0000000..6dd593f --- /dev/null +++ b/LICENSE.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 213916ac8f41d4773bb61394ce382190 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/README.md b/README.md new file mode 100644 index 0000000..23ca07b --- /dev/null +++ b/README.md @@ -0,0 +1,65 @@ +# Violet UI + +State-based rendering with live updates in the Unity Editor + +## State + +```csharp +using Dispatch; + +[System.Serializable] +public class UIState : State { + public int nice; +} +``` + +## Actions + +```csharp +using System; + +public static class UIActions { + public static Action IncrementNice => state => { + state.nice++; + } + + public static Action SetNice(int nice) => state => { + state.nice = nice; + } +} +``` + +## View +```csharp +using VioletUI; + +public class MyBaseView : View { + // pull state from gameObject, singleton, disk etc + UIState state = new UIState(); + public override UIState State => state + + // provide a copy of the state to use for history + UIState lastState = new UIState(); + public override UIState LastState => lastState; +} + +public class AddView : MyBaseView { + // Render is called every time the state changes + public override void Render(UIState state, UIState lastState) { + // only render when the part of the state u care about changes + if (state.nice == lastState.nice) { return; } + + print($"State of nice changed to {state.nice}"); + } +} + +public class AddButtonView : MyBaseView { + public void Increment() { + dispatcher.Run(UIActions.Increment); + } + + public void Set() { + dispatcher.Run(UIActions.Set(0)); + } +} +``` \ No newline at end of file diff --git a/README.md.meta b/README.md.meta new file mode 100644 index 0000000..d6ee934 --- /dev/null +++ b/README.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 84db7ef0289db47879d08c432f99fd22 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: