Skip to content

Commit

Permalink
Upgrade to 2021.3 (#73)
Browse files Browse the repository at this point in the history
* Bump Version

* Removed 2020.3 code

* Reverted behavior of LinkGameView (Disable on play) + Update button FB

* Updated Graphic Elements

* Updated Readme
  • Loading branch information
peeweek authored Jun 26, 2022
1 parent 5f99b88 commit 6c27a69
Show file tree
Hide file tree
Showing 15 changed files with 221 additions and 328 deletions.
Binary file added Documentation~/Images/bg-source3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions Documentation~/Images/bg-source3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Photo by Andy Chilton on Unsplash
https://unsplash.com/photos/0JFveX0c778
Binary file modified Documentation~/Images/site-banner.afphoto
Binary file not shown.
Binary file modified Documentation~/Images/site-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Documentation~/Images/wizard-banner.afphoto
Binary file not shown.
Binary file modified Documentation~/Images/wizard-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Editor/GameViewLink/LinkGameView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static void OnPlayModeChanged(PlayModeStateChange state)
// Reset State when entering editmode or play mode
if(state == PlayModeStateChange.EnteredEditMode || state == PlayModeStateChange.EnteredPlayMode)
{
if (Active)
if (Active && !Application.isPlaying)
Active = true;
else
Active = false;
Expand Down
10 changes: 9 additions & 1 deletion Editor/SceneViewToolbar/SceneViewToolbar.Overlays.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,15 @@ public LinkGameViewButton()
SetValueWithoutNotify(LinkGameView.Active && LinkGameView.LockedSceneView == containerWindow as SceneView);

buttons.Add(this);

EditorApplication.playModeStateChanged += EditorApplication_playModeStateChanged;
UpdateIcon();

}

private void EditorApplication_playModeStateChanged(PlayModeStateChange obj)
{
if(obj == PlayModeStateChange.EnteredPlayMode || obj == PlayModeStateChange.EnteredEditMode)
UpdateIcon();
}

~LinkGameViewButton()
Expand Down Expand Up @@ -290,6 +297,7 @@ static Contents()
public class IngredientsCustomToolbarOverlay : Overlay, IAccessContainerWindow
{
EditorWindow IAccessContainerWindow.containerWindow { get; set; }

SceneView sceneView => containerWindow as SceneView;

protected override Layout supportedLayouts => Layout.HorizontalToolbar;
Expand Down
314 changes: 1 addition & 313 deletions Editor/SceneViewToolbar/SceneViewToolbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,319 +8,7 @@ namespace GameplayIngredients.Editor
{
public static partial class SceneViewToolbar
{

#if !UNITY_2021_2_OR_NEWER

[InitializeOnLoadMethod]
static void Initialize()
{

SceneView.duringSceneGui += OnSceneGUI;

}

private static void OnSceneGUI(SceneView sceneView)
{
if (!Preferences.showToolbar)
return;

var r = new Rect(Vector2.zero, new Vector2(sceneView.position.width,24));
Handles.BeginGUI();
using (new GUILayout.AreaScope(r))
{
using (new GUILayout.HorizontalScope(EditorStyles.toolbar))
{

if(Preferences.showPlayFromHere)
{
using(new EditorGUI.DisabledGroupScope(!PlayFromHere.IsReady))
{
bool play = GUILayout.Toggle(EditorApplication.isPlaying, Contents.playFromHere, EditorStyles.toolbarButton);

if (GUI.changed)
{
if (play)
PlayFromHere.Play(sceneView);
else
EditorApplication.isPlaying = false;
}

}
GUILayout.Space(24);
}

if(Preferences.showLinkGameView)
{

Color backup = GUI.color;

bool isLinked = LinkGameView.Active;
bool isLocked = LinkGameView.LockedSceneView == sceneView;


if (isLinked && isLocked)
{
GUI.color = Styles.lockedLinkColor * 2;
}
else if (isLinked && LinkGameView.CinemachineActive)
{
GUI.color = Styles.cineColor * 2;
}

isLinked = GUILayout.Toggle(isLinked, LinkGameView.CinemachineActive ? Contents.linkGameViewCinemachine : Contents.linkGameView, EditorStyles.toolbarButton, GUILayout.Width(64));

if (GUI.changed)
{
if (Event.current.shift)
{
if (!LinkGameView.Active)
LinkGameView.Active = true;

LinkGameView.CinemachineActive = !LinkGameView.CinemachineActive;
}
else
{
LinkGameView.Active = isLinked;
LinkGameView.CinemachineActive = false;
}
}

isLocked = GUILayout.Toggle(isLocked, Contents.lockLinkGameView, EditorStyles.toolbarButton);

if (GUI.changed)
{
if (isLocked)
{
LinkGameView.CinemachineActive = false;
LinkGameView.LockedSceneView = sceneView;
}
else
{
LinkGameView.LockedSceneView = null;
}
}

GUI.color = backup;
GUILayout.Space(16);
}

if(Preferences.showPOV)
{
if (GUILayout.Button("POV", EditorStyles.toolbarDropDown))
{
Rect btnrect = GUILayoutUtility.GetLastRect();
btnrect.yMax += 17;
SceneViewPOV.ShowPopup(btnrect, sceneView);
}
GUILayout.Space(16);
}

if(Preferences.showCheck)
{
if (GUILayout.Button(Contents.checkWindow, EditorStyles.toolbarButton))
{
EditorWindow.GetWindow<CheckWindow>();
}
GUILayout.Space(16);
}

if(Preferences.showComments)
{
if (GUILayout.Button(Contents.commentsWindow, EditorStyles.toolbarButton))
{
CommentsWindow.Open();
}
if (GUILayout.Button(Contents.addComment, EditorStyles.toolbarButton))
{
SceneCommentEditor.CreateComment();
}
}

if(Preferences.showCustom)
{
// Custom Callback here
if (OnSceneViewToolbarGUI != null)
OnSceneViewToolbarGUI.Invoke(sceneView);
}

GUILayout.FlexibleSpace();
// Saving Space not to overlap view controls
GUILayout.Space(96);
}
}

if (LinkGameView.CinemachineActive)
{
DisplayText("CINEMACHINE PREVIEW", Styles.cineColor);
}
else if (LinkGameView.Active)
{
if (LinkGameView.LockedSceneView == sceneView)
{
DisplayText("GAME VIEW LINKED (LOCKED)", Styles.lockedLinkColor);
}
else if(LinkGameView.LockedSceneView == null && SceneView.lastActiveSceneView == sceneView)
{
DisplayText("GAME VIEW LINKED", Color.white);
}
}

Handles.EndGUI();
}

static void DisplayText(string text, Color color)
{
Rect r = new Rect(16, 24, 512, 32);
GUI.color = Color.black;
GUI.Label(r, text);
r.x--;
r.y--;
GUI.color = color;
GUI.Label(r, text);
GUI.color = Color.white;
}

static class Preferences
{
// Public Getters
public static bool showToolbar => Get(kShowToolbar);
public static bool showPlayFromHere => Get(kShowPlayFromHere);
public static bool showLinkGameView => Get(kShowLinkGameView);
public static bool showPOV => Get(kShowPOV);
public static bool showCheck => Get(kShowCheck);
public static bool showComments => Get(kShowComments);
public static bool showCustom => Get(kShowCustom);

const string kShowToolbar = "showToolbar";
const string kShowPlayFromHere = "showPlayFromHere";
const string kShowLinkGameView = "showLinkGameView";
const string kShowPOV = "showPOV";
const string kShowCheck = "showCheck";
const string kShowComments = "showComments";
const string kShowCustom = "showCustom";

const string kPrefPrefix = "GameplayIngredients.SceneViewToolbar";
static readonly Dictionary<string, bool> defaults = new Dictionary<string, bool>
{
{ kShowToolbar , true },
{ kShowPlayFromHere , true },
{ kShowLinkGameView , true },
{ kShowPOV , true },
{ kShowCheck , true },
{ kShowComments , true },
{ kShowCustom , true },
};

static bool Default(string name)
{
if (defaults.ContainsKey(name))
return defaults[name];
else
return false;
}

static bool Get(string name)
{
return EditorPrefs.GetBool($"{kPrefPrefix}.{name}", Default(name));
}

static void Set(string name, bool value)
{
EditorPrefs.SetBool($"{kPrefPrefix}.{name}", value);
}

[SettingsProvider]
public static SettingsProvider GetPreferences()
{
static void OnToggleAll(bool toggle)
{
OnToggleLinkGameView(toggle);
}

static void OnToggleLinkGameView(bool toggle)
{
if (!toggle)
LinkGameView.Active = false;
}

static void PreferenceItem(string label, string name, Action<bool> onToggle = null)
{
EditorGUI.BeginChangeCheck();
bool val = EditorGUILayout.Toggle(label, Get(name));
if (EditorGUI.EndChangeCheck())
{
Set(name, val);
onToggle?.Invoke(val);
SceneView.RepaintAll();
}
};

return new SettingsProvider("Preferences/Gameplay Ingredients/Scene View", SettingsScope.User)
{
label = "Scene View",
guiHandler = (searchContext) =>
{
PreferenceItem("Show Toolbar", "showToolbar", OnToggleAll);
using (new EditorGUI.IndentLevelScope(1))
{
PreferenceItem("Play From Here", kShowPlayFromHere);
PreferenceItem("Link Game View", kShowLinkGameView, OnToggleLinkGameView);
PreferenceItem("Point of View", kShowPOV);
PreferenceItem("Check Window", kShowCheck);
PreferenceItem("Comments Window", kShowComments);
PreferenceItem("Custom Toolbar Items", kShowCustom);
}
}
};
}


}

static class Contents
{
public static GUIContent playFromHere;
public static GUIContent lockLinkGameView;
public static GUIContent linkGameView;
public static GUIContent linkGameViewCinemachine;
public static GUIContent checkWindow;
public static GUIContent commentsWindow;
public static GUIContent addComment;

static Contents()
{
lockLinkGameView = new GUIContent(EditorGUIUtility.IconContent("IN LockButton"));
linkGameView = new GUIContent(EditorGUIUtility.Load("Packages/net.peeweek.gameplay-ingredients/Icons/GUI/Camera16x16.png") as Texture);
linkGameView.text = " Game";

linkGameViewCinemachine = new GUIContent(EditorGUIUtility.Load("Packages/net.peeweek.gameplay-ingredients/Icons/GUI/Camera16x16.png") as Texture);
linkGameViewCinemachine.text = " Cine";

playFromHere = new GUIContent(EditorGUIUtility.IconContent("Animation.Play"));
playFromHere.text = "Here";

checkWindow = new GUIContent(EditorGUIUtility.IconContent("Valid"));
checkWindow.text = "Check";

commentsWindow = new GUIContent(EditorGUIUtility.IconContent("console.infoicon.inactive.sml"));
commentsWindow.text = "Comments";

addComment = new GUIContent("+");
}
}

static class Styles
{
public static GUIStyle toolbar;
public static Color lockedLinkColor = new Color(0.5f, 1.0f, 0.1f, 1.0f);
public static Color cineColor = new Color(1.0f, 0.5f, 0.1f, 1.0f);

static Styles()
{
toolbar = new GUIStyle(EditorStyles.inspectorFullWidthMargins);
}
}
#endif
// Relic of the past
}
}

Binary file modified Editor/WelcomeScreen/welcome-title.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ Gameplay Ingredients for your Unity Games - A collection of scripts that ease si

## Requirements

* **Unity 2020.2** (Older versions compatible with 2018.3 / 2019.1 / 2019.2 / 2019.3 / 2020.1)
* **Unity 2020.3** for latest version
* (Older releases are still compatible with 2018.3 / 2019.1 / 2019.2 / 2019.3 / 2020.3)

* (**Optional, for older versions or development** : Command-line Git installed on your system, for example [Git For Windows](https://gitforwindows.org/))

## How to install (2020.2 and Newer)
Expand Down Expand Up @@ -54,10 +56,11 @@ You can check that the package was imported by looking at the project window, un

Gameplay Ingredients comes at latest version with the following compatibility:

**Unity 2020.2 +** : choose the tag : ![openupm](https://img.shields.io/npm/v/net.peeweek.gameplay-ingredients?label=openupm&registry_uri=https://package.openupm.com)
**Unity 2021.3 +** : choose the tag : ![openupm](https://img.shields.io/npm/v/net.peeweek.gameplay-ingredients?label=openupm&registry_uri=https://package.openupm.com)

#### Older Versions

* **Unity 2018.3 / 2018.4 :** choose the tag `2018.3.0`
* **Unity 2019.1 / 2019.2 :** choose the tag `2019.1.2`
* **Unity 2019.3 / 2020.1** : choose the the tag `2019.3.7`
* **Unity 2020.3** : choose the the tag `2020.2.11`
Loading

0 comments on commit 6c27a69

Please sign in to comment.