Minor cleanup (#10)
* General Feedback Cleanup Rename Samples to Examples Add a bunch of documentation about prefabs and scripts. Update sub-module to most recent build. Make SignIn button show a "Not Enabled" message when you're missing an XboxServices.config file. Add better error handling to UnityTaskExtensions stuff. * Add some better UI for configuration panel.
This commit is contained in:
Родитель
dc5f86a9fd
Коммит
1ac188ea79
|
@ -498,6 +498,10 @@ Prefab:
|
|||
propertyPath: m_Pivot.y
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1350312985410614, guid: 8adc2c440c4ec6c439b81ff9e3bfce6b, type: 2}
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 100100000, guid: 8adc2c440c4ec6c439b81ff9e3bfce6b, type: 2}
|
||||
m_IsPrefabParent: 0
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 496f4e1bdb1e6df4a93dcdace0111852
|
||||
folderAsset: yes
|
||||
timeCreated: 1479431419
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1 +0,0 @@
|
|||
# Xbox Live in Unity
|
|
@ -88,15 +88,16 @@ public class XboxLiveConfigurationEditor : EditorWindow
|
|||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox("In order to use Xbox Live functionality within your game, you must first associate it with a new or existing Xbox Live title.\nThis title information identifies your game with Xbox Live services and allows users to interact with Xbox Live and also allows you to interact with", MessageType.Info, true);
|
||||
EditorGUILayout.HelpBox("In order to use Xbox Live functionality within your game, you must first associate it with a new or existing Xbox Live title.\nThis title information identifies your game with Xbox Live services and allows users to interact with Xbox Live. You need a DevCenter account to associate your game, but you can create an empty configuration file to test functionality within Unity.", MessageType.Info, true);
|
||||
}
|
||||
|
||||
// Always show a button to manually open the configuration
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUILayout.FlexibleSpace();
|
||||
if (GUILayout.Button(new GUIContent("Edit " + XboxLiveAppConfiguration.FileName, "Manually create/edit the configuration file if you already have your configuration values"), GUILayout.MaxWidth(200)))
|
||||
|
||||
if (!File.Exists(this.configFilePath))
|
||||
{
|
||||
if (!File.Exists(this.configFilePath))
|
||||
if (GUILayout.Button(new GUIContent("Create empty " + XboxLiveAppConfiguration.FileName, "Create an empty configuration file so that you can test Xbox Live in the editor before associating your game with DevCenter.")))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -113,8 +114,13 @@ public class XboxLiveConfigurationEditor : EditorWindow
|
|||
{
|
||||
}
|
||||
}
|
||||
|
||||
Process.Start(this.configFilePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GUILayout.Button(new GUIContent("Edit " + XboxLiveAppConfiguration.FileName, "Manually edit the configuration file if you already have your configuration values."), GUILayout.MaxWidth(200)))
|
||||
{
|
||||
Process.Start(this.configFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
|
|
@ -22,6 +22,10 @@ namespace Assets.Xbox_Live.Editor
|
|||
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Handles post processing the generated Visaul Studio projects in order to deal with DevCenter
|
||||
/// association and including Xbox Live configuration files.
|
||||
/// </summary>
|
||||
[InitializeOnLoad]
|
||||
public class XboxLivePostProcessing
|
||||
{
|
||||
|
@ -31,11 +35,15 @@ namespace Assets.Xbox_Live.Editor
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the XboxServices.config file
|
||||
/// Adds the XboxServices.config file to the generated project file.
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="fileContent"></param>
|
||||
/// <returns></returns>
|
||||
/// <param name="fileName">The name of the file being processed.</param>
|
||||
/// <param name="fileContent">The content of the file being processed.</param>
|
||||
/// <returns>The project file with an additional content element included.</returns>
|
||||
/// <remarks>
|
||||
/// This only modifies the Unity debug projects and will not have any
|
||||
/// effect on projects built as part of the Unity UWP build process.
|
||||
/// </remarks>
|
||||
private static string AddXboxServicesConfig(string fileName, string fileContent)
|
||||
{
|
||||
if (!fileName.EndsWith(".Editor.csproj"))
|
||||
|
@ -106,11 +114,15 @@ namespace Assets.Xbox_Live.Editor
|
|||
}
|
||||
|
||||
CopyConfigurationFile(XboxLiveAppConfiguration.FileName, projectFolder);
|
||||
// Add the XboxService.config file
|
||||
identityItemGroup.Add(
|
||||
new XElement(msb + "Content",
|
||||
new XAttribute("Include", "XboxServices.config"),
|
||||
new XElement(msb + "CopyToOutputDirectory", "PreserveNewest")));
|
||||
|
||||
// Add the XboxService.config file if it doesn't exist
|
||||
if (identityItemGroup.XPathSelectElement("msb:Content[@Include='XboxServices.config']", ns) == null)
|
||||
{
|
||||
identityItemGroup.Add(
|
||||
new XElement(msb + "Content",
|
||||
new XAttribute("Include", "XboxServices.config"),
|
||||
new XElement(msb + "CopyToOutputDirectory", "PreserveNewest")));
|
||||
}
|
||||
|
||||
project.Save(projectFile);
|
||||
}
|
||||
|
@ -132,12 +144,12 @@ namespace Assets.Xbox_Live.Editor
|
|||
manifest.XPathSelectElement("m:Package/m:Properties/m:PublisherDisplayName", ns).Value = configuration.PublisherDisplayName;
|
||||
manifest.XPathSelectElement("m:Package/m:Applications/m:Application/uap:VisualElements", ns).Attribute("DisplayName").Value = configuration.DisplayName;
|
||||
|
||||
if (manifest.XPathSelectElement("m:Package/m:Capabilities") == null)
|
||||
if (manifest.XPathSelectElement("m:Package/m:Capabilities", ns) == null)
|
||||
{
|
||||
manifest.XPathSelectElement("m:Package", ns).Add(new XElement(m + "Capabilities"));
|
||||
}
|
||||
|
||||
if (manifest.XPathSelectElement("m:Package/m:Capabilities/m:Capability[@Name='internetClient']") == null)
|
||||
if (manifest.XPathSelectElement("m:Package/m:Capabilities/m:Capability[@Name='internetClient']", ns) == null)
|
||||
{
|
||||
manifest.XPathSelectElement("m:Package/m:Capabilities", ns).Add(new XElement(m + "Capability", new XAttribute("Name", "internetClient")));
|
||||
}
|
||||
|
|
|
@ -382,6 +382,7 @@ RectTransform:
|
|||
m_Children:
|
||||
- {fileID: 887648347}
|
||||
- {fileID: 146666290}
|
||||
- {fileID: 305207686}
|
||||
m_Father: {fileID: 534060255}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
@ -390,6 +391,128 @@ RectTransform:
|
|||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!1 &305207685
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 305207686}
|
||||
- component: {fileID: 305207689}
|
||||
- component: {fileID: 305207688}
|
||||
- component: {fileID: 305207687}
|
||||
m_Layer: 5
|
||||
m_Name: DoubleDistanceButton
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &305207686
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 305207685}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 363808349}
|
||||
m_Father: {fileID: 227486349}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: -62}
|
||||
m_SizeDelta: {x: 160, y: 30}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &305207687
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 305207685}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 1392445389, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 3
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 305207688}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 1720462892}
|
||||
m_MethodName: Multiply
|
||||
m_Mode: 4
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 2
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0,
|
||||
Culture=neutral, PublicKeyToken=null
|
||||
--- !u!114 &305207688
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 305207685}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
|
||||
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Type: 1
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
--- !u!222 &305207689
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 305207685}
|
||||
--- !u!1 &318207214
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -464,6 +587,80 @@ CanvasRenderer:
|
|||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 318207214}
|
||||
--- !u!1 &363808348
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 363808349}
|
||||
- component: {fileID: 363808351}
|
||||
- component: {fileID: 363808350}
|
||||
m_Layer: 5
|
||||
m_Name: Text
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &363808349
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 363808348}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 305207686}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &363808350
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 363808348}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
|
||||
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_FontData:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_FontSize: 14
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 0
|
||||
m_MinSize: 10
|
||||
m_MaxSize: 40
|
||||
m_Alignment: 4
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: Double Distance
|
||||
--- !u!222 &363808351
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 363808348}
|
||||
--- !u!1 &534060251
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
|
@ -1,6 +1,6 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 765d9457c414dfa4bbf379eb6b44443b
|
||||
timeCreated: 1486086152
|
||||
guid: 55480ceb2b651fc499951f46d4a1ba68
|
||||
timeCreated: 1487186589
|
||||
licenseType: Free
|
||||
PluginImporter:
|
||||
serializedVersion: 1
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
# Xbox Live Unity Plugin
|
||||
|
||||
See the Unity Plugin Documentation on GitHub for details on getting started: http://github.com/Microsoft/xbox-live-unity-plugin
|
|
@ -1,8 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e119864f0d9cd2e4a97b43e5806caac6
|
||||
timeCreated: 1479431741
|
||||
guid: e245c634144718444a8a31293733cce0
|
||||
timeCreated: 1487267409
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,27 +0,0 @@
|
|||
// -----------------------------------------------------------------------
|
||||
// <copyright file="FriendsList.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class FriendsList : MonoBehaviour
|
||||
{
|
||||
[Range(1, 10)]
|
||||
public int count;
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a2258d1a798d6064cb3888b0e9352a20
|
||||
timeCreated: 1481077314
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -43,6 +43,7 @@ public class Leaderboard : MonoBehaviour
|
|||
|
||||
public void Awake()
|
||||
{
|
||||
XboxLive.EnsureEnabled();
|
||||
this.headerText.text = this.displayName;
|
||||
this.entryObjectPool = GetComponent<ObjectPool>();
|
||||
this.UpdateButtons();
|
||||
|
|
|
@ -12,7 +12,7 @@ using Microsoft.Xbox.Services.Stats.Manager;
|
|||
[Serializable]
|
||||
public class DoubleStat : StatBase<double>
|
||||
{
|
||||
public void Multiply(double multiplier)
|
||||
public void Multiply(float multiplier)
|
||||
{
|
||||
this.SetValue(Value * multiplier);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// -----------------------------------------------------------------------
|
||||
// <copyright file="IntegerStat.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
// Internal use only.
|
||||
// </copyright>
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
|
@ -20,17 +20,17 @@ public class IntegerStat : StatBase<int>
|
|||
{
|
||||
public void Increment()
|
||||
{
|
||||
this.SetValue(Value + 1);
|
||||
this.SetValue(this.Value + 1);
|
||||
}
|
||||
|
||||
public void Decrement()
|
||||
{
|
||||
this.SetValue(Value - 1);
|
||||
this.SetValue(this.Value - 1);
|
||||
}
|
||||
|
||||
public override void SetValue(int value)
|
||||
{
|
||||
Value = value;
|
||||
StatsManager.Singleton.SetStatAsInteger(XboxLive.Instance.User, Name, Value);
|
||||
this.Value = value;
|
||||
StatsManager.Singleton.SetStatAsInteger(XboxLive.Instance.User, this.Name, this.Value);
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@ public class StatsManagerComponent : Singleton<StatsManagerComponent>
|
|||
/// </summary>
|
||||
private void Awake()
|
||||
{
|
||||
XboxLive.EnsureEnabled();
|
||||
this.manager = StatsManager.Singleton;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
// -----------------------------------------------------------------------
|
||||
// <copyright file="StringStat.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
|
||||
using Microsoft.Xbox.Services.Stats.Manager;
|
||||
|
@ -8,6 +15,6 @@ public class StringStat : StatBase<string>
|
|||
public override void SetValue(string value)
|
||||
{
|
||||
this.Value = value;
|
||||
StatsManager.Singleton.SetStatAsString(XboxLive.Instance.User, Name, Value);
|
||||
StatsManager.Singleton.SetStatAsString(XboxLive.Instance.User, this.Name, this.Value);
|
||||
}
|
||||
}
|
|
@ -43,6 +43,11 @@ public class TaskYieldInstruction : CustomYieldInstruction
|
|||
|
||||
public TaskYieldInstruction(Task task)
|
||||
{
|
||||
if (task == null)
|
||||
{
|
||||
throw new ArgumentNullException("task");
|
||||
}
|
||||
|
||||
this.Task = task;
|
||||
|
||||
if (task.IsCompleted)
|
||||
|
@ -62,7 +67,21 @@ public class TaskYieldInstruction : CustomYieldInstruction
|
|||
{
|
||||
get
|
||||
{
|
||||
return !this.taskComplete;
|
||||
if (!this.taskComplete)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the task has completed, but completes with an error
|
||||
// this will force the exception to be thrown so that the
|
||||
// coroutine code will at least log it somewhere which
|
||||
// should prevent stuff from getting lost.
|
||||
if (this.Task.Exception != null)
|
||||
{
|
||||
throw this.Task.Exception;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,17 @@ public class UserProfile : MonoBehaviour
|
|||
public void Start()
|
||||
{
|
||||
// Disable the sign-in button if there's no configuration available.
|
||||
this.signInPanel.GetComponentInChildren<Button>().interactable = XboxLive.IsEnabled;
|
||||
if (!XboxLive.IsEnabled)
|
||||
{
|
||||
Button signInButton = this.signInPanel.GetComponentInChildren<Button>();
|
||||
signInButton.interactable = false;
|
||||
Text signInButtonText = signInButton.GetComponentInChildren<Text>(true);
|
||||
if (signInButtonText != null)
|
||||
{
|
||||
signInButtonText.fontSize = 16;
|
||||
signInButtonText.text = "Xbox Live is not enabled.\nSee errors for detail.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void XboxLiveUserOnSignOutCompleted(object sender, SignOutCompletedEventArgs signOutCompletedEventArgs)
|
||||
|
|
|
@ -54,15 +54,16 @@ public class XboxLive : Singleton<XboxLive>
|
|||
{
|
||||
this.Configuration = XboxLiveAppConfiguration.Instance;
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Exception)
|
||||
{
|
||||
throw new InvalidOperationException("You must associate your game with an Xbox Live Title in order to use Xbox Live functionality.", e);
|
||||
Debug.LogError("Xbox Live must be enabled. Run the Xbox Live Association Wizard from Xbox Live > Configuration before using any Xbox Live features.");
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator SignInAsync()
|
||||
{
|
||||
this.User = new XboxLiveUser();
|
||||
|
||||
TaskYieldInstruction<SignInResult> signInTask = this.User.SignInAsync().AsCoroutine();
|
||||
yield return signInTask;
|
||||
|
||||
|
|
|
@ -6,10 +6,6 @@
|
|||
Install the Xbox Live SDK into the Unity project
|
||||
.PARAMETER FromSource
|
||||
Build the SDK from the xbox-live-api-csharp submodule and copy the binaries.
|
||||
.PARAMETER CopySource
|
||||
Copy the raw API source files directly into the Unity directory.
|
||||
This is generally useful if you're doing a large amount of back and forth between
|
||||
the SDK and Unity, but requires manually copying changes back.
|
||||
.PARAMETER FromNuget
|
||||
Download the SDK NuGet package and copy the binaries from there.
|
||||
.PARAMETER CopyOnly,
|
||||
|
@ -18,7 +14,6 @@
|
|||
#>
|
||||
param(
|
||||
[switch]$FromSource,
|
||||
[switch]$CopySource,
|
||||
[switch]$FromNuget,
|
||||
[switch]$CopyOnly
|
||||
)
|
||||
|
@ -49,6 +44,8 @@ if(!(Get-Command $nugetCmd -ErrorAction SilentlyContinue))
|
|||
$nugetCmd = $nugetPath
|
||||
}
|
||||
|
||||
Import-Module "$PSScriptRoot\Invoke-MsBuild"
|
||||
|
||||
if($FromNuget)
|
||||
{
|
||||
# Folder is named with a . prefix so that it's ignored by Unity, the files that we
|
||||
|
@ -76,8 +73,6 @@ elseif($FromSource)
|
|||
if(!$CopyOnly)
|
||||
{
|
||||
& $nugetCmd restore $sdkSln
|
||||
|
||||
Import-Module "$PSScriptRoot\Invoke-MsBuild"
|
||||
|
||||
Write-Host "Building Xbox Live SDK... "
|
||||
$buildResult = Invoke-MsBuild $sdkSln -BuildLogDirectoryPath $PSScriptRoot -ShowBuildOutputInCurrentWindow
|
||||
|
@ -92,18 +87,4 @@ elseif($FromSource)
|
|||
Write-Host "SDK Build Succeeded."
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif($CopySource)
|
||||
{
|
||||
# Otherwise just copy the raw source files from the xbox-live-api-csharp submodule directly into the project
|
||||
$sdkPath = Join-Path $PSScriptRoot "..\External\xbox-live-api-csharp"
|
||||
if(!(Test-Path (Join-Path $sdkPath "Source")))
|
||||
{
|
||||
Write-Error "Unable to find required files in xbox-live-api-csharp submodule. Make sure that all submodules are synced."
|
||||
return
|
||||
}
|
||||
|
||||
copy (Join-Path $sdkPath "External\parse-sdk\debug\*") $sdkOutputPath
|
||||
copy (Join-Path $sdkPath "External\newtonsoft\9.0.1\*.dll") $sdkOutputPath
|
||||
copy (Join-Path $sdkPath "Source\api") $sdkOutputPath -Exclude *.csproj -recurse -force
|
||||
}
|
|
@ -1 +1 @@
|
|||
Subproject commit 6dc459ba72a08f8f5bf9dc9fffe7ab567d35b5af
|
||||
Subproject commit 5392994db64c387df5bfd8232bd5010d5f1734bb
|
|
@ -5,11 +5,11 @@ EditorBuildSettings:
|
|||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Scenes:
|
||||
- enabled: 0
|
||||
path: Assets/Scenes/Main.unity
|
||||
- enabled: 1
|
||||
path: Assets/Xbox Live/Samples/Leaderboard.unity
|
||||
path: Assets/Scenes/Main.unity
|
||||
- enabled: 0
|
||||
path: Assets/Xbox Live/Samples/UpdateStat.unity
|
||||
path: Assets/Xbox Live/Examples/Leaderboard.unity
|
||||
- enabled: 0
|
||||
path: Assets/Xbox Live/Examples/UpdateStat.unity
|
||||
- enabled: 0
|
||||
path: Assets/Scenes/Demo.unity
|
||||
|
|
|
@ -393,7 +393,7 @@ PlayerSettings:
|
|||
metroCertificatePassword:
|
||||
metroCertificateSubject: Microsoft
|
||||
metroCertificateIssuer: Microsoft
|
||||
metroCertificateNotAfter: 005492a712a3d301
|
||||
metroCertificateNotAfter: 802a2c7703a7d301
|
||||
metroApplicationDescription: sdk.unityplugin
|
||||
wsaImages: {}
|
||||
metroTileShortName:
|
||||
|
|
35
README.md
35
README.md
|
@ -8,44 +8,51 @@ The Unity Plugin is broken into the following parts
|
|||
|
||||
* __Assets__ contains the Unity project content.
|
||||
* __Xbox Live__ contains the actual plugin assets that are included in the published `.unitypackage`.
|
||||
* __Editor__ contains scripts that provide the basic Unity configuration UI and processes the projects during build.
|
||||
* __Examples__ contains a set of simple scene files that show how to use the various prefabs and connect them together.
|
||||
* __Images__ is a small set of images that are used by the prefabs.
|
||||
* __Libs__ is where the Xbox Live libraries will be stored. This will only contain `.meta` files when you initially clone the repository. You must [build the SDK](#Getting_Started) to pull those files in.
|
||||
* __Prefabs__ contains various Unity prefab objects that implement Xbox Live functionality. See [the prefabs documentation](prefabs.md) for more information.
|
||||
* __Scripts__ contains all of the code files that actually call the Xbox Live APIs from the prefabs. This is a great place to look for examples about how to properly call the Xbox Live APIs. See [the scripts documentation](scripts.md) for more detail.
|
||||
* __Tools/AssociationWizard__ contains the Xbox Live Association Wizard, used to pull down application configuration from DevCenter for use within Unity.
|
||||
|
||||
* __Build__ contains scripts to generate the .unitypackage and handle other project setup tasks.
|
||||
* __External__ contains additional resources used by the plugin
|
||||
* [__xbox-live-api-csharp__](https://github.com/Microsoft/xbox-live-api-csharp) is a submodule where the Xbox Live SDK comes from. You can choose to build the SDK from this sub-module or pull existing binaries down from NuGet.
|
||||
* [__xbox-live-api-csharp__](https://github.com/Microsoft/xbox-live-api-csharp) is a submodule where the Xbox Live API comes from. You can choose to build the SDK from this sub-module or directly from the repository.
|
||||
|
||||
* __ProjectSettings__ contains standard Unity project settings files.
|
||||
|
||||
## Getting Started
|
||||
If you're just looking to integrate Xbox Live functionality into your Unity game, you can download the [Unity Plugin in the Unity Asset Store](https://https://www.assetstore.unity3d.com/#!/content/TODO). If you want to make changes or you need to debug something, you can do so directly from source.
|
||||
If you're just looking to integrate Xbox Live functionality into your Unity game, you can [download the latest UnityPackage from Releases](./releases/latest). If you want to make changes or you need to debug something, you can do so directly from this source.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
* Visual Studio 2015
|
||||
* Powershell 3.0
|
||||
* [Windows 10](https://microsoft.com/windows) Anniversary Update
|
||||
* [Unity 5.5](https://unity3d.com)
|
||||
* Currently 5.5 is the minimum supported version, but we are looking into supporting some earlier versions in the future.
|
||||
* [Visual Studio 2015](https://www.visualstudio.com/)
|
||||
* Any version of Visual Studio should work for this including Community Edition.
|
||||
* Make sure to select everything under **Universal Windowsn App Development Tools** when installing. You can modify the installation to include these features for an existing installation as well.
|
||||
* [Powershell](https://microsoft.com/powershell)
|
||||
* If you've never used powershell before make sure that you have [enabled powershell scripts to run](https://technet.microsoft.com/en-us/library/ee176961.aspx).
|
||||
|
||||
### Building
|
||||
|
||||
1. Open up a powershell window.
|
||||
2. Clone the project, and be sure to include and sync all the required submodules.
|
||||
|
||||
```
|
||||
```powershell
|
||||
git clone https://github.com/Microsoft/xbox-live-unity-plugin --recursive
|
||||
cd xbox-live-unity-plugin
|
||||
```
|
||||
3. Run the Setup script to get all of the pre-requisites built and configured.
|
||||
3. Run the Setup powershell script to get all of the pre-requisites built and configured.
|
||||
|
||||
```
|
||||
```powershell
|
||||
.\Build\Setup.ps1
|
||||
```
|
||||
|
||||
|
||||
4. If you want to make any modifications to the scripts or prefabs in the package, open up the project (the `xbox-live-unity-plugin` folder) in Unity and make your changes.
|
||||
|
||||
If `Unity.exe` is accessible from your command line, you can launch the project directly using.
|
||||
|
||||
```
|
||||
Unity.exe -projectPath .\
|
||||
```
|
||||
|
||||
5. Generate the `XboxLive.unitypackage` that you can import into any other project:
|
||||
|
||||
```
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
# Xbox Live Prefabs
|
||||
|
||||
There are a number of different [Unity Prefabs](https://docs.unity3d.com/Manual/Prefabs.html) provided with the Xbox Live Unity plugin that can help you quickly integrate Xbox Live functionality into your game while at the same time providing a good example about how to call the Xbox Live APIs yourself.
|
||||
|
||||
## UserProfile
|
||||
|
||||
The `UserProfile` prefab is the most important Xbox Live prefab. This prefab allows the user to login to Xbox Live and after the user is logged it, it will show their Gamertag, Gamer Picture, and Gamerscore. Usually you would show this prefab on the initial menu screen, or automatically trigger it when the game launches. In order to use any of the other Xbox Live prefabs, you must include a UserProfile prefab or manually invoke the sign-in API. See the `UserProfile.cs` script for details on how
|
||||
|
||||
## Leaderboard
|
||||
|
||||
The `Leaderboard` prefab provides a quick easy way to render a Leaderboard in your game. After dropping the prefab into your project set the following properties to configure it:
|
||||
|
||||
* **`LeaderboardName`** - the name of the leaderboard or the stat to render.
|
||||
* **`SocialGroup`** - *(Optional)* the social group of the leaderboard. If `None` is provided, a non-social leaderboard (i.e. a global leaderboard) will be rendered.
|
||||
* **`DisplayName`** - the value to use as the header text for the leaderboard.
|
||||
* **`EntryCount`** - The maximum number of entries to display on a single page of the leaderboard. **Default:** 10
|
||||
|
||||
### LeaderboardEntry
|
||||
|
||||
This is a helper prefab that's used to render a single row of a Leaderboard. You you can modify this prefab to customize the look and feel of leaderboard rows.
|
||||
|
||||
## Stats
|
||||
|
||||
There are a few different prefabs that work well together to interact with the Stats system.
|
||||
|
||||
### Stat Prefabs
|
||||
|
||||
In most cases it makes sense to maintain your own "user stats" object to hold the current values of all of the significant stats for a users but there are a few scenarios where it might be easier to expose one or more stats as objects within the Unity scene to allow easy binding.
|
||||
|
||||
We provide `IntegerStat`, `DoubleStat`, and `StringStat` prefabs for this purpose, each of which has it's own corresponding script (e.g. `IntegerStat.cs`). These have a few common properties that are shared across all three.
|
||||
|
||||
* **`Name`** - the name of the stat you want it to map to
|
||||
* **`DisplayName`** - a friendly name for the stat that will be used if it's displayed anywhere in the game (i.e. with a `StatPanel`).
|
||||
* **`Value`** - sets the initial value of the stat. This will *overwrite* any existing value on the service unless you specify `UseInitialValueFromService`.
|
||||
* **`UseInitialValueFromService`** - indicates that the stat should wait until all existing stat values are retrieved from the service before modifying the value.
|
||||
|
||||
In addition to a `SetValue` method, some of the components have extra helper methods to modify stat values. For example, `IntegerStat.Increment()` can be used to easily increment a stat value and with a `Stat` Unity object, you can bind a call to this method to [UnityEvent](https://docs.unity3d.com/ScriptReference/Events.UnityEvent.html) such as the `OnClick` event exposed by the [Button component](https://docs.unity3d.com/Manual/UIInteractionComponents.html).
|
||||
|
||||
### StatPanel Prefab
|
||||
|
||||
The `StatPanel` prefab provides an easy way to render the value of a `Stat`. You can bind this to a `Stat` object in Unity and any changes will be rendered automatically.
|
|
@ -0,0 +1,18 @@
|
|||
# Xbox Live Unity Scripts
|
||||
|
||||
The Xbox Live Unity plugin provides a bunch of [Unity Scripts](https://docs.unity3d.com/Manual/CreatingAndUsingScripts.html) to wrap Xbox Live APIs and make them easier to use from within Unity. Most of the scripts are directly attached to [various prefabs](./prefabs.md) but nearly all of it could easily be pulled out and used directly. A few more important scripts whos utility may not be immediately obvious are described below.
|
||||
|
||||
## `XboxLive` script
|
||||
|
||||
Most Xbox Live functionality in Unity is managed by the `XboxLive` script. This object is automatically instantiated in your scene when you use any Xbox Live functionality and marked as `DontDestryOnLoad` so that it lives for the entire duration of the game.
|
||||
|
||||
Any of your scripts that need to make calls to Xbox Live APIs should use the various properties `XboxLive.Instance`.
|
||||
|
||||
* **`Context`** provides the main entry point into many Xbox Live services and will be initialized after a user has been Authenticated using `SignInAsync()`. See the [Xbox Live API documentation](http://github.com/Microsoft/xbox-live-api-csharp) for details.
|
||||
* **`User`** provides a reference to the currently authenticated user which can be used when making calls to various services.
|
||||
|
||||
## `UnityTaskExtensions` script
|
||||
|
||||
Although Unity doesn't yet support .NET `Task` (along with async/await), the SDK is shared among different platforms including UWP which does. In order to properly support tasks, we include `Unity.Compat.dll` and `Unity.Tasks.dll` libraries which include barebones `Task` implementations for Unity (from the [Parse SDK for .NET](https://github.com/ParsePlatform/Parse-SDK-dotNET). The `UnityTaskExtensions` script provides some additional helper functions to make it easier to use tasks inside along side [Unity Coroutines](https://docs.unity3d.com/Manual/Coroutines.html).
|
||||
|
||||
The `.AsCoroutine()` extension method converts a `Task` into an `IEnumerable` which can be yielded from a coroutine.
|
Загрузка…
Ссылка в новой задаче