Skip to content

Commit

Permalink
Added an option to prevent accidentally grabbing and moving the camer…
Browse files Browse the repository at this point in the history
…a quad.
  • Loading branch information
Snow committed Feb 11, 2021
1 parent 0fc53fb commit 88ca88e
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CameraPlus/CameraMoverPointer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected virtual void Update()

protected virtual void LateUpdate()
{
if (_grabbingController != null)
if (_grabbingController != null && !_cameraPlus.Config.LockCamera)
{
var diff = _grabbingController.verticalAxisValue * Time.unscaledDeltaTime;
if (_grabPos.magnitude > MinScrollDistance)
Expand Down
4 changes: 4 additions & 0 deletions CameraPlus/CameraPlus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@
<EmbeddedResource Include="Resources\Lock.png" />
<EmbeddedResource Include="Resources\UnLock.png" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\CameraLock.png" />
<EmbeddedResource Include="Resources\CameraUnlock.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
Expand Down
1 change: 1 addition & 0 deletions CameraPlus/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class Config
{
public string FilePath { get; }
public bool LockScreen = false;
public bool LockCamera = false;
public float fov = 50;
public int antiAliasing = 2;
public float renderScale = 1;
Expand Down
16 changes: 16 additions & 0 deletions CameraPlus/ContextMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ internal Vector2 menuPos
internal string[] scriptName;
internal int scriptPage;
internal Texture2D texture = null;
internal Texture2D Cameratexture = null;
internal GUIStyle CustomEnableStyle = null;
internal GUIStyle CustomDisableStyle = null;

Expand All @@ -45,6 +46,10 @@ public void EnableMenu(Vector2 mousePos, CameraPlusBehaviour parentBehaviour)
texture = Utils.LoadTextureFromResources("CameraPlus.Resources.Lock.png");
else
texture = Utils.LoadTextureFromResources("CameraPlus.Resources.UnLock.png");
if (this.parentBehaviour.Config.LockCamera)
Cameratexture = Utils.LoadTextureFromResources("CameraPlus.Resources.CameraLock.png");
else
Cameratexture = Utils.LoadTextureFromResources("CameraPlus.Resources.CameraUnlock.png");
}
public void DisableMenu()
{
Expand Down Expand Up @@ -89,6 +94,17 @@ void OnGUI()
}
GUI.Box(new Rect(menuPos.x + 35, menuPos.y + 25, 115, 30), new GUIContent(parentBehaviour.Config.LockScreen ? "Locked Screen" : "Unlocked Screen"));

if (GUI.Button(new Rect(menuPos.x + 150, menuPos.y + 25, 30, 30), Cameratexture))
{
parentBehaviour.Config.LockCamera = !parentBehaviour.Config.LockCamera;
parentBehaviour.Config.Save();
if (this.parentBehaviour.Config.LockCamera)
Cameratexture = Utils.LoadTextureFromResources("CameraPlus.Resources.CameraLock.png");
else
Cameratexture = Utils.LoadTextureFromResources("CameraPlus.Resources.CameraUnlock.png");
}
GUI.Box(new Rect(menuPos.x + 185, menuPos.y + 25, 115, 30), new GUIContent(parentBehaviour.Config.LockCamera ? "Locked Camera" : "Unlocked Camera"));

if (GUI.Button(new Rect(menuPos.x + 5, menuPos.y + 60, 145, 60), new GUIContent("Add New Camera")))
{
lock (Plugin.Instance.Cameras)
Expand Down
4 changes: 2 additions & 2 deletions CameraPlus/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.7.4")]
[assembly: AssemblyFileVersion("4.7.4")]
[assembly: AssemblyVersion("4.7.5")]
[assembly: AssemblyFileVersion("4.7.5")]
Binary file added CameraPlus/Resources/CameraLock.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 added CameraPlus/Resources/CameraUnlock.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 CameraPlus/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"gameVersion": "1.13.2",
"id": "CameraPlus",
"name": "CameraPlus",
"version": "4.7.4",
"version": "4.7.5",
"features": [],
"dependsOn": {
"BSIPA": "^4.1.4"
Expand Down

0 comments on commit 88ca88e

Please sign in to comment.