Skip to content

Commit

Permalink
Update auth URL, add explicit sign in button, and fix field focus issue
Browse files Browse the repository at this point in the history
Fixes #4
  • Loading branch information
caseypugh committed Jan 5, 2018
1 parent 3d9f8a4 commit fb9f2ac
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 37 deletions.
8 changes: 4 additions & 4 deletions Assets/Vimeo/Scenes/360Player.unity
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ RenderSettings:
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
serializedVersion: 9
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
Expand All @@ -54,7 +54,7 @@ LightmapSettings:
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_LightmapEditorSettings:
serializedVersion: 9
serializedVersion: 8
m_Resolution: 2
m_BakeResolution: 40
m_TextureWidth: 1024
Expand Down Expand Up @@ -87,7 +87,7 @@ LightmapSettings:
m_PVRFilteringAtrousNormalSigma: 1
m_PVRFilteringAtrousPositionSigma: 1
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
m_ShadowMaskMode: 2
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
Expand Down Expand Up @@ -160,7 +160,7 @@ Prefab:
- target: {fileID: 114151494372987810, guid: 54f1b0e92fb3a604a9c1edae4d8c74c1,
type: 2}
propertyPath: saveVimeoToken
value: 0
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 54f1b0e92fb3a604a9c1edae4d8c74c1, type: 2}
Expand Down
11 changes: 8 additions & 3 deletions Assets/Vimeo/Scenes/CanvasPlayer.unity
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ RenderSettings:
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
serializedVersion: 9
m_GIWorkflowMode: 0
m_GISettings:
serializedVersion: 2
Expand All @@ -54,7 +54,7 @@ LightmapSettings:
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_LightmapEditorSettings:
serializedVersion: 9
serializedVersion: 8
m_Resolution: 2
m_BakeResolution: 40
m_TextureWidth: 1024
Expand Down Expand Up @@ -87,7 +87,7 @@ LightmapSettings:
m_PVRFilteringAtrousNormalSigma: 1
m_PVRFilteringAtrousPositionSigma: 1
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
m_ShadowMaskMode: 2
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
Expand Down Expand Up @@ -245,6 +245,11 @@ Prefab:
propertyPath: m_SizeDelta.y
value: -100
objectReference: {fileID: 0}
- target: {fileID: 114708236403802286, guid: 9ba9537c00e62a34bbb9071dfed6399d,
type: 2}
propertyPath: saveVimeoToken
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 9ba9537c00e62a34bbb9071dfed6399d, type: 2}
m_IsPrefabParent: 0
Expand Down
21 changes: 18 additions & 3 deletions Assets/Vimeo/Scenes/Player.unity
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ RenderSettings:
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
serializedVersion: 9
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
Expand All @@ -54,7 +54,7 @@ LightmapSettings:
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_LightmapEditorSettings:
serializedVersion: 9
serializedVersion: 8
m_Resolution: 2
m_BakeResolution: 40
m_TextureWidth: 1024
Expand Down Expand Up @@ -87,7 +87,7 @@ LightmapSettings:
m_PVRFilteringAtrousNormalSigma: 1
m_PVRFilteringAtrousPositionSigma: 1
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
m_ShadowMaskMode: 2
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
Expand Down Expand Up @@ -301,6 +301,21 @@ Prefab:
propertyPath: m_RootOrder
value: 3
objectReference: {fileID: 0}
- target: {fileID: 114529228338408296, guid: f54a9bafa49ec444098b519b1e4771c4,
type: 2}
propertyPath: saveVimeoToken
value: 1
objectReference: {fileID: 0}
- target: {fileID: 114529228338408296, guid: f54a9bafa49ec444098b519b1e4771c4,
type: 2}
propertyPath: vimeoToken
value:
objectReference: {fileID: 0}
- target: {fileID: 114529228338408296, guid: f54a9bafa49ec444098b519b1e4771c4,
type: 2}
propertyPath: vimeoSignIn
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: f54a9bafa49ec444098b519b1e4771c4, type: 2}
m_IsPrefabParent: 0
Expand Down
36 changes: 24 additions & 12 deletions Assets/Vimeo/Scripts/Config/VimeoConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public bool Authenticated(string token)
return token != "" && token != null;
}

public void DrawVimeoConfig (VimeoPlayer player)
public void DrawVimeoConfig(VimeoPlayer player)
{
var so = serializedObject;

if (Authenticated(player.GetVimeoToken())) {
if (Authenticated(player.GetVimeoToken()) && player.vimeoSignIn) {
EditorGUILayout.PropertyField(so.FindProperty("videoScreen"));
EditorGUILayout.PropertyField(so.FindProperty("audioSource"));
EditorGUILayout.PropertyField(so.FindProperty("vimeoVideoId"), new GUIContent("Vimeo Video URL"));
Expand All @@ -30,27 +30,40 @@ public void DrawVimeoConfig (VimeoPlayer player)
EditorGUILayout.Space();
}

DrawVimeoAuth(player.GetVimeoToken());

DrawVimeoAuth(player);
so.ApplyModifiedProperties();
}

public void DrawVimeoAuth(string _token)
public void DrawVimeoAuth(VimeoPlayer player)
{
var so = serializedObject;
if (!Authenticated(_token)) {
EditorGUILayout.PropertyField(so.FindProperty("vimeoToken"));

if (!Authenticated(player.GetVimeoToken()) || !player.vimeoSignIn) {
EditorGUILayout.PropertyField(so.FindProperty("vimeoToken"));
EditorGUILayout.PropertyField(so.FindProperty("saveVimeoToken"), new GUIContent("Save token with scene"));

GUILayout.BeginHorizontal("box");
if (GUILayout.Button("Get Token", GUILayout.Height(30))) {
Application.OpenURL("https://vimeo-authy.herokuapp.com/auth/vimeo/unity?scope=public%20private%20video_files");
}

GUI.backgroundColor = Color.green;
if (GUILayout.Button("Sign into Vimeo", GUILayout.Height(30))) {
Application.OpenURL ("https://vimeo-authy.herokuapp.com/auth/vimeo/unity?scope=public%20private");
if (Authenticated(player.vimeoToken)) {
if (GUILayout.Button("Sign into Vimeo", GUILayout.Height(30))) {
(target as VimeoPlayer).SetVimeoToken(player.vimeoToken);
player.vimeoSignIn = true;
GUI.FocusControl(null);
}
}

GUILayout.EndHorizontal();
}
else {
EditorGUILayout.PropertyField(so.FindProperty("saveVimeoToken"), new GUIContent("Save token with scene"));


GUI.backgroundColor = Color.red;
if (GUILayout.Button("Switch accounts")) {
player.vimeoSignIn = false;

if (target.GetType().ToString() == "Vimeo.VimeoPublisher") {
#if UNITY_2017_3_OR_NEWER
(target as VimeoPublisher).SetVimeoToken(null);
Expand Down Expand Up @@ -106,7 +119,6 @@ public void DrawSlackAuth(string _token)
}
}
}


public void DrawSlackConfig(VimeoPublisher publisher)
{
Expand Down
25 changes: 10 additions & 15 deletions Assets/Vimeo/Scripts/VimeoPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public class VimeoPlayer : MonoBehaviour
public GameObject videoScreen;
public GameObject audioSource;
public string vimeoToken;
public bool saveVimeoToken = false;
public bool saveVimeoToken = true;
public bool vimeoSignIn = false;
public string vimeoVideoId;

public string[] videoQualities = new [] { "Highest", "1080", "720", "540", "480", "360" };
Expand Down Expand Up @@ -108,29 +109,23 @@ private void Start()

public string GetVimeoToken()
{
var token = PlayerPrefs.GetString("vimeo-player-token");
if (token == null || token == "") {
if (vimeoToken != null && vimeoToken != "") {
SetVimeoToken(vimeoToken);
}
token = vimeoToken;
}

if (saveVimeoToken) {
vimeoToken = token;
return vimeoToken;
}
else {
vimeoToken = null;
return PlayerPrefs.GetString("vimeo-player-token");
}
return token;
}

public void SetVimeoToken(string token)
{
SetKey("vimeo-player-token", token);

if (token == null) {
if (saveVimeoToken) {
SetKey("vimeo-player-token", null);
vimeoToken = token;
}
else {
vimeoToken = null;
SetKey("vimeo-player-token", token);
}
}

Expand Down

0 comments on commit fb9f2ac

Please sign in to comment.