Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Properties> | ||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" PreferredExecutionTarget="MonoDevelop.Default" /> | ||
<MonoDevelop.Ide.Workbench ActiveDocument="Assets\scripts\KeyGate.cs"> | ||
<Files> | ||
<File FileName="Assets\scripts\TeleportPad.cs" Line="26" Column="4" /> | ||
<File FileName="Assets\scripts\KeyGate.cs" Line="14" Column="2" /> | ||
</Files> | ||
</MonoDevelop.Ide.Workbench> | ||
<MonoDevelop.Ide.DebuggingService.Breakpoints> | ||
<BreakpointStore /> | ||
</MonoDevelop.Ide.DebuggingService.Breakpoints> | ||
<MonoDevelop.Ide.DebuggingService.PinnedWatches /> | ||
</Properties> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using UnityEditor; | ||
|
||
namespace UnityStandardAssets.CrossPlatformInput.Inspector | ||
{ | ||
[InitializeOnLoad] | ||
public class CrossPlatformInitialize | ||
{ | ||
// Custom compiler defines: | ||
// | ||
// CROSS_PLATFORM_INPUT : denotes that cross platform input package exists, so that other packages can use their CrossPlatformInput functions. | ||
// EDITOR_MOBILE_INPUT : denotes that mobile input should be used in editor, if a mobile build target is selected. (i.e. using Unity Remote app). | ||
// MOBILE_INPUT : denotes that mobile input should be used right now! | ||
|
||
static CrossPlatformInitialize() | ||
{ | ||
var defines = GetDefinesList(buildTargetGroups[0]); | ||
if (!defines.Contains("CROSS_PLATFORM_INPUT")) | ||
{ | ||
SetEnabled("CROSS_PLATFORM_INPUT", true, false); | ||
SetEnabled("MOBILE_INPUT", true, true); | ||
} | ||
} | ||
|
||
|
||
[MenuItem("Mobile Input/Enable")] | ||
private static void Enable() | ||
{ | ||
SetEnabled("MOBILE_INPUT", true, true); | ||
switch (EditorUserBuildSettings.activeBuildTarget) | ||
{ | ||
case BuildTarget.Android: | ||
case BuildTarget.iOS: | ||
case BuildTarget.WP8Player: | ||
case BuildTarget.BlackBerry: | ||
case BuildTarget.PSM: | ||
case BuildTarget.Tizen: | ||
case BuildTarget.WSAPlayer: | ||
EditorUtility.DisplayDialog("Mobile Input", | ||
"You have enabled Mobile Input. You'll need to use the Unity Remote app on a connected device to control your game in the Editor.", | ||
"OK"); | ||
break; | ||
|
||
default: | ||
EditorUtility.DisplayDialog("Mobile Input", | ||
"You have enabled Mobile Input, but you have a non-mobile build target selected in your build settings. The mobile control rigs won't be active or visible on-screen until you switch the build target to a mobile platform.", | ||
"OK"); | ||
break; | ||
} | ||
} | ||
|
||
|
||
[MenuItem("Mobile Input/Enable", true)] | ||
private static bool EnableValidate() | ||
{ | ||
var defines = GetDefinesList(mobileBuildTargetGroups[0]); | ||
return !defines.Contains("MOBILE_INPUT"); | ||
} | ||
|
||
|
||
[MenuItem("Mobile Input/Disable")] | ||
private static void Disable() | ||
{ | ||
SetEnabled("MOBILE_INPUT", false, true); | ||
switch (EditorUserBuildSettings.activeBuildTarget) | ||
{ | ||
case BuildTarget.Android: | ||
case BuildTarget.iOS: | ||
case BuildTarget.WP8Player: | ||
case BuildTarget.BlackBerry: | ||
EditorUtility.DisplayDialog("Mobile Input", | ||
"You have disabled Mobile Input. Mobile control rigs won't be visible, and the Cross Platform Input functions will always return standalone controls.", | ||
"OK"); | ||
break; | ||
} | ||
} | ||
|
||
|
||
[MenuItem("Mobile Input/Disable", true)] | ||
private static bool DisableValidate() | ||
{ | ||
var defines = GetDefinesList(mobileBuildTargetGroups[0]); | ||
return defines.Contains("MOBILE_INPUT"); | ||
} | ||
|
||
|
||
private static BuildTargetGroup[] buildTargetGroups = new BuildTargetGroup[] | ||
{ | ||
BuildTargetGroup.Standalone, | ||
BuildTargetGroup.WebPlayer, | ||
BuildTargetGroup.Android, | ||
BuildTargetGroup.iOS, | ||
BuildTargetGroup.WP8, | ||
BuildTargetGroup.BlackBerry | ||
}; | ||
|
||
private static BuildTargetGroup[] mobileBuildTargetGroups = new BuildTargetGroup[] | ||
{ | ||
BuildTargetGroup.Android, | ||
BuildTargetGroup.iOS, | ||
BuildTargetGroup.WP8, | ||
BuildTargetGroup.BlackBerry, | ||
BuildTargetGroup.PSM, | ||
BuildTargetGroup.Tizen, | ||
BuildTargetGroup.WSA | ||
}; | ||
|
||
|
||
private static void SetEnabled(string defineName, bool enable, bool mobile) | ||
{ | ||
//Debug.Log("setting "+defineName+" to "+enable); | ||
foreach (var group in mobile ? mobileBuildTargetGroups : buildTargetGroups) | ||
{ | ||
var defines = GetDefinesList(group); | ||
if (enable) | ||
{ | ||
if (defines.Contains(defineName)) | ||
{ | ||
return; | ||
} | ||
defines.Add(defineName); | ||
} | ||
else | ||
{ | ||
if (!defines.Contains(defineName)) | ||
{ | ||
return; | ||
} | ||
while (defines.Contains(defineName)) | ||
{ | ||
defines.Remove(defineName); | ||
} | ||
} | ||
string definesString = string.Join(";", defines.ToArray()); | ||
PlayerSettings.SetScriptingDefineSymbolsForGroup(group, definesString); | ||
} | ||
} | ||
|
||
|
||
private static List<string> GetDefinesList(BuildTargetGroup group) | ||
{ | ||
return new List<string>(PlayerSettings.GetScriptingDefineSymbolsForGroup(group).Split(';')); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
The first-person character is a single prefab which is designed to be used as-is. There's usually no need to create your own from the separate scripts provided. Just drop the prefab into your scene and you're good to go. | ||
|
||
|
||
The simplest way to get started with the First Person Character is to follow these steps: | ||
|
||
1) Start with a suitable scene. There ought to be enough flat ground to walk around on. | ||
|
||
2) Place the "FirstPersonCharacter" prefab in the scene. | ||
|
||
3) If present, delete the "Main Camera" that exists in new scenes by default. The First Person Character prefab contains its own camera, so you don't need the default camera, or any of the camera rigs to use it. | ||
|
||
The first-person character is made up of a few components acting together. The FirstPersonCharacter script provides the functionality of moving, strafing and jumping. The SimpleMouseRotator provides the functionality of turning the body of the character left and right, and another copy of the same script on the "FirstPersonCamera" controls the looking-up-and-down effect. | ||
|
||
There is also an optional "Head Bob" script which provides a head bobbing effect and optionally also plays footstep sounds in sync with the head bobbing. This script can be disabled or removed if required. | ||
|
||
There are a number of simple adjustable settings on each component allowing you to change the movement speed, jump power, head bob style, and more. For more detail about each setting, see the comments in each script. | ||
|
||
The Character script also requires references to "zero friction" and "max friction" physics materials. These are provided already set-up for you. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.