Skip to content

Commit

Permalink
Updated the html version of documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
svermeulen committed Nov 6, 2016
1 parent 90fd01b commit 0b4a15b
Show file tree
Hide file tree
Showing 7 changed files with 614 additions and 66 deletions.
10 changes: 10 additions & 0 deletions Build/CreateHtmlDocs.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@echo off

grip %~dp0\..\README.md --export .\UnityProject\Assets\Zenject\Documentation\README.html
grip %~dp0\..\Documentation\AutoMocking.md --export .\UnityProject\Assets\Zenject\Documentation\AutoMocking.html
grip %~dp0\..\Documentation\CheatSheet.md --export .\UnityProject\Assets\Zenject\Documentation\CheatSheet.html
grip %~dp0\..\Documentation\CommandsAndSignals.md --export .\UnityProject\Assets\Zenject\Documentation\CommandsAndSignals.html
grip %~dp0\..\Documentation\Factories.md --export .\UnityProject\Assets\Zenject\Documentation\Factories.html
grip %~dp0\..\Documentation\ReleaseNotes.md --export .\UnityProject\Assets\Zenject\Documentation\ReleaseNotes.html
grip %~dp0\..\Documentation\SubContainers.md --export .\UnityProject\Assets\Zenject\Documentation\SubContainers.html
grip %~dp0\..\Documentation\WritingAutomatedTests.md --export .\UnityProject\Assets\Zenject\Documentation\WritingAutomatedTests.html
8 changes: 8 additions & 0 deletions Documentation/ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@

## <a id="release-notes"></a>Release Notes

4.7 (November 6, 2016)
- Removed the concept of triggers in favour of just directly acting on the Signal to both subscribe and fire, since using Trigger was too much overhead for not enough gain
- Fixed issue for Windows Store platform where zenject was not properly stripping out the WSA generated constructors
- Changed to automatically choose the public constructor if faced with a choice between public and private
- Fix to IL2CPP builds to work again
- Added support for using the WithArguments bind method combined with FromFactory
- Improved validation of multi-scene setups using Contract Names to output better error messages

4.6 (October 23, 2016)
- Changed Validation to run at edit time rather than requiring that we enter play mode. This is significantly faster. Also added a hotkey to "validate then run" since it's fast enough to use as a pre-run check
- Added InstantiateComponentOnNewGameObject method
Expand Down
492 changes: 492 additions & 0 deletions UnityProject/Assets/Zenject/Documentation/CheatSheet.html

Large diffs are not rendered by default.

113 changes: 66 additions & 47 deletions UnityProject/Assets/Zenject/Documentation/CommandsAndSignals.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,95 +70,114 @@ <h2>

<p>Signals are defined like this:</p>

<div class="highlight highlight-source-cs"><pre><span class="pl-k">public</span> <span class="pl-k">class</span> <span class="pl-en">GameLoadedSignal</span> : <span class="pl-k">Signal</span>
<div class="highlight highlight-source-cs"><pre><span class="pl-k">public</span> <span class="pl-k">class</span> <span class="pl-en">PressedButtonSignal</span> : <span class="pl-k">Signal</span>&lt;<span class="pl-k">PressedButtonSignal</span>&gt;
{
<span class="pl-k">public</span> <span class="pl-k">class</span> <span class="pl-en">Trigger</span> : <span class="pl-k">TriggerBase</span> { }
}
}</pre></div>

<p>Then in an Installer:</p>

<span class="pl-k">public</span> <span class="pl-k">class</span> <span class="pl-en">GameLoadedSignalWithParameter</span> : <span class="pl-k">Signal</span>&lt;<span class="pl-k">string</span>&gt;
<div class="highlight highlight-source-cs"><pre><span class="pl-k">public</span> <span class="pl-k">override</span> <span class="pl-k">void</span> InstallBindings()
{
<span class="pl-k">public</span> <span class="pl-k">class</span> <span class="pl-en">Trigger</span> : <span class="pl-k">TriggerBase</span> { }
Container.BindSignal&lt;PressedButtonSignal&gt;();
}</pre></div>

<p>The trigger class is used to invoke the signal event. We make the trigger a separate class so that we can control which classes can trigger the signal and which classes can listen on the signal separately.</p>

<p>Signals are declared in an installer like this:</p>
<p>Then in the firing class:</p>

<div class="highlight highlight-source-cs"><pre>
<span class="pl-k">public</span> <span class="pl-k">override</span> <span class="pl-k">void</span> InstallBindings()
<div class="highlight highlight-source-cs"><pre><span class="pl-k">public</span> <span class="pl-k">class</span> <span class="pl-en">Bar</span>
{
...
Container.BindSignal&lt;GameLoadedSignal&gt;();
...
Container.BindSignal&lt;GameLoadedSignalWithParameter&gt;().WhenInjectedInto&lt;Foo&gt;();
}
</pre></div>
<span class="pl-k">readonly</span> PressedButtonSignal _signal;

<p>These statements will do the following:</p>
<span class="pl-k">public</span> <span class="pl-en">Bar</span>(<span class="pl-k">PressedButtonSignal</span> <span class="pl-smi">signal</span>)
{
_signal = signal;
}

<ul>
<li>Bind the class <code>GameLoadedSignal</code> using <code>AsSingle</code> without a condition. This means that any class can declare <code>GameLoadedSignal</code> as a dependency.</li>
<li>Bind the class <code>GameLoadedSignalWithParameter</code> using <code>AsSingle</code> as well, except it will limit its usage strictly to class <code>Foo</code>.</li>
</ul>
<span class="pl-k">public</span> <span class="pl-k">void</span> <span class="pl-en">DoSomething</span>()
{
_signal.Fire();
}
}</pre></div>

<p>Once you have added the signal to your container by binding it within an installer, you can use it like this:</p>
<p>And in the listening class:</p>

<div class="highlight highlight-source-cs"><pre>
<span class="pl-k">public</span> <span class="pl-k">class</span> <span class="pl-en">Foo</span> : <span class="pl-k">IInitializable</span>, <span class="pl-k">IDisposable</span>
<div class="highlight highlight-source-cs"><pre><span class="pl-k">public</span> <span class="pl-k">class</span> <span class="pl-en">Foo</span> : <span class="pl-k">IInitializable</span>, <span class="pl-k">IDisposable</span>
{
<span class="pl-k">readonly</span> GameLoadedSignal _signal;
PressedButtonSignal _signal;

<span class="pl-k">public</span> <span class="pl-en">Foo</span>(<span class="pl-k">GameLoadedSignal</span> <span class="pl-smi">signal</span>)
<span class="pl-k">public</span> <span class="pl-en">Foo1</span>(<span class="pl-k">PressedButtonSignal</span> <span class="pl-smi">signal</span>)
{
_signal = signal;
}

<span class="pl-k">public</span> <span class="pl-k">void</span> <span class="pl-en">Initialize</span>()
{
_signal.Event += OnGameLoaded;
_signal += OnPressed;

<span class="pl-c">// You can also do this which is equivalent</span>
<span class="pl-c">// _signal.Listen(OnPressed);</span>
}

<span class="pl-k">public</span> <span class="pl-k">void</span> <span class="pl-en">Dispose</span>()
{
_signal.Event -= OnGameLoaded;
_signal -= OnPressed;

<span class="pl-c">// You can also do this which is equivalent</span>
<span class="pl-c">// _signal.Unlisten(OnPressed);</span>
}

<span class="pl-k">void</span> <span class="pl-en">OnGameLoaded</span>()
<span class="pl-k">void</span> <span class="pl-en">OnPressed</span>()
{
...
Debug.Log(<span class="pl-s"><span class="pl-pds">"</span>Received OnPressed event<span class="pl-pds">"</span></span>);
}
}</pre></div>

<p>Here we use the convention of prefixing event handlers with On, but of course you don't have to follow this convention.</p>
<p>Signals can be especially useful for system-wide events that are not associated with any particular class.</p>

<p>After binding the signal, you will almost always want to also bind a trigger, so that you can actually invoke the signal. Signals and Triggers are bound as separate statements so that you can optionally add conditional binding on both the trigger and the signal separately.</p>
<p>Something else worth noting is that signals will throw exceptions if all listeners have not properly removed themselves by the time the scene exits. So for example, if we were to remove the line <code>_signal -= OnPressed</code> from above, we would see error messages in the log. If this behaviour is too strict for your liking, you might consider commenting out the assert in the Signal.Dispose methods.</p>

<p>Triggers are declared in an installer like this:</p>
<p>Also note that you can add parameters to your signals by adding the parameter types to the generic arguments of the Signal base class. For example:</p>

<div class="highlight highlight-source-cs"><pre>
<span class="pl-k">public</span> <span class="pl-k">override</span> <span class="pl-k">void</span> InstallBindings()
<div class="highlight highlight-source-cs"><pre><span class="pl-k">public</span> <span class="pl-k">class</span> <span class="pl-en">PressedButtonSignal</span> : <span class="pl-k">Signal</span>&lt;<span class="pl-k">PressedButtonSignal</span>, <span class="pl-k">string</span>&gt;
{
...
Container.BindTrigger&lt;GameLoadedSignal.Trigger&gt;();
...
Container.BindTrigger&lt;GameLoadedSignalWithParameter.Trigger&gt;().WhenInjectedInto&lt;Foo&gt;();
}
</pre></div>

<p>Once you have added the trigger to your container by binding it within an installer, you can use it like this:</p>

<div class="highlight highlight-source-cs"><pre><span class="pl-k">public</span> <span class="pl-k">class</span> <span class="pl-en">Foo</span>
<span class="pl-k">public</span> <span class="pl-k">class</span> <span class="pl-en">Bar</span>
{
<span class="pl-k">readonly</span> GameLoadedSignal.Trigger _trigger;
<span class="pl-k">readonly</span> PressedButtonSignal _signal;

<span class="pl-k">public</span> <span class="pl-en">Foo</span>(<span class="pl-k">GameLoadedSignal.Trigger</span> <span class="pl-smi">trigger</span>)
<span class="pl-k">public</span> <span class="pl-en">Bar</span>(<span class="pl-k">PressedButtonSignal</span> <span class="pl-smi">signal</span>)
{
_trigger = trigger;
_signal = signal;
}

<span class="pl-k">public</span> <span class="pl-k">void</span> <span class="pl-en">DoSomething</span>()
{
_trigger.Fire();
_signal.Fire(<span class="pl-s"><span class="pl-pds">"</span>some data<span class="pl-pds">"</span></span>);
}
}

<span class="pl-k">public</span> <span class="pl-k">class</span> <span class="pl-en">Foo</span> : <span class="pl-k">IInitializable</span>, <span class="pl-k">IDisposable</span>
{
PressedButtonSignal _signal;

<span class="pl-k">public</span> <span class="pl-en">Foo1</span>(<span class="pl-k">PressedButtonSignal</span> <span class="pl-smi">signal</span>)
{
_signal = signal;
}

<span class="pl-k">public</span> <span class="pl-k">void</span> <span class="pl-en">Initialize</span>()
{
_signal += OnPressed;
}

<span class="pl-k">public</span> <span class="pl-k">void</span> <span class="pl-en">Dispose</span>()
{
_signal -= OnPressed;
}

<span class="pl-k">void</span> <span class="pl-en">OnPressed</span>(<span class="pl-k">string</span> <span class="pl-smi">data</span>)
{
Debug.Log(<span class="pl-s"><span class="pl-pds">"</span>Received OnPressed event with data: <span class="pl-pds">"</span></span> + data);
}
}</pre></div>

Expand Down
36 changes: 22 additions & 14 deletions UnityProject/Assets/Zenject/Documentation/ReadMe.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand Down Expand Up @@ -36,18 +36,18 @@
<div class="page">
<div id="preview-page" class="preview-page" data-autorefresh-url="">



<div role="main" class="main-content">
<div class="container new-discussion-timeline experiment-repo-nav">
<div class="repository-content">
<div id="readme" class="readme boxed-group clearfix announce instapaper_body md">

<h3>
<span class="octicon octicon-book"></span>
README.md
</h3>

<article class="markdown-body entry-content" itemprop="text" id="grip-content">
<p><a href="ZenjectLogo.png?raw=true" target="_blank"><img src="ZenjectLogo.png?raw=true" alt="Zenject" width="600px" height="134px" style="max-width:100%;"></a></p>

Expand Down Expand Up @@ -1021,11 +1021,11 @@ <h2>

public class GameInstaller : MonoInstaller
{
public Foo Foo;
public Foo foo;

public override void InstallBindings()
{
Container.BindInstance(Foo);
Container.BindInstance(foo);
Container.Bind&lt;IInitializable&gt;().To&lt;GameRunner&gt;().AsSingle();
}
}
Expand Down Expand Up @@ -1881,7 +1881,9 @@ <h2>

<p>If you run your scene it should now behave exactly like the main scene except with the added functionality in your decorator installer. Also note that while not shown here, both scenes can access each other's bindings as if everything was in the same scene.</p>

<p>Also note that the Validate command can be used to quickly verify the different multi-scene setups.</p>
<p>Also note that the Validate command (CTRL+SHIFT+V) can be used to quickly verify the different multi-scene setups.</p>

<p>Also, note that decorator scenes must be loaded before the scenes that they are decorating.</p>

<p>Also, I should mention that Unity currently doesn't have a built-in way to save and restore multi-scene setups. We use a simple editor script for this that you can find <a href="https://gist.github.com/svermeulen/8927b29b2bfab4e84c950b6788b0c677">here</a> if interested.</p>

Expand Down Expand Up @@ -2310,8 +2312,14 @@ <h2>

<ul>
<li>Pokemon Go (both <a href="https://itunes.apple.com/us/app/pokemon-go/id1094591345?mt=8">iOS</a> and <a href="https://play.google.com/store/apps/details?id=com.nianticlabs.pokemongo&amp;hl=en">Android</a>)</li>
<li><a href="https://play.google.com/store/apps/details?id=com.nerdcorps.pinballcritters&amp;hl=en">Spinball Carnival</a></li>
<li><a href="https://play.google.com/store/apps/details?id=com.nerdcorps.slugthree&amp;hl=en">Slugterra: Guardian Force</a></li>
<li>
<a href="https://play.google.com/store/apps/details?id=com.nerdcorps.pinballcritters&amp;hl=en">Spinball Carnival</a> (Android)</li>
<li>
<a href="https://play.google.com/store/apps/details?id=com.nerdcorps.slugthree&amp;hl=en">Slugterra: Guardian Force</a> (Android)</li>
<li>
<a href="https://github.com/shiwano/submarine">Submarine</a> (iOS and Android)</li>
<li>
<a href="https://itunes.apple.com/us/app/nova-black-holes/id1114574985?mt=8">NOVA Black Holes</a> (iOS)</li>
</ul>

<p>Libraries</p>
Expand All @@ -2327,17 +2335,17 @@ <h2>

<ul>
<li>
<a href="https://www.modest3d.com/editor">Modest 3D</a> - An IDE to allow users to quickly and easily create procedural training content</li>
<a href="https://www.modest3d.com/editor">Modest 3D</a> (WebGL, WebPlayer, PC) - An IDE to allow users to quickly and easily create procedural training content</li>
<li>
<a href="https://www.modest3d.com/explorer">Modest 3D Explorer</a> - A simple editor to quickly create a 3D presentation with some number of slides</li>
<a href="https://www.modest3d.com/explorer">Modest 3D Explorer</a> (WebGL, WebPlayer, iOS, Android, PC, Windows Store) - A simple editor to quickly create a 3D presentation with some number of slides</li>
</ul>
</li>
</ul>

<h2>
<a id="user-content-cheat-sheet" class="anchor" href="#cheat-sheet" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a><a id="user-content-cheatsheet"></a>Cheat Sheet</h2>

<p>TBD</p>
<p>See <a href="CheatSheet.html">here</a>.</p>

<h2>
<a id="user-content-further-help" class="anchor" href="#further-help" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a><a id="user-content-further-help"></a>Further Help</h2>
Expand Down Expand Up @@ -2381,7 +2389,7 @@ <h2>
</div>
</div>



</div>
<div>&nbsp;</div>
Expand Down Expand Up @@ -2451,4 +2459,4 @@ <h2>
}
</script>
</body>
</html>
</html>
11 changes: 11 additions & 0 deletions UnityProject/Assets/Zenject/Documentation/ReleaseNotes.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ <h3>
<h2>
<a id="user-content-release-notes" class="anchor" href="#release-notes" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a><a id="user-content-release-notes"></a>Release Notes</h2>

<p>4.7 (November 6, 2016)</p>

<ul>
<li>Removed the concept of triggers in favour of just directly acting on the Signal to both subscribe and fire, since using Trigger was too much overhead for not enough gain</li>
<li>Fixed issue for Windows Store platform where zenject was not properly stripping out the WSA generated constructors</li>
<li>Changed to automatically choose the public constructor if faced with a choice between public and private</li>
<li>Fix to IL2CPP builds to work again</li>
<li>Added support for using the WithArguments bind method combined with FromFactory</li>
<li>Improved validation of multi-scene setups using Contract Names to output better error messages</li>
</ul>

<p>4.6 (October 23, 2016)</p>

<ul>
Expand Down
10 changes: 5 additions & 5 deletions UnityProject/Assets/Zenject/Documentation/SubContainers.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@
<div class="page">
<div id="preview-page" class="preview-page" data-autorefresh-url="">



<div role="main" class="main-content">
<div class="container new-discussion-timeline experiment-repo-nav">
<div class="repository-content">
<div id="readme" class="readme boxed-group clearfix announce instapaper_body md">

<h3>
<span class="octicon octicon-book"></span>
SubContainers.md
</h3>

<article class="markdown-body entry-content" itemprop="text" id="grip-content">
<h2>
<a id="user-content-sub-containers-and-facades" class="anchor" href="#sub-containers-and-facades" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a><a id="user-content-sub-containers-and-facades"></a>Sub-Containers And Facades</h2>
Expand Down Expand Up @@ -552,7 +552,7 @@ <h2>
</div>
</div>



</div>
<div>&nbsp;</div>
Expand Down Expand Up @@ -622,4 +622,4 @@ <h2>
}
</script>
</body>
</html>
</html>

0 comments on commit 0b4a15b

Please sign in to comment.