Skip to content

Commit 6ebf7f3

Browse files
JordiFBfacebook-github-bot
authored andcommitted
{sla warn.} [EXTERNAL BUG] Facebook Unity SDK not compatible with the new Unity Input System
Summary: Removed auto creation of the old Event System object, if the scene doesn't have it. Also, added a warning message about the input system used by the example. Unity 2019 and above have a new input system completely different from the old one. Our UnitySDK example uses the old one. To fix that I made the following changes: * created the EventSystem inside the Main Menu scene * removed automatic creation of event system in code * added a warning to explain the developer how to use our example in unity. NOTE: I fixed some scenes background color too. Reviewed By: zenlita Differential Revision: D37746695 fbshipit-source-id: ed698f29cbcbedea92d1721743092621b4c9a10b
1 parent 1008603 commit 6ebf7f3

File tree

5 files changed

+122
-38
lines changed

5 files changed

+122
-38
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [14.1.0]
9+
10+
### Fixed
11+
- Issue with new Unity Input System and UnitySDK Example
12+
813
## [14.0.0]
914

1015
### Added

Facebook.Unity/Codeless/CodelessUIInteractEvent.cs

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1919
*/
2020

21-
using System;
21+
using System;
2222
using System.Collections;
2323
using System.Collections.Generic;
2424
using UnityEngine;
@@ -32,15 +32,17 @@ public class CodelessUIInteractEvent : MonoBehaviour
3232
{
3333

3434
private FBSDKEventBindingManager eventBindingManager { get; set; }
35+
private Boolean isOldEventSystem { get; set; }
3536

3637
void Awake ()
3738
{
39+
Debug.LogWarning("This example uses Unity Engine OLD input system. If you are using new Input System and you want to use this example, please set your input configuration to BOTH.");
40+
3841
EventSystem sceneEventSystem = FindObjectOfType<EventSystem> ();
39-
if (sceneEventSystem == null) {
40-
GameObject eventSystem = new GameObject ("EventSystem");
41-
eventSystem.AddComponent<EventSystem> ();
42-
eventSystem.AddComponent<StandaloneInputModule> ();
43-
DontDestroyOnLoad (eventSystem);
42+
isOldEventSystem = !(sceneEventSystem == null);
43+
if (isOldEventSystem)
44+
{
45+
DontDestroyOnLoad(sceneEventSystem);
4446
}
4547
switch (Constants.CurrentPlatform) {
4648
case FacebookUnityPlatform.Android:
@@ -68,37 +70,50 @@ private static void SetLoggerInitIos ()
6870
// Update is called once per frame
6971
void Update ()
7072
{
71-
if (Input.GetMouseButtonDown (0) || (Input.touchCount > 0 && Input.GetTouch (0).phase == TouchPhase.Began)) {
72-
try {
73-
if (EventSystem.current.IsPointerOverGameObject () ||
74-
(Input.touchCount > 0 && EventSystem.current.IsPointerOverGameObject (Input.touches [0].fingerId))
75-
) {
76-
if (null != EventSystem.current.currentSelectedGameObject) {
77-
string name = EventSystem.current.currentSelectedGameObject.name;
78-
GameObject go = EventSystem.current.currentSelectedGameObject;
79-
if (null != go.GetComponent<UnityEngine.UI.Button> () &&
80-
null != eventBindingManager) {
73+
if (isOldEventSystem)
74+
{
75+
if (Input.GetMouseButtonDown(0) || (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began))
76+
{
77+
try
78+
{
79+
if (EventSystem.current.IsPointerOverGameObject() ||
80+
(Input.touchCount > 0 && EventSystem.current.IsPointerOverGameObject(Input.touches[0].fingerId))
81+
)
82+
{
83+
if (null != EventSystem.current.currentSelectedGameObject)
84+
{
85+
string name = EventSystem.current.currentSelectedGameObject.name;
86+
GameObject go = EventSystem.current.currentSelectedGameObject;
87+
if (null != go.GetComponent<UnityEngine.UI.Button>() &&
88+
null != eventBindingManager)
89+
{
8190

82-
var eventBindings = eventBindingManager.eventBindings;
83-
FBSDKEventBinding matchedBinding = null;
84-
if (null != eventBindings) {
85-
foreach(var eventBinding in eventBindings) {
86-
if (FBSDKViewHiearchy.CheckGameObjectMatchPath(go, eventBinding.path)) {
87-
matchedBinding = eventBinding;
88-
break;
89-
}
90-
}
91-
}
91+
var eventBindings = eventBindingManager.eventBindings;
92+
FBSDKEventBinding matchedBinding = null;
93+
if (null != eventBindings)
94+
{
95+
foreach (var eventBinding in eventBindings)
96+
{
97+
if (FBSDKViewHiearchy.CheckGameObjectMatchPath(go, eventBinding.path))
98+
{
99+
matchedBinding = eventBinding;
100+
break;
101+
}
102+
}
103+
}
92104

93-
if (null != matchedBinding) {
94-
FB.LogAppEvent(matchedBinding.eventName);
105+
if (null != matchedBinding)
106+
{
107+
FB.LogAppEvent(matchedBinding.eventName);
108+
}
95109
}
96110
}
97111
}
98112
}
99-
}
100-
catch (Exception) {
101-
return;
113+
catch (Exception)
114+
{
115+
return;
116+
}
102117
}
103118
}
104119
}

UnitySDK/Assets/FacebookSDK/Examples/MainMenu.unity

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,69 @@ MonoBehaviour:
256256
m_Script: {fileID: 11500000, guid: 922e3ad8d88a146b3b392cd8c84edd6a, type: 3}
257257
m_Name:
258258
m_EditorClassIdentifier:
259+
--- !u!1 &2113301448
260+
GameObject:
261+
m_ObjectHideFlags: 0
262+
m_CorrespondingSourceObject: {fileID: 0}
263+
m_PrefabInstance: {fileID: 0}
264+
m_PrefabAsset: {fileID: 0}
265+
serializedVersion: 6
266+
m_Component:
267+
- component: {fileID: 2113301451}
268+
- component: {fileID: 2113301450}
269+
- component: {fileID: 2113301449}
270+
m_Layer: 0
271+
m_Name: EventSystem
272+
m_TagString: Untagged
273+
m_Icon: {fileID: 0}
274+
m_NavMeshLayer: 0
275+
m_StaticEditorFlags: 0
276+
m_IsActive: 1
277+
--- !u!114 &2113301449
278+
MonoBehaviour:
279+
m_ObjectHideFlags: 0
280+
m_CorrespondingSourceObject: {fileID: 0}
281+
m_PrefabInstance: {fileID: 0}
282+
m_PrefabAsset: {fileID: 0}
283+
m_GameObject: {fileID: 2113301448}
284+
m_Enabled: 1
285+
m_EditorHideFlags: 0
286+
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
287+
m_Name:
288+
m_EditorClassIdentifier:
289+
m_HorizontalAxis: Horizontal
290+
m_VerticalAxis: Vertical
291+
m_SubmitButton: Submit
292+
m_CancelButton: Cancel
293+
m_InputActionsPerSecond: 10
294+
m_RepeatDelay: 0.5
295+
m_ForceModuleActive: 0
296+
--- !u!114 &2113301450
297+
MonoBehaviour:
298+
m_ObjectHideFlags: 0
299+
m_CorrespondingSourceObject: {fileID: 0}
300+
m_PrefabInstance: {fileID: 0}
301+
m_PrefabAsset: {fileID: 0}
302+
m_GameObject: {fileID: 2113301448}
303+
m_Enabled: 1
304+
m_EditorHideFlags: 0
305+
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
306+
m_Name:
307+
m_EditorClassIdentifier:
308+
m_FirstSelected: {fileID: 0}
309+
m_sendNavigationEvents: 1
310+
m_DragThreshold: 10
311+
--- !u!4 &2113301451
312+
Transform:
313+
m_ObjectHideFlags: 0
314+
m_CorrespondingSourceObject: {fileID: 0}
315+
m_PrefabInstance: {fileID: 0}
316+
m_PrefabAsset: {fileID: 0}
317+
m_GameObject: {fileID: 2113301448}
318+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
319+
m_LocalPosition: {x: 0, y: 0, z: 0}
320+
m_LocalScale: {x: 1, y: 1, z: 1}
321+
m_Children: []
322+
m_Father: {fileID: 0}
323+
m_RootOrder: 2
324+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

UnitySDK/Assets/FacebookSDK/Examples/TournamentsMenu.unity

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ RenderSettings:
3838
m_ReflectionIntensity: 1
3939
m_CustomReflection: {fileID: 0}
4040
m_Sun: {fileID: 0}
41-
m_IndirectSpecularColor: {r: 0.3731193, g: 0.38073996, b: 0.35872698, a: 1}
41+
m_IndirectSpecularColor: {r: 0.3731316, g: 0.38074902, b: 0.3587254, a: 1}
4242
m_UseRadianceAmbientProbe: 0
4343
--- !u!157 &3
4444
LightmapSettings:
4545
m_ObjectHideFlags: 0
46-
serializedVersion: 12
46+
serializedVersion: 11
4747
m_GIWorkflowMode: 1
4848
m_GISettings:
4949
serializedVersion: 2
@@ -98,7 +98,7 @@ LightmapSettings:
9898
m_TrainingDataDestination: TrainingData
9999
m_LightProbeSampleCountMultiplier: 4
100100
m_LightingDataAsset: {fileID: 0}
101-
m_LightingSettings: {fileID: 0}
101+
m_UseShadowmask: 1
102102
--- !u!196 &4
103103
NavMeshSettings:
104104
serializedVersion: 2
@@ -118,8 +118,6 @@ NavMeshSettings:
118118
manualTileSize: 0
119119
tileSize: 256
120120
accuratePlacement: 0
121-
maxJobWorkers: 0
122-
preserveTilesOutsideBounds: 0
123121
debug:
124122
m_Flags: 0
125123
m_NavMeshData: {fileID: 0}
@@ -158,7 +156,7 @@ Camera:
158156
m_GameObject: {fileID: 1312537528}
159157
m_Enabled: 1
160158
serializedVersion: 2
161-
m_ClearFlags: 1
159+
m_ClearFlags: 2
162160
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
163161
m_projectionMatrixMode: 1
164162
m_GateFitMode: 2

UnitySDK/Assets/FacebookSDK/Examples/UploadToMediaLibrary.unity

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Camera:
157157
m_Enabled: 1
158158
serializedVersion: 2
159159
m_ClearFlags: 2
160-
m_BackGroundColor: {r: 0.19215688, g: 0.4745098, b: 0.4593359, a: 0}
160+
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
161161
m_projectionMatrixMode: 1
162162
m_GateFitMode: 2
163163
m_FOVAxisMode: 0

0 commit comments

Comments
 (0)