Files
Fishing2/Assets/ThirdParty/Rewired/Documentation/Html/ComponentControls.html
2025-05-10 12:49:47 +08:00

361 lines
22 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/BasicTemplate.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Rewired Documentation | Component Controls</title>
<!-- InstanceEndEditable -->
<!-- InstanceParam name="isRoot" type="boolean" value="false" -->
<!-- InstanceParam name="wide" type="boolean" value="false" -->
<link href="files/css/styles.css" rel="stylesheet" type="text/css" />
<!-- Favicons -->
<link rel="icon" type="image/x-icon" href="/projects/rewired/files/images/favicon.ico?v=1" />
<!-- Apple Icons -->
<!-- For iPad with high-resolution Retina display running iOS = 7: -->
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="files/images/favicon_152x152.png?v=1">
<!-- For iPad with high-resolution Retina display running iOS = 6: -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="files/images/favicon_144x144.png?v=1">
<!-- For iPhone with high-resolution Retina display running iOS = 7: -->
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="files/images/favicon_120x120.png?v=1">
<!-- For iPhone with high-resolution Retina display running iOS = 6: -->
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="files/images/favicon_114x114.png?v=1">
<!-- For the iPad mini and the first- and second-generation iPad on iOS = 7: -->
<link rel="apple-touch-icon-precomposed" sizes="76x76" href="files/images/favicon_76x76.png?v=1">
<!-- For the iPad mini and the first- and second-generation iPad on iOS = 6: -->
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="files/images/favicon_72x72.png?v=1">
<!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: -->
<link rel="apple-touch-icon-precomposed" href="files/images/favicon_57x57.png?v=1">
</head>
<body>
<div class="container">
<div class="google-search-bar">
<script>
(function() {
var cx = '007961148920562332911:oocvtwz5jce';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:search></gcse:search>
</div>
<div class="content">
<div class="page-body">
<div class="sidebar-nav">
<h4><a href="Documentation.html">Documentation</a></h4>
<ul>
<li><a href="Overview.html">Overview</a></li>
<li><a href="ReleaseNotes.txt">Release Notes</a></li>
</ul>
<strong>Essentials:</strong>
<ol>
<li><a href="Installation.html">Installation</a></li>
<li><a href="QuickStart.html">Quick Start</a></li>
<li><a href="BasicUsage.html">Basic Usage</a></li>
<li><a href="Deployment.html">Deployment</a></li>
<li><a href="BestPractices.html">Best Practices</a></li>
<li><a href="RewiredEditor.html">Rewired Editor</a></li>
<li><a href="http://guavaman.com/projects/rewired/docs/api-reference" target="_blank">API Reference</a></li>
</ol>
<strong>Concepts:</strong>
<ul>
<li><a href="InputManager.html">Input Manager</a></li>
<li><a href="Players.html">Players</a></li>
<li><a href="Actions.html">Actions</a></li>
<li><a href="InputBehaviors.html">Input Behaviors</a></li>
<li><a href="Controllers.html">Controllers</a></li>
<li><a href="ControllerMaps.html">Controller Maps</a></li>
<li><a href="ControllerTemplates.html">Controller Templates</a></li>
<li><a href="MapCategories.html">Map Categories</a></li>
<li><a href="Layouts.html">Layouts</a></li>
<li><a href="LayoutManager.html">Layout Manager</a></li>
<li><a href="MapEnabler.html">Map Enabler</a></li>
<li><a href="CustomControllers.html">Custom Controllers</a></li>
</ul>
<strong>Extras:</strong>
<ul>
<li><a href="ControlMapper.html" title="Control Mapper">Control Mapper</a></li>
<li><a href="Glyphs.html" title="Glyphs">Glyphs</a></li>
<li><a href="TouchControls.html" title="Touch Controls">Touch Controls</a></li>
<li><a href="UnityInputOverride.html" title="Unity Input Override">Unity Input Override</a></li>
</ul>
<strong>Misc:</strong>
<ul>
<li><a href="RewiredStandaloneInputModule.html">Rewired Standalone Input Module</a></li>
<li><a href="ComponentControls.html" title="Component Controls">Component Controls</a></li>
<li><a href="PlayerControllers.html" title="Player Controllers">Player Controllers</a></li>
<li><a href="InputMapper.html" title="Input Mapper">Input Mapper</a></li>
<li><a href="UserDataStore.html" title="User Data Store">User Data Store</a></li>
<li><a href="CustomPlatforms.html" title="User Data Store">Custom Platforms</a></li>
<li><a href="Localization.html" title="Localization">Localization</a></li>
</ul>
<strong>How To's:</strong>
<ul>
<li><a href="HowTos.html">See all topics...</a></li>
</ul>
<strong>Help:</strong>
<ul>
<li><a href="SupportedControllers.html" title="Supported Controllers">Supported Controllers</a></li>
<li><a href="Overview.html#tested-platforms" title="Tested Platforms">Tested Platforms</a></li>
<li><a href="Troubleshooting.html" title="Troubleshooting">Troubleshooting</a></li>
<li><a href="KnownIssues.html">Known Issues</a></li>
<li><a href="SpecialPlatformSupport.html" title="Special Platform Support">Special Platform Support</a></li>
<li><a href="Examples.html" title="Examples">Examples</a></li>
<li><a href="Integration.html">Integrations</a></li>
<li><a href="Updating.html" title="Updating Rewired">Updating Rewired</a></li>
</ul>
<strong>FAQ</strong>
<ul>
<li><a href="FAQ.html">See all topics...</a></li>
</ul>
<strong>Unity Help:</strong>
<ul>
<li><a href="http://docs.unity3d.com/Manual/" target="_blank">Unity Manual</a></li>
<li><a href="http://docs.unity3d.com/ScriptReference/" target="_blank">Unity Script Reference</a></li>
<li><a href="http://unity3d.com/learn/tutorials/modules" target="_blank">Unity Tutorials</a></li>
</ul>
<strong>Links:</strong>
<ul>
<li><a href="http://guavaman.com/projects/rewired">Rewired Website</a></li>
<li><a href="http://guavaman.com/projects/rewired/docs">Web Documentation</a></li>
</ul>
</div>
<div class="main-body">
<div class="logo"><a href="http://guavaman.com/projects/rewired" title="Rewired"><img src="files/images/rewired-logo.png" width="173" height="139" alt="Rewired" /></a></div>
<h1>
<!-- InstanceBeginEditable name="PageHeader" -->Component Controls<!-- InstanceEndEditable -->
</h1>
<!-- InstanceBeginEditable name="MainBody" -->
<h3><strong>General Information</strong></h3>
<ul>
<li><a href="#requirements">Requirements</a></li>
<li><a href="#overview">Overview</a></li>
</ul>
<p><strong>Controllers</strong></p>
<ul>
<li><a href="#custom-controller">Custom Controller</a></li>
</ul>
<p><strong>Controls</strong></p>
<ul>
<li><a href="#tilt-control">Tilt Control</a> </li>
</ul>
<p><strong>Other Controls</strong></p>
<ul>
<li><a href="TouchControls.html">Touch Controls</a></li>
</ul>
<p>&nbsp;</p>
<hr />
<h2>General Information</h2>
<h3><a name="requirements" id="requirements"></a>Requirements</h3>
<ul>
<li>Understanding of <a href="Documentation.html">Rewired</a> and <a href="ControllerMaps.html">Controller Maps</a></li>
<li>Understanding of <a href="CustomControllers.html">Custom Controllers</a></li>
</ul>
<p>&nbsp;</p>
<hr />
<h3><a name="overview" id="overview"></a>Overview</h3>
<p>Component controls are MonoBehaviour based controls that can be configured using the Unity inspector. <a href="TouchControls.html">Touch controls</a> and <a href="#tilt-control">tilt controls</a> are two examples of component controls. Component controls are most commonly used to provide input values to a <a href="CustomControllers.html">Custom Controller</a> which has been configured beforehand in the <a href="RewiredEditor.html">Rewired Editor</a>.</p>
<p>Component controls consist of two component types:</p>
<ol>
<li>Component Controller - Manages a set of controls.</li>
<li>Component Control - Individual buttons, joysticks, touch pads, tilt control, etc.</li>
</ol>
<p>Each Component Control must always be the child of a Component Controller in the Unity scene Hierarchy. The Component Controller is responsible for collecting input data from its individual child controls, and in most cases, sending that data to a <a href="CustomControllers.html">Custom Controller</a>. The hierarchy of a an example Component Controller with its child controls would look like this:</p>
<p><img src="files/images/touch-controller-hierarchy.png" alt="Touch Controller hierarchy" /><br />
</p>
<p>In the example above, the Touch Controller component points to a Rewired.CustomController class object which will receive the data from the touch joystick, the two touch buttons, and a tilt control. Each control will get the user input and send that data back to the Touch Controller component, which will feed it into the target Custom Controller elements pointed to in the inspector. The input will be piped into the Rewired Player-Action system and the Player who is assigned the Custom Controller will receive the input. The game-side code for getting input remains unchanged regardless of whether the input is coming from a physical joystick, keyboard, mouse, touch controller, tilt control, etc.</p>
<p>You will notice the Tilt Control in the list above parented underneath a Touch Controller component. Even though a Tilt Control isn't a touch control, it can still be parented underneath a Touch Controller component and it will work because Touch Controller inherits from Custom Controller component and fulfills all requirements of the Tilt Control. You could just as easily parent the Tilt Control underneath a Custom Controller component instead, for example, if you aren't using any touch controls.</p>
<p><img src="files/images/custom-controller-tilt-hierarchy.png" /></p>
<p> For Touch Controls, however, the Touch Controller component must be used instead of the Custom Controller component.</p>
<p>The most common use of Component Controls is on-screen Touch Controls for mobile games. Rewired includes touch controls which you can customize and use directly in your games. See <a href="TouchControls.html">Touch Controls</a> for more information.</p>
<p>&nbsp;</p>
<hr />
<h2>Controllers </h2>
<h3><a name="custom-controller" id="tilt-control2"></a>Custom Controller</h3>
<p>The Custom Controller component is responsible for sending user input data received from its child Component Controls into the Rewired.CustomController.</p>
<p>The Custom Controller component is essentially a component wrapper for the Rewired.CustomController class. The Custom Controller component cannot function without an underlying target Rewired.CustomController. This component's inspector allows you to set options which will tell it which Rewired.CustomController to point to.</p>
<p>The first thing you should do is link the Rewired Input Manager you intend to use to the Rewired Input Manager field of the Custom Controller. This is optional, but highly recommended as it allows you to select the Custom Controller and the target elements on that controller by simply selecting them from a drop-down. If you do not link the Rewired Input Manager, you will have to use either string names or id integers to tell the controller and each control which Custom Controller and which elements in which to feed the incoming data.</p>
<p>Click the &quot;Find Rewired Input Manager&quot; button in the inspector to find any enabled Rewired Input Manager in the scene and link it. Otherwise, you can manually link it to the Rewired Input Manager.</p>
<p><img src="files/images/componentcontrols_customcontroller_inspector_rim.png" alt="Custom Controller inspector" /></p>
<p>There are two ways to determine the target Rewired.CustomController:</p>
<ol>
<li>Instantiate a new Custom Controller from a controller defined in the Rewired Input Manager.</li>
<li>Search through existing Custom Controllers that have already been instantiated. </li>
</ol>
<p><strong>Instantiating a new Custom Controller:</strong><br />
The Custom Controller component can instantiate a new Rewired.CustomController from an existing controller definition that you have created beforehand in the Rewired Input Manager. This is the easiest way to work with Custom Controllers and is the recommended option.
</p>
<p>A new Rewired.CustomController will be instantiated on Awake of the Custom Controller component and optionally destroyed when the Custom Controller component is destroyed. To enable this, check &quot;Create Custom Controller&quot; and &quot;Destroy Custom Controller&quot; in the inspector. Select a Custom Controller from the list or enter its Source Id, then choose a Player to assign it to when it's instantiated.</p>
<p><img src="files/images/componentcontrols_customcontroller_inspector_create_rimlinked.png" alt="Custom Controller inspector" /></p>
<table width="100%" border="0">
<tr>
<td>Create Custom Controller</td>
<td>If true, a new Custom Controller will be created. Otherwise, an existing Custom Controller will be found using the selector properties.</td>
</tr>
<tr>
<td>Custom Controller / Source Id</td>
<td><p>(Custom Controller is shown if the Rewired Input Manager has been linked in the Rewired Input Manager field, otherwise Source Id is shown.)</p>
<p>Custom Controller:<br />
The Custom Controller to create.</p>
<p>Source Id:<br />
The source id of the Custom Controller to create. Get this from the Rewired Input Manager.</p></td>
</tr>
<tr>
<td>Assign To Player / Assign To Player Id</td>
<td><p>(Assign To Player is shown if the Rewired Input Manager has been linked in the Rewired Input Manager field, otherwise Assign To Player Id is shown.)</p>
<p>Assign To Player:<br />
The Player that will be assigned this Custom Controller when it is created. </p>
<p>Assign To Player Id:<br />
The Player that will be assigned this Custom Controller when it is created.</p></td>
</tr>
<tr>
<td>Destroy Custom Controller</td>
<td>If true, the Custom Controller created by this component will be destroyed when this component is destroyed.</td>
</tr>
</table>
<p>&nbsp;</p>
<p><strong>Searching for an existing Custom Controller:</strong><br />
If you have already instiantated a Rewired.CustomController through scripting or have set up Rewired to automatically create a Custom Controller on start by adding it under &quot;Starting Custom Controllers&quot; on the <a href="RewiredEditor.html#Players">Players page of the Rewired Editor</a>, you can set up the Custom Controller component to find that existing Rewired.CustomController and use it for its target.</p>
<p>If you want to search for an existing Rewired.CustomController, the &quot;Create Custom Controller&quot; field must not be checked:</p>
<p><img src="files/images/componentcontrols_customcontroller_inspector_search_rimlinked.png" alt="Custom Controller inspector" /></p>
<p>Additional options will appear in the inspector allowing you to set the search parameters:</p>
<table width="100%" border="0">
<tr>
<td>Find Using Source Id</td>
<td>If true, the Custom Controller will be searched for by its source controller id. This can be used with Find in Player and/or Find Using Tag to further refine the search parameters.</td>
</tr>
<tr>
<td>Custom Controller / Custom Controller Id</td>
<td><p>(Custom Controller is shown if the Rewired Input Manager has been linked in the Rewired Input Manager field, otherwise Custom Controller Id is shown.)</p>
<p>Custom Controller:<br />
The target Custom Controller. This is used to find the Custom Controller if Find Using Source Id is True.</p>
<p>Custom Controller Id:<br />
The source id of the Custom Controller. This is used to find the Custom Controller if Find Using Source Id is True.</p></td>
</tr>
<tr>
<td>Find Using Tag</td>
<td>If true, the Custom Controller will be found using the tag specified here. This can be used with Find in Player and/or Find Using Source Id to further refine the search parameters.</td>
</tr>
<tr>
<td>Tag</td>
<td>The tag on the Custom Controller you wish to use. This is used to find the Custom Controller.</td>
</tr>
<tr>
<td>Find In Player</td>
<td>If true, the Custom Controller will be searched for in the Player specified in the Player Id field. This can be used with Find Using Source Id and/or Find Using Tag to further refine the search parameters.</td>
</tr>
<tr>
<td>Player / Player Id</td>
<td>The Player Id of the Player that owns the Custom Controller.</td>
</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<hr />
<h2>Controls </h2>
<h3><a name="tilt-control" id="tilt-control"></a>Tilt Control</h3>
<p>The Tilt Control uses a device's accelerometer and gyro to determine forward and horizontal tilt. The output values are in the -1 to +1 range.</p>
<p>A <a href="#custom-controller">Custom Controller</a> component or a component that inherits from it must exist on a parent of the control's GameObject.</p>
<p><strong>Inspector Options</strong></p>
<p><img src="files/images/componentcontrols_tiltcontrol_inspector.png" width="445" height="440" alt="Tilt Control inspector" /></p>
<table width="100%" border="0">
<tr>
<td><strong>Custom Controller Options</strong></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Horizontal Tilt Custom Controller Element</td>
<td>The Custom Controller element that will receive input values from the X axis.</td>
</tr>
<tr>
<td>Forward Tilt Custom Controller Element</td>
<td>The Custom Controller element that will receive input values from the Y axis.</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><strong>Tilt Options</strong></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Allowed Tilt Directions</td>
<td>The tilt directions in which movement is allowed. You can restrict movement to one or both directions.</td>
</tr>
<tr>
<td>Horizontal Tilt Limit</td>
<td>The maximum horizontal tilt angle in degrees. When the device is tilted to this angle or further in either direction, the axis will return a value of 1/-1.</td>
</tr>
<tr>
<td>Horizontal Rest Angle</td>
<td>The offset angle from horizontal which will be considered the resting angle. This represents the angle at which the user holds the device without generating tilt.</td>
</tr>
<tr>
<td>Forward Tilt Limit</td>
<td>The maximum forward tilt angle in degrees. When the device is tilted to this angle or further in either direction, the axis will return a value of 1/-1.</td>
</tr>
<tr>
<td>Forward Rest Angle</td>
<td>The offset angle from vertical which will be considered the resting angle. This represents the angle at which the user holds the device without generating tilt. A typical value would be around 40 degrees.</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><strong>Axis Options</strong></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Invert Horizontal Tilt</td>
<td>Inverts the X axis value.</td>
</tr>
<tr>
<td>Invert Forward Tilt</td>
<td>Inverts the Y axis value.</td>
</tr>
<tr>
<td>Advanced</td>
<td>Advanced configuration options for the axes.</td>
</tr>
</table>
<p><br />
</p>
<div class="bottom-pager clearfix">
<a class="back-button" href="Actions.html" title="Actions"><span class="button-img"></span></a><a class="back-button" href="Documentation.html" title="Actions">Documentation</a></div>
<!-- InstanceEndEditable -->
</div>
</div>
<div class="footer clearfix">
<p class="left">Copyright &copy;2014-2021 <a href="http://guavaman.com" title="Guavaman Enterprises">Guavaman Enterprises</a>. All rights reserved. No materials may be reproduced without permission.</p>
<p class="right"><a href="http://guavaman.com/projects/rewired" title="Return to Rewired Website">Return to Rewired Website</a></p>
</div>
<!-- end .content --></div>
<!-- end .container --></div>
</body>
<!-- InstanceEnd --></html>