Initial commit

This commit is contained in:
gunnbr committed 2021-01-11 22:20:43 -08:00
1 parent ee9615239e
commit 16feac691f
4093 files changed
+1030491

No files matched your search

@@ -0,0 +1,191 @@
using UnityEngine;
namespace Gaia
{
/// <summary>
/// This camera controller is adapted from here: https://ruhrnuklear.de/fcc/ and provided here as a convenience.
/// </summary>
public class CameraController : MonoBehaviour
{
public GameObject target; // Target to follow
public float targetHeight = 5f; // Vertical offset adjustment
public float distance = 12.0f; // Default Distance
public float offsetFromWall = 0.1f; // Bring camera away from any colliding objects
public float maxDistance = 20f; // Maximum zoom Distance
public float minDistance = 0.6f; // Minimum zoom Distance
public float xSpeed = 200.0f; // Orbit speed (Left/Right)
public float ySpeed = 200.0f; // Orbit speed (Up/Down)
public float yMinLimit = -80f; // Looking up limit
public float yMaxLimit = 80f; // Looking down limit
public float zoomRate = 40f; // Zoom Speed
public float rotationDampening = 0.5f; // Auto Rotation speed (higher = faster)
public float zoomDampening = 5.0f; // Auto Zoom speed (Higher = faster)
public LayerMask collisionLayers = 3841; // What the camera will collide with
public bool lockToRearOfTarget = false; // Lock camera to rear of target
public bool allowMouseInputX = true; // Allow player to control camera angle on the X axis (Left/Right)
public bool allowMouseInputY = true; // Allow player to control camera angle on the Y axis (Up/Down)
private float xDeg = 0.0f;
private float yDeg = 0.0f;
private float currentDistance;
private float desiredDistance;
private float correctedDistance;
private bool rotateBehind = false;
private bool mouseSideButton = false;
private float pbuffer = 0.0f; //Cooldownpuffer for SideButtons
//private float coolDown = 0.5f; //Cooldowntime for SideButtons
void Start()
{
Vector3 angles = transform.eulerAngles;
xDeg = angles.x;
yDeg = angles.y;
currentDistance = distance;
desiredDistance = distance;
correctedDistance = distance;
// Make the rigid body not change rotation
// if (rigidbody)
// rigidbody.freezeRotation = true;
if (lockToRearOfTarget)
rotateBehind = true;
//Grab target
if (target == null)
{
target = GameObject.FindGameObjectWithTag("Player") as GameObject;
}
gameObject.layer = 2;
}
//Only Move camera after everything else has been updated
private void LateUpdate()
{
Apply();
}
public void Apply()
{
// Don't do anything if target is not defined
if (target == null)
return;
//pushbuffer
if (pbuffer > 0)
pbuffer -= Time.deltaTime;
if (pbuffer < 0)
pbuffer = 0;
//Sidebuttonmovement
// if ((Input.GetAxis("Toggle Move") != 0) && (pbuffer == 0))
// {
// pbuffer = coolDown;
// mouseSideButton = !mouseSideButton;
// }
if (mouseSideButton && Input.GetAxis("Vertical") != 0)
mouseSideButton = false;
Vector3 vTargetOffset;
// If either mouse buttons are down, let the mouse govern camera position
if (GUIUtility.hotControl == 0)
{
if (Input.GetMouseButton(0) || Input.GetMouseButton(1))
{
//Check to see if mouse input is allowed on the axis
if (allowMouseInputX)
xDeg += Input.GetAxis("Mouse X") * xSpeed * 0.02f;
else
RotateBehindTarget();
if (allowMouseInputY)
yDeg -= Input.GetAxis("Mouse Y") * ySpeed * 0.02f;
//Interrupt rotating behind if mouse wants to control rotation
if (!lockToRearOfTarget)
rotateBehind = false;
}
// otherwise, ease behind the target if any of the directional keys are pressed
else if (Input.GetAxis("Vertical") != 0 || Input.GetAxis("Horizontal") != 0 || rotateBehind ||
mouseSideButton)
{
RotateBehindTarget();
}
}
yDeg = ClampAngle(yDeg, yMinLimit, yMaxLimit);
// Set camera rotation
Quaternion rotation = Quaternion.Euler(yDeg, xDeg, 0);
// Calculate the desired distance
desiredDistance -= Input.GetAxis("Mouse ScrollWheel") * Time.deltaTime * zoomRate *
Mathf.Abs(desiredDistance);
desiredDistance = Mathf.Clamp(desiredDistance, minDistance, maxDistance);
correctedDistance = desiredDistance;
// Calculate desired camera position
vTargetOffset = new Vector3(0, -targetHeight, 0);
Vector3 position = target.transform.position - (rotation * Vector3.forward * desiredDistance + vTargetOffset);
// Check for collision using the true target's desired registration point as set by user using height
RaycastHit collisionHit;
Vector3 trueTargetPosition = new Vector3(target.transform.position.x, target.transform.position.y + targetHeight, target.transform.position.z);
// If there was a collision, correct the camera position and calculate the corrected distance
var isCorrected = false;
if (Physics.Linecast(trueTargetPosition, position, out collisionHit, collisionLayers))
{
// Calculate the distance from the original estimated position to the collision location,
// subtracting out a safety "offset" distance from the object we hit. The offset will help
// keep the camera from being right on top of the surface we hit, which usually shows up as
// the surface geometry getting partially clipped by the camera's front clipping plane.
correctedDistance = Vector3.Distance(trueTargetPosition, collisionHit.point) - offsetFromWall;
isCorrected = true;
}
// For smoothing, lerp distance only if either distance wasn't corrected, or correctedDistance is more than currentDistance
currentDistance = !isCorrected || correctedDistance > currentDistance
? Mathf.Lerp(currentDistance, correctedDistance, Time.deltaTime * zoomDampening)
: correctedDistance;
// Keep within limits
currentDistance = Mathf.Clamp(currentDistance, minDistance, maxDistance);
// Recalculate position based on the new currentDistance
position = target.transform.position - (rotation * Vector3.forward * currentDistance + vTargetOffset);
//Finally Set rotation and position of camera
transform.rotation = rotation;
transform.position = position;
}
private void RotateBehindTarget()
{
float targetRotationAngle = target.transform.eulerAngles.y;
float currentRotationAngle = transform.eulerAngles.y;
xDeg = Mathf.LerpAngle(currentRotationAngle, targetRotationAngle, rotationDampening * Time.deltaTime);
// Stop rotating behind if not completed
if (targetRotationAngle == currentRotationAngle)
{
if (!lockToRearOfTarget)
rotateBehind = false;
}
else
rotateBehind = true;
}
private float ClampAngle(float angle, float min, float max)
{
if (angle < -360f)
angle += 360f;
if (angle > 360f)
angle -= 360f;
return Mathf.Clamp(angle, min, max);
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 197f6b4de389cac469c4a23bb589a787
timeCreated: 1524270810
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,81 @@
using UnityEngine;
namespace Gaia
{
[System.Serializable]
public class CameraControllerData
{
public float targetHeight = 1.5f; // Vertical offset adjustment
public float distance = 6.0f; // Default Distance
public float offsetFromWall = 0.1f; // Bring camera away from any colliding objects
public float maxDistance = 20f; // Maximum zoom Distance
public float minDistance = 0.6f; // Minimum zoom Distance
public float xSpeed = 200.0f; // Orbit speed (Left/Right)
public float ySpeed = 200.0f; // Orbit speed (Up/Down)
public float yMinLimit = -80f; // Looking up limit
public float yMaxLimit = 80f; // Looking down limit
public float zoomRate = 40f; // Zoom Speed
public float rotationDampening = 0.5f; // Auto Rotation speed (higher = faster)
public float zoomDampening = 5.0f; // Auto Zoom speed (Higher = faster)
public LayerMask collisionLayers = 3841; // What the camera will collide with
public bool lockToRearOfTarget = false; // Lock camera to rear of target
public bool allowMouseInputX = true; // Allow player to control camera angle on the X axis (Left/Right)
public bool allowMouseInputY = true; // Allow player to control camera angle on the Y axis (Up/Down)
}
public class CarControllerSetup : MonoBehaviour
{
public GameObject m_carFocusPoint;
public Camera m_camera;
public CameraControllerData m_cameraControllerData = new CameraControllerData();
private void Start()
{
if (m_camera == null)
{
m_camera = GaiaUtils.GetCamera();
}
if (!VerifyCameraController())
{
Debug.LogError("Car Controller could not be setup correctly.");
}
}
public bool VerifyCameraController()
{
if (m_camera == null)
{
m_camera = GaiaUtils.GetCamera();
if (m_camera == null)
{
return false;
}
}
CameraController controller = m_camera.GetComponent<CameraController>();
if (controller == null)
{
controller = m_camera.gameObject.AddComponent<CameraController>();
}
controller.target = m_carFocusPoint;
controller.targetHeight = m_cameraControllerData.targetHeight;
controller.distance = m_cameraControllerData.distance;
controller.offsetFromWall = m_cameraControllerData.offsetFromWall;
controller.maxDistance = m_cameraControllerData.maxDistance;
controller.minDistance = m_cameraControllerData.minDistance;
controller.xSpeed = m_cameraControllerData.xSpeed;
controller.ySpeed = m_cameraControllerData.ySpeed;
controller.yMinLimit = m_cameraControllerData.yMinLimit;
controller.yMaxLimit = m_cameraControllerData.yMaxLimit;
controller.zoomRate = m_cameraControllerData.zoomRate;
controller.rotationDampening = m_cameraControllerData.rotationDampening;
controller.zoomDampening = m_cameraControllerData.zoomDampening;
controller.collisionLayers = m_cameraControllerData.collisionLayers;
controller.lockToRearOfTarget = m_cameraControllerData.lockToRearOfTarget;
controller.allowMouseInputX = m_cameraControllerData.allowMouseInputX;
controller.allowMouseInputY = m_cameraControllerData.allowMouseInputY;
return true;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: eb3340820a4d553488ad45f9b16a987a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,232 @@
using UnityEngine;
using System.Collections;
namespace Gaia
{
public class FrameRateManager : MonoBehaviour
{
//Quality manager related
public bool m_showFPS = true;
public bool m_showGUI = true;
public bool m_autoQualityManagement = true;
public float m_autoCheckInterval = 10f;
public int m_targetFrameRate = 60;
public int m_fontSize = 25;
private float m_autoCheckTimeLeft = 0f;
private int m_currentQuality = 0;
private int m_maxQuality = 1;
private string[] m_qualityNames;
//FPS Related
private float m_fpsUpdateInterval = 0.5f;
private float m_fpsAccum = 0;
private int m_fpsFrames = 0;
private float m_fpsTimeLeft;
private float m_fpsValue = 0f;
private string m_fpsValueStr = string.Empty;
private GUIStyle m_fpsStyle = new GUIStyle();
private GUIStyle m_fpsShadowStyle = new GUIStyle();
private Rect m_fpsLocation = new Rect(5, 5, 100, 25);
private Rect m_fpsShadowLocation = new Rect(5 + 1, 5 + 1, 100, 25);
void Start()
{
Application.targetFrameRate = m_targetFrameRate;
m_maxQuality = QualitySettings.names.Length - 1;
m_qualityNames = QualitySettings.names;
m_currentQuality = QualitySettings.GetQualityLevel();
m_autoCheckTimeLeft = m_autoCheckInterval;
Debug.Log("Current quality is " + m_qualityNames[m_currentQuality]);
//Increase the size of FPS
m_fpsStyle.fontSize = m_fontSize;
m_fpsShadowStyle.fontSize = m_fontSize;
m_fpsTimeLeft = m_fpsUpdateInterval;
m_fpsLocation = new Rect(Screen.width - 250, 5, 100, 25);
m_fpsShadowLocation = new Rect(Screen.width - 250 + 1, 5 + 1, 100, 25);
}
void OnGUI()
{
if (!m_showFPS && !m_showGUI)
{
return;
}
if (m_showFPS)
{
GUI.Label(m_fpsShadowLocation, m_fpsValueStr, m_fpsShadowStyle);
GUI.Label(m_fpsLocation, m_fpsValueStr, m_fpsStyle);
}
if (m_showGUI)
{
GUILayout.BeginVertical();
for (int i = 0; i <= m_maxQuality; i++)
{
if (GUILayout.Button(m_qualityNames[i]))
{
QualitySettings.SetQualityLevel(i, true);
m_currentQuality = i;
UpdateQuality();
m_autoQualityManagement = false; //Assume you are manually handling quality management
}
}
GUILayout.EndVertical();
}
}
void Update()
{
m_fpsTimeLeft -= Time.deltaTime;
m_fpsAccum += Time.timeScale / Time.deltaTime;
++m_fpsFrames;
// Interval ended - update GUI text and start new interval
if (m_fpsTimeLeft <= 0.0f)
{
m_fpsValue = m_fpsAccum / m_fpsFrames;
if (m_fpsValue < 30)
m_fpsStyle.normal.textColor = Color.yellow;
else if (m_fpsValue < 10)
m_fpsStyle.normal.textColor = Color.red;
else
m_fpsStyle.normal.textColor = Color.green;
m_fpsValueStr = System.String.Format("{0:f0} {1}", m_fpsValue, m_qualityNames[m_currentQuality].Substring(0, 3));
m_fpsTimeLeft = m_fpsUpdateInterval;
m_fpsAccum = 0.0F;
m_fpsFrames = 0;
}
if (m_autoQualityManagement)
{
m_autoCheckTimeLeft -= Time.deltaTime;
if (m_autoCheckTimeLeft < 0.0f)
{
if ((m_fpsValue + 10f) >= m_targetFrameRate)
{
IncreaseQuality();
}
else if ((m_fpsValue - 10f) <= m_targetFrameRate)
{
DecreaseQuality();
}
m_autoCheckTimeLeft = m_autoCheckInterval;
}
}
}
void UpdateQuality()
{
//Dont change the settings if there is no change in quality
if (QualitySettings.GetQualityLevel() == m_currentQuality)
{
return;
}
Debug.Log("Changing quality to " + m_qualityNames[m_currentQuality]);
//Update the terrain quality settings
switch (m_currentQuality)
{
case 0:
Terrain.activeTerrain.treeDistance = 250.0f;
Terrain.activeTerrain.treeBillboardDistance = 30.0f;
Terrain.activeTerrain.treeCrossFadeLength = 5.0f;
Terrain.activeTerrain.treeMaximumFullLODCount = 5;
Terrain.activeTerrain.detailObjectDistance = 40.0f;
Terrain.activeTerrain.detailObjectDensity = 0.1f;
Terrain.activeTerrain.heightmapPixelError = 20.0f;
Terrain.activeTerrain.heightmapMaximumLOD = 1;
Terrain.activeTerrain.basemapDistance = 100.0f;
break;
case 1:
Terrain.activeTerrain.treeDistance = 500.0f;
Terrain.activeTerrain.treeBillboardDistance = 50.0f;
Terrain.activeTerrain.treeCrossFadeLength = 10.0f;
Terrain.activeTerrain.treeMaximumFullLODCount = 10;
Terrain.activeTerrain.detailObjectDistance = 50.0f;
Terrain.activeTerrain.detailObjectDensity = 0.25f;
Terrain.activeTerrain.heightmapPixelError = 10.0f;
Terrain.activeTerrain.heightmapMaximumLOD = 1;
Terrain.activeTerrain.basemapDistance = 250.0f;
break;
case 2:
Terrain.activeTerrain.treeDistance = 650.0f;
Terrain.activeTerrain.treeBillboardDistance = 75.0f;
Terrain.activeTerrain.treeCrossFadeLength = 25.0f;
Terrain.activeTerrain.treeMaximumFullLODCount = 20;
Terrain.activeTerrain.detailObjectDistance = 60.0f;
Terrain.activeTerrain.detailObjectDensity = 0.4f;
Terrain.activeTerrain.heightmapPixelError = 8.0f;
Terrain.activeTerrain.heightmapMaximumLOD = 0;
Terrain.activeTerrain.basemapDistance = 500.0f;
break;
case 3:
Terrain.activeTerrain.treeDistance = 800.0f;
Terrain.activeTerrain.treeBillboardDistance = 100.0f;
Terrain.activeTerrain.treeCrossFadeLength = 40.0f;
Terrain.activeTerrain.treeMaximumFullLODCount = 30;
Terrain.activeTerrain.detailObjectDistance = 80.0f;
Terrain.activeTerrain.detailObjectDensity = 0.7f;
Terrain.activeTerrain.heightmapPixelError = 5.0f;
Terrain.activeTerrain.heightmapMaximumLOD = 0;
Terrain.activeTerrain.basemapDistance = 800.0f;
break;
case 4:
Terrain.activeTerrain.treeDistance = 1000.0f;
Terrain.activeTerrain.treeBillboardDistance = 150.0f;
Terrain.activeTerrain.treeCrossFadeLength = 50.0f;
Terrain.activeTerrain.treeMaximumFullLODCount = 50;
Terrain.activeTerrain.detailObjectDistance = 120.0f;
Terrain.activeTerrain.detailObjectDensity = 1f;
Terrain.activeTerrain.heightmapPixelError = 5f;
Terrain.activeTerrain.heightmapMaximumLOD = 0;
Terrain.activeTerrain.basemapDistance = 1000.0f;
break;
case 5:
Terrain.activeTerrain.treeDistance = 2000.0f;
Terrain.activeTerrain.treeBillboardDistance = 200.0f;
Terrain.activeTerrain.treeCrossFadeLength = 50.0f;
Terrain.activeTerrain.treeMaximumFullLODCount = 100;
Terrain.activeTerrain.detailObjectDistance = 150f;
Terrain.activeTerrain.detailObjectDensity = 1f;
Terrain.activeTerrain.heightmapPixelError = 5f;
Terrain.activeTerrain.heightmapMaximumLOD = 0;
Terrain.activeTerrain.basemapDistance = 1000.0f;
break;
}
}
bool IncreaseQuality()
{
if (m_currentQuality < m_maxQuality)
{
m_currentQuality++;
UpdateQuality();
}
return true;
}
bool DecreaseQuality()
{
if (m_currentQuality > 0)
{
m_currentQuality--;
UpdateQuality();
}
return true;
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 4296cb4e053296948b61c2ab80ec68a0
timeCreated: 1438379627
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,119 @@
using UnityEngine;
namespace Gaia
{
/// <summary>
/// This camera script has been adapted from the camera provided by Unity with the black smith environment pack
/// </summary>
public class FreeCamera : MonoBehaviour
{
public bool enableInputCapture = true;
public bool lockAndHideCursor = false;
public bool holdRightMouseCapture = true;
public float lookSpeed = 5f;
public float moveSpeed = 5f;
public float sprintSpeed = 50f;
public GameObject UIGameObject;
bool m_inputCaptured;
float m_yaw;
float m_pitch;
void Awake()
{
enabled = enableInputCapture;
}
private void Start()
{
if (UIGameObject != null)
{
UIGameObject.SetActive(true);
}
}
void OnEnable()
{
if (enableInputCapture && !holdRightMouseCapture)
CaptureInput();
}
void OnDisable()
{
ReleaseInput();
}
void OnValidate()
{
if (Application.isPlaying)
enabled = enableInputCapture;
}
void CaptureInput()
{
if (lockAndHideCursor)
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
m_inputCaptured = true;
m_yaw = transform.eulerAngles.y;
m_pitch = transform.eulerAngles.x;
}
void ReleaseInput()
{
if (lockAndHideCursor)
{
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
m_inputCaptured = false;
}
void OnApplicationFocus(bool focus)
{
if (m_inputCaptured && !focus)
ReleaseInput();
}
void Update()
{
if (!m_inputCaptured)
{
if (!holdRightMouseCapture && Input.GetMouseButtonDown(0))
CaptureInput();
else if (holdRightMouseCapture && Input.GetMouseButtonDown(1))
CaptureInput();
}
if (!m_inputCaptured)
return;
if (m_inputCaptured)
{
if (!holdRightMouseCapture && Input.GetKeyDown(KeyCode.Escape))
ReleaseInput();
else if (holdRightMouseCapture && Input.GetMouseButtonUp(1))
ReleaseInput();
}
var rotStrafe = Input.GetAxis("Mouse X");
var rotFwd = Input.GetAxis("Mouse Y");
m_yaw = (m_yaw + lookSpeed * rotStrafe) % 360f;
m_pitch = (m_pitch - lookSpeed * rotFwd) % 360f;
transform.rotation = Quaternion.AngleAxis(m_yaw, Vector3.up) * Quaternion.AngleAxis(m_pitch, Vector3.right);
var speed = Time.deltaTime * (Input.GetKey(KeyCode.LeftShift) ? sprintSpeed : moveSpeed);
var forward = speed * Input.GetAxis("Vertical");
var right = speed * Input.GetAxis("Horizontal");
var up = speed * ((Input.GetKey(KeyCode.E) ? 1f : 0f) - (Input.GetKey(KeyCode.Q) ? 1f : 0f));
transform.position += transform.forward * forward + transform.right * right + Vector3.up * up;
}
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 914d865d1e3e9429ba78b8735e5bb2d5
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,81 @@
using UnityEngine;
using System.Collections;
namespace Gaia
{
/// <summary>
/// Base growth class - can be assigned to a game object to cause it to grow over a given range.
/// Implemeneted as virtuals so that you can derive more sophisticated behavior from it.
/// </summary>
public class Growth : MonoBehaviour
{
[Range(0.1f, 2f), Tooltip("The start size in the game.")]
public float m_startScale = 0.15f;
[Range(0.1f, 2f), Tooltip("The end size in the game.")]
public float m_endScale = 1.0f;
[Range(0f, 2f), Tooltip("Scale variance. Final scale is equal to end scale plus a a random value between 0 and this.")]
public float m_scaleVariance = 0.25f;
[Range(0.5f, 60f), Tooltip("The time it takes to grow in seconds.")]
public float m_growthTime = 5.0f;
/// <summary>
/// The actual end scale being used
/// </summary>
private float m_actualEndScale = 0f;
void Start()
{
Initialise();
}
/// <summary>
/// Initialise this agent.
/// </summary>
public virtual void Initialise()
{
//Randomly choose an end scale
m_actualEndScale = m_endScale + Random.Range(0f, m_scaleVariance);
//Update the scale of the agent
StartCoroutine(Grow());
}
/// <summary>
/// Grow this agent in a co-routine. Its a one shot thing.
/// </summary>
IEnumerator Grow()
{
//Set growth params
float scale;
float startTime = Time.realtimeSinceStartup;
float currentTime = startTime;
float deltaScale = m_actualEndScale - m_startScale;
float finishTime = startTime + m_growthTime;
while (currentTime < finishTime)
{
//Update scale
scale = 1f - ((finishTime - currentTime) / m_growthTime);
scale = m_startScale + (scale * deltaScale);
//Apply it to the game object
gameObject.transform.localScale = Vector3.one * scale;
yield return null;
//yield return new WaitForSeconds(0.1f); // Can use this to lessen impact on fps
//Update time
currentTime = Time.realtimeSinceStartup;
}
}
/// <summary>
/// Kill this instance.
/// </summary>
public virtual void Die()
{
//Destroy ourselves
Destroy(gameObject, 5f);
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 0a288931c059b024cb9788a1af051e9d
timeCreated: 1432534392
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 086be44942abfb542b44bfa9e53c3ea3
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d482b667a0c0a914f83089767158a560
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,425 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Gaia.Internal;
using PWCommon4;
using UnityEditor;
using UnityEngine;
namespace Gaia
{
public class LocationManagerEditor : EditorWindow, IPWEditor
{
private EditorUtils m_editorUtils;
private LocationSystem m_profile;
private Vector2 scrollPosition;
private GUIStyle m_boxStyle;
public bool PositionChecked { get; set; }
/// <summary>
/// Show Gaia Manager editor window
/// </summary>
public static void ShowLocationManager()
{
try
{
var manager = EditorWindow.GetWindow<Gaia.LocationManagerEditor>(false, "Location Manager");
//Show manager if not null
if (manager != null)
{
Vector2 initialSize = new Vector2(600f, 400f);
manager.position = new Rect(new Vector2(Screen.currentResolution.width / 2f - initialSize.x / 2f, Screen.currentResolution.height / 2f - initialSize.y / 2f), initialSize);
manager.Show();
}
}
catch (Exception ex)
{
if (ex.Message == "")
{ }
}
}
private void OnEnable()
{
m_profile = GetLocationSystem();
if (m_editorUtils == null)
{
// Get editor utils for this
m_editorUtils = PWApp.GetEditorUtils(this);
}
if (!Application.isPlaying)
{
if (GaiaUtils.CheckIfSceneProfileExists())
{
m_profile.m_locationProfile.m_currentControllerType = GaiaGlobal.Instance.SceneProfile.m_controllerType;
}
}
}
/// <summary>
/// Setup on destroy
/// </summary>
private void OnDestroy()
{
m_editorUtils?.Dispose();
}
public void OnGUI()
{
//Initialization
m_editorUtils.Initialize(); // Do not remove this!
scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUILayout.Width(position.width), GUILayout.Height(position.height));
//Set up the box style
if (m_boxStyle == null)
{
m_boxStyle = new GUIStyle(GUI.skin.box)
{
normal = {textColor = GUI.skin.label.normal.textColor},
fontStyle = FontStyle.Bold,
alignment = TextAnchor.UpperLeft
};
}
if (m_profile == null)
{
m_profile = GetLocationSystem();
}
m_editorUtils.Panel("GlobalSettings", GlobalPanel, true);
EditorGUILayout.EndScrollView();
}
private void GlobalPanel(bool helpEnabled)
{
if (Application.isPlaying)
{
if (GaiaUtils.CheckIfSceneProfileExists())
{
if (m_profile.m_locationProfile.m_currentControllerType != GaiaGlobal.Instance.SceneProfile.m_controllerType)
{
EditorGUILayout.HelpBox(m_editorUtils.GetTextValue("ControllerHasChanged"), MessageType.Warning);
}
}
}
if (m_profile == null)
{
EditorGUILayout.HelpBox("Location manager allows you to track camera position at runtime and create bookmarks to load locations", MessageType.Info);
if (m_editorUtils.Button("AddLocationManager"))
{
m_profile = AddLocationSystem();
}
}
else
{
EditorGUI.BeginChangeCheck();
m_editorUtils.Panel("Setup", Setup);
if (m_profile.m_locationProfile != null)
{
GUI.enabled = true;
}
else
{
GUI.enabled = false;
}
m_editorUtils.Panel("Controls", RuntimeControls);
m_editorUtils.Panel("BookmarkSetup", BookmarkSetup, true);
if (EditorGUI.EndChangeCheck())
{
EditorUtility.SetDirty(m_profile);
if (m_profile.m_locationProfile != null)
{
EditorUtility.SetDirty(m_profile.m_locationProfile);
}
}
}
}
private void RuntimeControls(bool helpEnabled)
{
m_editorUtils.Heading("Controls");
if (m_profile.m_locationProfile != null)
{
m_profile.m_locationProfile.m_mainKey = (KeyCode)m_editorUtils.EnumPopup("MasterKey", m_profile.m_locationProfile.m_mainKey, helpEnabled);
m_profile.m_locationProfile.m_addBookmarkKey = (KeyCode)m_editorUtils.EnumPopup("AddNewBookmark", m_profile.m_locationProfile.m_addBookmarkKey, helpEnabled);
m_profile.m_locationProfile.m_prevBookmark = (KeyCode)m_editorUtils.EnumPopup("PreviousBookmark", m_profile.m_locationProfile.m_prevBookmark, helpEnabled);
m_profile.m_locationProfile.m_nextBookmark = (KeyCode)m_editorUtils.EnumPopup("NextBookmark", m_profile.m_locationProfile.m_nextBookmark, helpEnabled);
}
else
{
EditorGUILayout.HelpBox("No location profile provided. Please add one.", MessageType.Info);
}
}
private void Setup(bool helpEnabled)
{
m_profile.m_locationProfile = (LocationSystemScriptableObject)m_editorUtils.ObjectField("LocationProfile", m_profile.m_locationProfile, typeof(LocationSystemScriptableObject), false, helpEnabled);
if (m_profile.m_locationProfile == null)
{
m_profile.m_locationProfile = AssetDatabase.LoadAssetAtPath<LocationSystemScriptableObject>(GaiaUtils.GetAssetPath("Location Profile.asset"));
}
if (m_profile.m_camera == null)
{
EditorGUILayout.BeginHorizontal();
m_profile.m_camera = (Transform)m_editorUtils.ObjectField("Camera", m_profile.m_camera, typeof(Transform), true, helpEnabled);
if (m_editorUtils.Button("FindCamera", GUILayout.MaxWidth(50f)))
{
Camera locatedCam = GaiaUtils.GetCamera();
if (locatedCam != null)
{
m_profile.m_camera = locatedCam.transform;
}
else
{
Debug.LogWarning("No camera could be found in your scene please add one from the GameObject/Camera in the top toolbar.");
}
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.HelpBox("A camera transform must be provided for Location Manager to work. You can press 'Find' button to quickly locate the camera in the scene.", MessageType.Warning);
}
else
{
m_profile.m_camera = (Transform)m_editorUtils.ObjectField("Camera", m_profile.m_camera, typeof(Transform), true, helpEnabled);
}
m_profile.m_player = (Transform)m_editorUtils.ObjectField("Player", m_profile.m_player, typeof(Transform), true, helpEnabled);
m_profile.m_trackPlayer = m_editorUtils.Toggle("TrackPlayer", m_profile.m_trackPlayer, helpEnabled);
}
private void BookmarkSetup(bool helpEnabled)
{
if (m_profile.m_locationProfile != null)
{
m_editorUtils.Heading("BookmarkSetup");
m_profile.m_locationProfile.m_autoLoad = m_editorUtils.Toggle("AutoLoad", m_profile.m_locationProfile.m_autoLoad, helpEnabled);
if (m_profile.m_locationProfile.m_bookmarkedLocationNames.Count > 0)
{
int selected = m_profile.m_selectedBookmark;
for (int i = 0; i < m_profile.m_locationProfile.m_bookmarkedLocationNames.Count; i++)
{
if (m_profile.m_locationProfile.m_bookmarkedLocationNames[i] == m_profile.m_bookmarkName)
{
m_profile.m_bookmarkName = ObjectNames.GetUniqueName(m_profile.m_locationProfile.m_bookmarkedLocationNames.ToArray(), m_profile.m_bookmarkName);
}
}
EditorGUILayout.BeginHorizontal();
m_profile.m_bookmarkName = m_editorUtils.TextField("BookmarkName", m_profile.m_bookmarkName);
if (m_editorUtils.Button("AddBookmark", GUILayout.MaxWidth(60f)))
{
m_profile.m_locationProfile.AddNewBookmark(m_profile);
selected = m_profile.m_locationProfile.m_bookmarkedLocationNames.Count - 1;
m_profile.m_selectedBookmark = m_profile.m_locationProfile.m_bookmarkedLocationNames.Count - 1;
}
EditorGUILayout.EndHorizontal();
m_editorUtils.InlineHelp("BookmarkName", helpEnabled);
if (!m_profile.m_rename)
{
EditorGUILayout.BeginHorizontal();
selected = EditorGUILayout.Popup(new GUIContent(m_editorUtils.GetTextValue("SelectedBookmark"), m_editorUtils.GetTooltip("SelectedBookmark")), selected, m_profile.m_locationProfile.m_bookmarkedLocationNames.ToArray());
if (selected != m_profile.m_selectedBookmark)
{
m_profile.m_selectedBookmark = selected;
if (m_profile.m_locationProfile.m_autoLoad)
{
m_profile.m_locationProfile.LoadBookmark(m_profile);
}
}
if (m_editorUtils.Button("Rename", GUILayout.MaxWidth(60f)))
{
m_profile.m_savedName = m_profile.m_locationProfile.m_bookmarkedLocationNames[m_profile.m_selectedBookmark];
m_profile.m_rename = true;
}
if (m_editorUtils.Button("Override", GUILayout.MaxWidth(60f)))
{
m_profile.m_locationProfile.OverrideBookmark(m_profile);
}
if (!m_profile.m_locationProfile.m_autoLoad)
{
if (m_editorUtils.Button("LoadBookmark", GUILayout.MaxWidth(60f)))
{
m_profile.m_locationProfile.LoadBookmark(m_profile);
}
}
EditorGUILayout.EndHorizontal();
m_editorUtils.InlineHelp("SelectedBookmark", helpEnabled);
if (m_profile.m_locationProfile.m_bookmarkedLocationNames.Count > 0)
{
EditorGUILayout.LabelField("Current Bookmark Controller Type Used: " + m_profile.m_locationProfile.m_bookmarkedSettings[selected].m_controllerUsed, EditorStyles.boldLabel);
}
EditorGUILayout.LabelField("Current Bookmark Was Created In Scene: " + m_profile.m_locationProfile.m_bookmarkedSettings[selected].m_sceneName, EditorStyles.boldLabel);
}
else
{
EditorGUILayout.BeginHorizontal();
m_profile.m_savedName = m_editorUtils.TextField("BookmarkRename", m_profile.m_savedName);
if (m_editorUtils.Button("Save", GUILayout.MaxWidth(55f)))
{
m_profile.m_locationProfile.m_bookmarkedLocationNames[m_profile.m_selectedBookmark] = m_profile.m_savedName;
m_profile.m_rename = false;
}
EditorGUILayout.EndHorizontal();
m_editorUtils.InlineHelp("BookmarkRename", helpEnabled);
}
EditorGUILayout.BeginHorizontal();
if (m_editorUtils.Button("RemoveBookmark"))
{
if (EditorUtility.DisplayDialog("Removing Bookmark", "Are you sure you want to remove " + m_profile.m_locationProfile.m_bookmarkedLocationNames[selected] + " bookmark?", "Yes", "No"))
{
m_profile.m_locationProfile.RemoveBookmark(m_profile.m_selectedBookmark, m_profile);
}
}
if (m_editorUtils.Button("RemoveAllBookmark"))
{
if (EditorUtility.DisplayDialog("Removing All Bookmarks", "Are you sure you want to remove all the bookmarks?", "Yes", "No"))
{
m_profile.m_locationProfile.RemoveAllBookmarks();
}
}
EditorGUILayout.EndHorizontal();
}
else
{
m_profile.m_selectedBookmark = 0;
EditorGUILayout.BeginHorizontal();
m_profile.m_bookmarkName = m_editorUtils.TextField("BookmarkName", m_profile.m_bookmarkName);
if (m_editorUtils.Button("AddBookmark", GUILayout.MaxWidth(55f)))
{
m_profile.m_locationProfile.AddNewBookmark(m_profile);
m_profile.m_selectedBookmark = m_profile.m_locationProfile.m_bookmarkedLocationNames.Count - 1;
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.HelpBox("No bookmarks added to use bookmark features please press 'Add Bookmark'", MessageType.Info);
}
}
else
{
EditorGUILayout.HelpBox("No location profile provided. Please add one.", MessageType.Info);
}
}
private static LocationSystem GetLocationSystem()
{
LocationSystem locationSystem = FindObjectOfType<LocationSystem>();
return locationSystem;
}
/// <summary>
/// Adds the system to the scene and sets it up
/// </summary>
/// <returns></returns>
public static LocationSystem AddLocationSystem()
{
LocationSystem system = null;
GameObject mainCam = GameObject.Find("Main Camera");
if (mainCam != null)
{
system = mainCam.gameObject.GetComponent<LocationSystem>();
if (system == null)
{
system = mainCam.gameObject.AddComponent<LocationSystem>();
system.m_camera = mainCam.transform;
}
}
else
{
mainCam = GameObject.Find("Camera");
if (mainCam != null)
{
system = mainCam.gameObject.GetComponent<LocationSystem>();
if (system == null)
{
system = mainCam.gameObject.AddComponent<LocationSystem>();
system.m_camera = mainCam.transform;
}
}
else
{
mainCam = GameObject.Find("FlyCam");
if (mainCam != null)
{
system = mainCam.gameObject.GetComponent<LocationSystem>();
if (system == null)
{
system = mainCam.gameObject.AddComponent<LocationSystem>();
system.m_camera = mainCam.transform;
}
}
else
{
mainCam = GameObject.Find("FirstPersonCharacter");
if (mainCam != null)
{
system = mainCam.gameObject.GetComponent<LocationSystem>();
if (system == null)
{
system = mainCam.gameObject.AddComponent<LocationSystem>();
system.m_camera = mainCam.transform;
}
}
else
{
mainCam = GameObject.FindGameObjectWithTag("MainCamera");
if (mainCam != null)
{
system = mainCam.gameObject.GetComponent<LocationSystem>();
if (system == null)
{
system = mainCam.gameObject.AddComponent<LocationSystem>();
system.m_camera = mainCam.transform;
}
}
}
}
}
}
GameObject firstPersonController = GameObject.Find("FPSController");
if (firstPersonController != null)
{
if (system != null)
{
system.m_player = firstPersonController.transform;
return system;
}
}
GameObject thirdPersonController = GameObject.Find("ThirdPersonController");
if (thirdPersonController != null)
{
if (system != null)
{
system.m_player = thirdPersonController.transform;
return system;
}
}
GameObject fpsController = GameObject.Find("Player");
if (fpsController != null)
{
if (system != null)
{
system.m_player = fpsController.transform;
return system;
}
}
return null;
}
/// <summary>
/// Removes the location system
/// </summary>
public static void RemoveLocationSystem()
{
LocationSystem system = GameObject.FindObjectOfType<LocationSystem>();
if (system != null)
{
GameObject.DestroyImmediate(system);
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 255a81e4bcf277142b696133d9a8600f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,19 @@
using UnityEditor;
using UnityEngine;
namespace Gaia
{
[CustomEditor(typeof(LocationSystem))]
public class LocationSystemEditor : Editor
{
public override void OnInspectorGUI()
{
EditorGUILayout.HelpBox("The location manager allows you to create bookmark locations to allow you to quickly jump from bookmark to bookmark to help navigate around the scene.", MessageType.Info);
if (GUILayout.Button(new GUIContent("Open Location Manager", "Opens the location manager window")))
{
LocationManagerEditor.ShowLocationManager();
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c6ba9ae158e06df47b1b72161b4fd7e3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,26 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 914692587b938174fb90c1d420593b7d, type: 3}
m_Name: Location Profile
m_EditorClassIdentifier:
m_savedCameraPosition: {x: 159.91113, y: 35.282097, z: 229.74411}
m_savedCameraRotation: {x: 0.0010679468, y: 0.99893147, z: 0.03210823, w: -0.0332253}
m_savedPlayerPosition: {x: 0, y: 0, z: 0}
m_savedPlayerRotation: {x: 0, y: 0, z: 0, w: 1}
m_hasBeenSaved: 0
m_bookmarkedLocationNames: []
m_bookmarkedSettings: []
m_autoLoad: 1
m_mainKey: 304
m_addBookmarkKey: 98
m_prevBookmark: 276
m_nextBookmark: 275
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6fe1b315b70710248ae17a5cd139c1fc
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,104 @@
using UnityEngine;
namespace Gaia
{
[ExecuteAlways]
public class LocationSystem : MonoBehaviour
{
[HideInInspector]
public LocationSystemScriptableObject m_locationProfile;
[HideInInspector]
public Transform m_camera;
[HideInInspector]
public Transform m_player;
[HideInInspector]
public bool m_trackPlayer = false;
[HideInInspector]
public LocationBookmarkSettings m_bookmarkSettings;
[HideInInspector]
public int m_selectedBookmark;
[HideInInspector]
public string m_bookmarkName = "My New Location Name";
[HideInInspector]
public bool m_rename = false;
[HideInInspector]
public string m_savedName;
private void OnEnable()
{
Initilize();
if (m_locationProfile == null)
{
return;
}
if (m_locationProfile.HasBeenSaved())
{
if (m_trackPlayer)
{
m_locationProfile.LoadLocation(m_camera, m_player);
}
}
}
private void Update()
{
if (Application.isPlaying)
{
if (m_camera == null || m_locationProfile == null)
{
return;
}
if (m_trackPlayer)
{
m_locationProfile.SaveLocation(m_camera, m_player);
}
if (Input.GetKey(m_locationProfile.m_mainKey) && Input.GetKeyDown(m_locationProfile.m_prevBookmark))
{
m_selectedBookmark--;
if (m_selectedBookmark < 0)
{
m_selectedBookmark = m_locationProfile.m_bookmarkedLocationNames.Count - 1;
}
m_locationProfile.LoadBookmark(this);
}
if (Input.GetKey(m_locationProfile.m_mainKey) && Input.GetKeyDown(m_locationProfile.m_nextBookmark))
{
m_selectedBookmark++;
if (m_selectedBookmark > m_locationProfile.m_bookmarkedLocationNames.Count - 1)
{
m_selectedBookmark = 0;
}
m_locationProfile.LoadBookmark(this);
}
if (Input.GetKey(m_locationProfile.m_mainKey) && Input.GetKeyDown(m_locationProfile.m_addBookmarkKey))
{
LocationBookmarkSettings settings = LocationSystemScriptableObject.GetCurrentLocation(this);
string name = "Bookmark " + " Position(" + settings.m_savedCameraPosition.x + ", " +
settings.m_savedCameraPosition.y + ", " +
settings.m_savedCameraPosition.z + ")";
m_locationProfile.AddNewBookmark(this, name);
m_selectedBookmark = m_locationProfile.m_bookmarkedLocationNames.Count - 1;
Debug.Log("New Bookmark: " + name);
}
}
}
private void Initilize()
{
if (m_locationProfile == null)
{
#if UNITY_EDITOR
m_locationProfile = UnityEditor.AssetDatabase.LoadAssetAtPath<LocationSystemScriptableObject>(GaiaUtils.GetAssetPath("Location Profile.asset"));
#endif
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f31c048ddcf46df42bd7fd342231d47b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,402 @@
#if UNITY_EDITOR
using UnityEditor;
#endif
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Gaia
{
[System.Serializable]
public class LocationBookmarkSettings
{
public Vector3 m_savedCameraPosition = Vector3.zero;
public Quaternion m_savedCameraRotation = Quaternion.identity;
public Vector3 m_savedPlayerPosition = Vector3.zero;
public Quaternion m_savedPlayerRotation = Quaternion.identity;
public string m_controllerUsed = "Not Been Set";
public string m_sceneName = "Not Been Set";
}
public class LocationSystemScriptableObject : ScriptableObject
{
[HideInInspector]
public GaiaConstants.EnvironmentControllerType m_currentControllerType = GaiaConstants.EnvironmentControllerType.FlyingCamera;
[HideInInspector]
public Vector3 m_savedCameraPosition = Vector3.zero;
[HideInInspector]
public Quaternion m_savedCameraRotation = Quaternion.identity;
[HideInInspector]
public Vector3 m_savedPlayerPosition = Vector3.zero;
[HideInInspector]
public Quaternion m_savedPlayerRotation = Quaternion.identity;
[HideInInspector]
public bool m_hasBeenSaved = false;
[HideInInspector]
public List<string> m_bookmarkedLocationNames = new List<string>();
//[HideInInspector]
public List<LocationBookmarkSettings> m_bookmarkedSettings = new List<LocationBookmarkSettings>();
[HideInInspector]
public bool m_autoLoad = true;
[HideInInspector]
public KeyCode m_mainKey = KeyCode.LeftShift;
[HideInInspector]
public KeyCode m_addBookmarkKey = KeyCode.B;
[HideInInspector]
public KeyCode m_prevBookmark = KeyCode.LeftArrow;
[HideInInspector]
public KeyCode m_nextBookmark = KeyCode.RightArrow;
public static GaiaSettings m_gaiaSettings;
public bool HasBeenSaved()
{
return m_hasBeenSaved;
}
public void SaveLocation(Transform camera, Transform player = null)
{
if (camera == null)
{
Debug.LogError("No camera transform provided");
return;
}
#if UNITY_EDITOR
if (SceneView.lastActiveSceneView != null)
{
if (SceneView.lastActiveSceneView.camera == null)
{
return;
}
}
else
{
return;
}
#endif
if (Application.isPlaying)
{
m_savedCameraPosition = camera.position;
m_savedCameraRotation = camera.rotation;
if (player != null)
{
m_savedPlayerPosition = player.position;
m_savedPlayerRotation = player.rotation;
}
}
else
{
#if UNITY_EDITOR
m_savedCameraPosition = SceneView.lastActiveSceneView.camera.transform.position;
m_savedCameraRotation = SceneView.lastActiveSceneView.camera.transform.rotation;
#endif
}
m_hasBeenSaved = true;
#if UNITY_EDITOR
EditorUtility.SetDirty(this);
#endif
}
public void LoadLocation(Transform camera, Transform player = null)
{
if (camera == null)
{
Debug.LogError("No camera transform provided");
return;
}
camera.position = m_savedCameraPosition;
camera.rotation = m_savedCameraRotation;
if (player != null)
{
player.position = m_savedPlayerPosition;
player.rotation = m_savedPlayerRotation;
}
m_hasBeenSaved = false;
}
public void AddNewBookmark(LocationSystem locationSystem, string overrideName = null)
{
bool addBookmark = true;
for (int i = 0; i < m_bookmarkedLocationNames.Count; i++)
{
if (overrideName != null)
{
if (m_bookmarkedLocationNames[i] == overrideName)
{
addBookmark = false;
}
}
else
{
if (m_bookmarkedLocationNames[i] == locationSystem.m_bookmarkName)
{
addBookmark = false;
}
}
}
if (addBookmark)
{
if (overrideName != null)
{
m_bookmarkedLocationNames.Add(overrideName);
}
else
{
m_bookmarkedLocationNames.Add(locationSystem.m_bookmarkName);
}
m_bookmarkedSettings.Add(GetCurrentLocation(locationSystem));
#if UNITY_EDITOR
EditorUtility.SetDirty(locationSystem);
#endif
}
else
{
Debug.LogWarning("Location name " + locationSystem.m_bookmarkName + " already exists please change the name then add bookmark again.");
}
}
public void OverrideBookmark(LocationSystem locationSystem)
{
if (locationSystem != null)
{
GaiaUtils.CopyFields(GetCurrentLocation(locationSystem), m_bookmarkedSettings[locationSystem.m_selectedBookmark]);
}
}
public void RemoveAllBookmarks()
{
m_bookmarkedLocationNames.Clear();
m_bookmarkedSettings.Clear();
}
public void RemoveBookmark(int index, LocationSystem locationSystem)
{
if (locationSystem.m_selectedBookmark == m_bookmarkedLocationNames.Count - 1)
{
locationSystem.m_selectedBookmark--;
}
m_bookmarkedLocationNames.RemoveAt(index);
m_bookmarkedSettings.RemoveAt(index);
#if UNITY_EDITOR
EditorUtility.SetDirty(locationSystem);
#endif
}
public void LoadBookmark(LocationSystem locationSystem)
{
if (m_bookmarkedSettings.Count < 1)
{
return;
}
LocationBookmarkSettings settings = m_bookmarkedSettings[locationSystem.m_selectedBookmark];
if (settings != null)
{
if (locationSystem.m_camera != null)
{
if (Application.isPlaying)
{
if (GaiaUtils.CheckIfSceneProfileExists())
{
if (settings.m_controllerUsed == GaiaConstants.EnvironmentControllerType.FirstPerson.ToString())
{
switch (GaiaGlobal.Instance.SceneProfile.m_controllerType)
{
case GaiaConstants.EnvironmentControllerType.FirstPerson:
CharacterController controller = FindObjectOfType<CharacterController>();
if (controller != null)
{
controller.enabled = false;
locationSystem.m_camera.SetPositionAndRotation(settings.m_savedCameraPosition, settings.m_savedCameraRotation);
if (locationSystem.m_player != null)
{
locationSystem.m_player.SetPositionAndRotation(settings.m_savedPlayerPosition, settings.m_savedPlayerRotation);
}
controller.enabled = true;
}
break;
case GaiaConstants.EnvironmentControllerType.Custom:
locationSystem.m_camera.SetPositionAndRotation(settings.m_savedCameraPosition, settings.m_savedCameraRotation);
if (locationSystem.m_player != null)
{
locationSystem.m_player.SetPositionAndRotation(settings.m_savedPlayerPosition, settings.m_savedPlayerRotation);
}
break;
case GaiaConstants.EnvironmentControllerType.FlyingCamera:
locationSystem.m_camera.SetPositionAndRotation(settings.m_savedPlayerPosition, settings.m_savedPlayerRotation);
if (locationSystem.m_player != null)
{
locationSystem.m_player.SetPositionAndRotation(settings.m_savedPlayerPosition, settings.m_savedPlayerRotation);
}
break;
case GaiaConstants.EnvironmentControllerType.ThirdPerson:
locationSystem.m_camera.SetPositionAndRotation(new Vector3(0f, 100f, 0f), settings.m_savedCameraRotation);
if (locationSystem.m_player != null)
{
locationSystem.m_player.SetPositionAndRotation(settings.m_savedPlayerPosition, settings.m_savedPlayerRotation);
}
break;
}
}
else if (settings.m_controllerUsed == "Scene View (Editor)")
{
switch (GaiaGlobal.Instance.SceneProfile.m_controllerType)
{
case GaiaConstants.EnvironmentControllerType.FirstPerson:
CharacterController controller = FindObjectOfType<CharacterController>();
if (controller != null)
{
controller.enabled = false;
if (locationSystem.m_player != null)
{
locationSystem.m_player.SetPositionAndRotation(settings.m_savedCameraPosition, settings.m_savedCameraRotation);
}
controller.enabled = true;
}
break;
case GaiaConstants.EnvironmentControllerType.Custom:
if (locationSystem.m_player != null)
{
locationSystem.m_player.SetPositionAndRotation(settings.m_savedCameraPosition, settings.m_savedCameraRotation);
}
break;
case GaiaConstants.EnvironmentControllerType.FlyingCamera:
locationSystem.m_camera.SetPositionAndRotation(settings.m_savedCameraPosition, settings.m_savedCameraRotation);
if (locationSystem.m_player != null)
{
locationSystem.m_player.SetPositionAndRotation(settings.m_savedPlayerPosition, settings.m_savedPlayerRotation);
}
break;
case GaiaConstants.EnvironmentControllerType.ThirdPerson:
if (locationSystem.m_player != null)
{
locationSystem.m_player.SetPositionAndRotation(settings.m_savedCameraPosition, settings.m_savedCameraRotation);
}
break;
}
}
else
{
locationSystem.m_camera.SetPositionAndRotation(settings.m_savedCameraPosition, settings.m_savedCameraRotation);
if (locationSystem.m_player != null)
{
locationSystem.m_player.SetPositionAndRotation(settings.m_savedPlayerPosition, settings.m_savedPlayerRotation);
}
}
}
}
else
{
#if UNITY_EDITOR
if (SceneView.lastActiveSceneView != null)
{
if (SceneView.lastActiveSceneView.camera != null)
{
Camera target = SceneView.lastActiveSceneView.camera;
Transform temp = target.transform;
if (settings.m_controllerUsed == GaiaConstants.EnvironmentControllerType.FirstPerson.ToString())
{
temp.position = settings.m_savedPlayerPosition;
temp.rotation = settings.m_savedPlayerRotation;
}
else
{
temp.position = settings.m_savedCameraPosition;
temp.rotation = settings.m_savedCameraRotation;
}
SceneView.lastActiveSceneView.AlignViewToObject(temp);
}
}
#endif
}
}
}
}
public static LocationBookmarkSettings GetCurrentLocation(LocationSystem locationSystem)
{
LocationBookmarkSettings settings = new LocationBookmarkSettings();
if (Application.isPlaying)
{
if (locationSystem.m_camera != null)
{
settings.m_savedCameraPosition = locationSystem.m_camera.localPosition;
settings.m_savedCameraRotation = locationSystem.m_camera.localRotation;
}
if (locationSystem.m_player != null)
{
settings.m_savedPlayerPosition = locationSystem.m_player.localPosition;
settings.m_savedPlayerRotation = locationSystem.m_player.localRotation;
}
if (GaiaUtils.CheckIfSceneProfileExists())
{
settings.m_controllerUsed = GaiaGlobal.Instance.SceneProfile.m_controllerType.ToString();
}
}
else
{
#if UNITY_EDITOR
if (SceneView.lastActiveSceneView != null)
{
if (SceneView.lastActiveSceneView.camera != null)
{
settings.m_savedCameraPosition = SceneView.lastActiveSceneView.camera.transform.localPosition;
settings.m_savedCameraRotation = SceneView.lastActiveSceneView.camera.transform.localRotation;
settings.m_controllerUsed = "Scene View (Editor)";
}
}
#endif
}
if (SceneManager.GetActiveScene() != null)
{
settings.m_sceneName = SceneManager.GetActiveScene().name;
}
else
{
settings.m_sceneName = "Untitled (Recommend Saving Your Scene Then Override This Bookmark)";
}
return settings;
}
private static GaiaConstants.EnvironmentControllerType GetCharacterControllerType()
{
if (m_gaiaSettings == null)
{
m_gaiaSettings = GaiaUtils.GetGaiaSettings();
}
if (m_gaiaSettings != null)
{
return m_gaiaSettings.m_currentController;
}
return GaiaConstants.EnvironmentControllerType.None;
}
/// <summary>
/// Create sky profile asset
/// </summary>
#if UNITY_EDITOR
[MenuItem("Assets/Create/Procedural Worlds/Gaia/Location Profile")]
public static void CreateLocationProfiles()
{
LocationSystemScriptableObject asset = ScriptableObject.CreateInstance<LocationSystemScriptableObject>();
AssetDatabase.CreateAsset(asset, "Assets/Location Profile.asset");
AssetDatabase.SaveAssets();
EditorUtility.FocusProjectWindow();
Selection.activeObject = asset;
}
#endif
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 914692587b938174fb90c1d420593b7d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4210094cb48a893499644c795bc367a4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c72c700826bbba64887bb006a96789a9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,46 @@
using UnityEngine;
using UnityEditor;
namespace Gaia
{
[CustomEditor(typeof(PostProcessingConverter))]
public class PostProcessingConverterEditor : Editor
{
private PostProcessingConverter m_profile;
private void OnEnable()
{
m_profile = (PostProcessingConverter)target;
}
public override void OnInspectorGUI()
{
m_profile.gameObject.name = "Post Processing Converter";
#if UNITY_POST_PROCESSING_STACK_V2
EditorGUILayout.HelpBox("This only support from Built-In to URP/HDRP conversions only", MessageType.Info);
EditorGUILayout.LabelField("Setup", EditorStyles.boldLabel);
m_profile.RenderPipeline = (GaiaConstants.EnvironmentRenderer)EditorGUILayout.EnumPopup("Selected Pipeline", m_profile.RenderPipeline);
m_profile.ProcessProfile = (UnityEngine.Rendering.PostProcessing.PostProcessProfile)EditorGUILayout.ObjectField("Post Processing Profile", m_profile.ProcessProfile, typeof(UnityEngine.Rendering.PostProcessing.PostProcessProfile), false);
EditorGUILayout.BeginHorizontal();
m_profile.SavePath = EditorGUILayout.TextField("Save Path", m_profile.SavePath);
if (GUILayout.Button("Selected Folder", GUILayout.MaxWidth(110f)))
{
string newPath = EditorUtility.SaveFolderPanel("Save Path", Application.dataPath, "");
m_profile.SavePath = newPath;
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.LabelField("Converting from Built-In to " + m_profile.RenderPipeline);
if (GUILayout.Button("Convert Profile"))
{
#if HDPipeline || UPPipeline
GaiaUtils.CreateURPOrHDRPPostProcessing(m_profile.RenderPipeline, m_profile.ProcessProfile, m_profile.SavePath);
#endif
}
#else
EditorGUILayout.HelpBox("Post Processing V2 is not installed. To use this feature you need to install post processing v2 fromt he package manager. This only support from Built-In to URP/HDRP conversions only", MessageType.Info);
#endif
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 317faaadcd86d7f4ba919d72c10dc8f7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,13 @@
using UnityEngine;
namespace Gaia
{
public class PostProcessingConverter : MonoBehaviour
{
public GaiaConstants.EnvironmentRenderer RenderPipeline = GaiaConstants.EnvironmentRenderer.BuiltIn;
#if UNITY_POST_PROCESSING_STACK_V2
public UnityEngine.Rendering.PostProcessing.PostProcessProfile ProcessProfile;
#endif
public string SavePath = "Assets/";
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 07940a8fdcc06624fb42574f8a4b5564
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,355 @@
using UnityEngine;
using System.Collections;
using System.IO;
using UnityEngine.Experimental.Rendering;
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine.UI;
#endif
namespace Gaia
{
/// <summary>
/// A simple screen shot taker - with thanks to @jamiepollard on the Gaia forum
/// Adapted from the original script here:
/// http://answers.unity3d.com/questions/22954/how-to-save-a-picture-take-screenshot-from-a-camer.html
/// </summary>
[GaiaScriptOrder(500)]
public class ScreenShotter : MonoBehaviour
{
/// <summary>
/// Key the screenshotter is bound to
/// </summary>
public KeyCode m_screenShotKey = KeyCode.F12;
/// <summary>
/// The storage format, JPG is smaller, PNG is higher quality
/// </summary>
public Gaia.GaiaConstants.ImageFileType m_imageFormat = Gaia.GaiaConstants.ImageFileType.Png;
/// <summary>
/// The target directory for the screenshots i.e. /Assets/targetdir
/// </summary>
public string m_targetDirectory = "Gaia User Data/Screenshots";
/// <summary>
/// Target resolution used to quickly change both width and height
/// </summary>
public GaiaConstants.ScreenshotResolution m_screenshotResolution = GaiaConstants.ScreenshotResolution.Resolution1920X1080;
/// <summary>
/// Target screenshot width
/// </summary>
public int m_targetWidth = 1920;
/// <summary>
/// Target screenshot height
/// </summary>
public int m_targetHeight = 1080;
/// <summary>
/// If set the actual screen dimensions will be used instead of target dimensions
/// </summary>
public bool m_useScreenSize = true;
/// <summary>
/// The screen shot camera
/// </summary>
public Camera m_mainCamera;
/// <summary>
/// A toggle to cause the next updatre to take a shot
/// </summary>
private bool m_takeShot = false;
/// <summary>
/// A toggle to cause an asset db refresh
/// </summary>
private bool m_refreshAssetDB = false;
/// <summary>
/// Texture used for the watermark
/// </summary>
public Texture2D m_watermark;
/// <summary>
/// Sets up the camera if not already done
/// </summary>
private void OnEnable()
{
if (m_mainCamera == null)
{
m_mainCamera = GaiaUtils.GetCamera(true);
}
//Create the target directory
string path = Path.Combine(Application.dataPath, m_targetDirectory);
if (!System.IO.Directory.Exists(path))
{
System.IO.Directory.CreateDirectory(path);
#if UNITY_EDITOR
AssetDatabase.Refresh();
#endif
}
}
/// <summary>
/// Get unity to refresh the files list
/// </summary>
private void OnDisable()
{
//Refresh the asset database
if (m_refreshAssetDB)
{
m_refreshAssetDB = false;
#if UNITY_EDITOR
AssetDatabase.Refresh();
#endif
}
}
/// <summary>
/// On Start find camera
/// </summary>
private void Start()
{
if (m_mainCamera == null)
{
m_mainCamera = GaiaUtils.GetCamera(true);
}
}
/// <summary>
/// Assigns a name to the screen shot - by default puts in in the assets directory
/// </summary>
/// <param name="width">Width of screenshot</param>
/// <param name="height">Height of screenshot</param>
/// <returns>Screen shot name and full path</returns>
private string ScreenShotName(int width, int height)
{
string path = Path.Combine(Application.dataPath, m_targetDirectory);
path = path.Replace('\\', '/');
if (path[path.Length-1] == '/')
{
path = path.Substring(0, path.Length - 1);
}
switch (m_imageFormat)
{
case GaiaConstants.ImageFileType.Exr:
return string.Format("{0}/Grab {1:yyyyMMddHHmmss} w{2}h{3} x{4}y{5}z{6}r{7}.exr",
path, System.DateTime.Now,
width,
height,
(int)m_mainCamera.transform.position.x,
(int)m_mainCamera.transform.position.y,
(int)m_mainCamera.transform.position.z,
(int)m_mainCamera.transform.rotation.eulerAngles.y
);
case GaiaConstants.ImageFileType.Png:
return string.Format("{0}/Grab {1:yyyyMMddHHmmss} w{2}h{3} x{4}y{5}z{6}r{7}.png",
path, System.DateTime.Now,
width,
height,
(int)m_mainCamera.transform.position.x,
(int)m_mainCamera.transform.position.y,
(int)m_mainCamera.transform.position.z,
(int)m_mainCamera.transform.rotation.eulerAngles.y
);
case GaiaConstants.ImageFileType.Tga:
return string.Format("{0}/Grab {1:yyyyMMddHHmmss} w{2}h{3} x{4}y{5}z{6}r{7}.tga",
path, System.DateTime.Now,
width,
height,
(int)m_mainCamera.transform.position.x,
(int)m_mainCamera.transform.position.y,
(int)m_mainCamera.transform.position.z,
(int)m_mainCamera.transform.rotation.eulerAngles.y
);
case GaiaConstants.ImageFileType.Jpg:
return string.Format("{0}/Grab {1:yyyyMMddHHmmss} w{2}h{3} x{4}y{5}z{6}r{7}.jpg",
path, System.DateTime.Now,
width,
height,
(int)m_mainCamera.transform.position.x,
(int)m_mainCamera.transform.position.y,
(int)m_mainCamera.transform.position.z,
(int)m_mainCamera.transform.rotation.eulerAngles.y
);
}
return string.Format("{0}/Grab {1:yyyyMMddHHmmss} w{2}h{3} x{4}y{5}z{6}r{7}.jpg",
path, System.DateTime.Now,
width,
height,
(int)m_mainCamera.transform.position.x,
(int)m_mainCamera.transform.position.y,
(int)m_mainCamera.transform.position.z,
(int)m_mainCamera.transform.rotation.eulerAngles.y
);
}
/// <summary>
/// Call this to take a screen shot in next late update
/// </summary>
public void TakeHiResShot()
{
m_takeShot = true;
}
/// <summary>
/// Takes the actual screen shot when the key is pressed or takeshot is true
/// </summary>
private void LateUpdate()
{
if (Input.GetKeyDown(m_screenShotKey) || m_takeShot)
{
if (m_mainCamera == null)
{
m_mainCamera = GaiaUtils.GetCamera(true);
}
//Pick up and use the actual screen dimensions
if (m_useScreenSize)
{
m_targetWidth = Screen.width;
m_targetHeight = Screen.height;
}
m_refreshAssetDB = true;
RenderTexture rt;
if (m_imageFormat == GaiaConstants.ImageFileType.Exr)
{
rt = new RenderTexture(m_targetWidth, m_targetHeight, 24, DefaultFormat.HDR);
}
else
{
rt = new RenderTexture(m_targetWidth, m_targetHeight, 24, DefaultFormat.LDR);
}
m_mainCamera.targetTexture = rt;
Texture2D screenShot;
if (m_imageFormat == GaiaConstants.ImageFileType.Exr)
{
screenShot = new Texture2D(m_targetWidth, m_targetHeight, TextureFormat.RGBAFloat, false);
}
else
{
screenShot = new Texture2D(m_targetWidth, m_targetHeight, TextureFormat.RGB24, false);
}
bool allowHDR = m_mainCamera.allowHDR;
if (m_imageFormat == GaiaConstants.ImageFileType.Exr)
{
m_mainCamera.allowHDR = true;
}
m_mainCamera.Render();
m_mainCamera.allowHDR = allowHDR;
RenderTexture.active = rt;
screenShot.ReadPixels(new Rect(0, 0, m_targetWidth, m_targetHeight), 0, 0);
m_mainCamera.targetTexture = null;
RenderTexture.active = null; // JC: added to avoid errors
Destroy(rt);
if (m_watermark != null)
{
Gaia.GaiaUtils.MakeTextureReadable(m_watermark);
screenShot = AddWatermark(screenShot, m_watermark);
}
byte[] bytes = null;
switch (m_imageFormat)
{
case GaiaConstants.ImageFileType.Exr:
bytes = ImageConversion.EncodeToEXR(screenShot, Texture2D.EXRFlags.CompressZIP);
break;
case GaiaConstants.ImageFileType.Png:
bytes = ImageConversion.EncodeToPNG(screenShot);
break;
case GaiaConstants.ImageFileType.Tga:
bytes = ImageConversion.EncodeToTGA(screenShot);
break;
case GaiaConstants.ImageFileType.Jpg:
bytes = ImageConversion.EncodeToJPG(screenShot, 100);
break;
}
string filename = ScreenShotName(m_targetWidth, m_targetHeight);
PWCommon4.Utils.WriteAllBytes(filename, bytes);
m_takeShot = false;
Debug.Log(string.Format("Took screenshot to: {0}", filename));
}
}
/// <summary>
/// Adds watermark the screenshot
/// </summary>
/// <param name="background"></param>
/// <param name="watermark"></param>
/// <returns></returns>
public Texture2D AddWatermark(Texture2D background, Texture2D watermark)
{
int startX = background.width - watermark.width - 10;
int endX = startX + watermark.width;
//int startY = background.height - watermark.height - 20;
int startY = 8;
int endY = startY + watermark.height;
for (int x = startX; x < endX; x++)
{
for (int y = startY; y < endY; y++)
{
Color bgColor = background.GetPixel(x, y);
Color wmColor = watermark.GetPixel(x - startX, y - startY);
Color final_color = Color.Lerp(bgColor, wmColor, wmColor.a / 1.0f);
background.SetPixel(x, y, final_color);
}
}
background.Apply();
return background;
}
public void UpdateScreenshotResolution(GaiaConstants.ScreenshotResolution screenshotResolution)
{
switch (screenshotResolution)
{
case GaiaConstants.ScreenshotResolution.Resolution640X480:
m_targetWidth = 640;
m_targetHeight = 480;
break;
case GaiaConstants.ScreenshotResolution.Resolution800X600:
m_targetWidth = 800;
m_targetHeight = 600;
break;
case GaiaConstants.ScreenshotResolution.Resolution1280X720:
m_targetWidth = 1280;
m_targetHeight = 720;
break;
case GaiaConstants.ScreenshotResolution.Resolution1366X768:
m_targetWidth = 1366;
m_targetHeight = 768;
break;
case GaiaConstants.ScreenshotResolution.Resolution1600X900:
m_targetWidth = 1600;
m_targetHeight = 900;
break;
case GaiaConstants.ScreenshotResolution.Resolution1920X1080:
m_targetWidth = 1920;
m_targetHeight = 1080;
break;
case GaiaConstants.ScreenshotResolution.Resolution2560X1440:
m_targetWidth = 2560;
m_targetHeight = 1440;
break;
case GaiaConstants.ScreenshotResolution.Resolution3840X2160:
m_targetWidth = 3840;
m_targetHeight = 2160;
break;
case GaiaConstants.ScreenshotResolution.Resolution7680X4320:
m_targetWidth = 7680;
m_targetHeight = 4320;
break;
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5799bfbccbd15d94aba08faa73803848
timeCreated: 1524565155
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 500
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,95 @@
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;
using UnityEngine.UI;
namespace Gaia
{
[ExecuteInEditMode]
public class UIConfiguration : MonoBehaviour
{
#region Variables
[Header("UI Settings")]
[Tooltip("Sets the UI text color")]
public Color32 m_uiTextColor = new Color32(255, 255, 255, 255);
[Tooltip("Button used to toggle the UI on and off")]
public KeyCode m_uiToggleButton = KeyCode.U;
private Text m_textContent;
private Color32 storedColor;
private bool storedUIStatus = true;
#endregion
#region UI Text Setup
/// <summary>
/// Starting function setup
/// </summary>
void Start()
{
storedColor = m_uiTextColor;
if (m_textContent != null)
{
m_textContent.color = storedColor;
#if UNITY_EDITOR
if (!m_textContent.text.Contains("Open the Location Manager"))
{
string locationProfilePath = GaiaUtils.GetAssetPath("Location Profile.asset");
if (!string.IsNullOrEmpty(locationProfilePath))
{
LocationSystemScriptableObject locationProfile = AssetDatabase.LoadAssetAtPath<LocationSystemScriptableObject>(locationProfilePath);
if (locationProfile != null)
{
m_textContent.text += "\r\n\r\nOpen the Location Manager from the Advanced Tab in the Gaia Manager to bookmark interesting locations:\r\n";
m_textContent.text += string.Format("{0} + {1} (new bookmark), {0} + {2} / {3} (cycle bookmarks)", locationProfile.m_mainKey.ToString(), locationProfile.m_addBookmarkKey.ToString(), locationProfile.m_prevBookmark.ToString(), locationProfile.m_nextBookmark.ToString());
m_textContent.text += "\r\n\r\n";
}
}
}
#endif
}
}
void OnEnable()
{
if (m_textContent == null)
{
GameObject controlTextGO = GameObject.Find("Control Text");
if (controlTextGO != null)
{
m_textContent = controlTextGO.GetComponent<Text>();
}
}
}
void LateUpdate()
{
storedColor = m_uiTextColor;
if (storedUIStatus && Input.GetKeyDown(m_uiToggleButton))
{
m_textContent.enabled = false;
storedUIStatus = false;
}
else if (!storedUIStatus && Input.GetKeyDown(m_uiToggleButton))
{
m_textContent.enabled = true;
storedUIStatus = true;
}
if (m_textContent != null)
{
if (m_textContent.color != storedColor)
{
m_textContent.color = storedColor;
}
}
}
#endregion
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c743dc5b70808e24bb9baaed4b03c7af
timeCreated: 1541073013
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: