Skip to content

Commit

Permalink
All scripts are now using the namespace "AdultLink"
Browse files Browse the repository at this point in the history
  • Loading branch information
AdultLink committed Aug 21, 2018
1 parent ab64476 commit 43e2d83
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 156 deletions.
201 changes: 101 additions & 100 deletions Assets/AdultLink/TexturePanner/Examples/Scripts/CameraController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,124 +2,125 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class CameraController : MonoBehaviour {


public float movementSpeed = 1f;
public float rotationSpeed = 10f;
public float smoothTime = 0.3f;
public Text nameText;
public Text indexText;
public Text descriptionText;
public GameObject lockedIcon;
public GameObject unlockedIcon;
public CameraPositions[] cameraPositions;
private bool lockCursor = true;
private int positionIndex = 0;
private Vector3 velocity = Vector3.zero;
private Vector3 targetPos;
private Vector3 targetRot;
private bool freeView = false;
private Camera cam;
// Use this for initialization
void Start () {
cam = Camera.main;
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
setPosition();
transform.position = targetPos;
transform.rotation = Quaternion.Euler(targetRot);
}

// Update is called once per frame
void Update () {

//CAMERA STUFF
if (Input.GetKeyDown(KeyCode.Tab)) {
freeView = !freeView;
toggleLockedIcon();
if (!freeView) {
setPosition();
setCursorVisibility(false);
}
namespace AdultLink {
public class CameraController : MonoBehaviour {

public float movementSpeed = 1f;
public float rotationSpeed = 10f;
public float smoothTime = 0.3f;
public Text nameText;
public Text indexText;
public Text descriptionText;
public GameObject lockedIcon;
public GameObject unlockedIcon;
public CameraPositions[] cameraPositions;
private bool lockCursor = true;
private int positionIndex = 0;
private Vector3 velocity = Vector3.zero;
private Vector3 targetPos;
private Vector3 targetRot;
private bool freeView = false;
private Camera cam;
// Use this for initialization
void Start () {
cam = Camera.main;
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
setPosition();
transform.position = targetPos;
transform.rotation = Quaternion.Euler(targetRot);
}

// Update is called once per frame
void Update () {

//FREE VIEW
if (freeView){
if (lockCursor){
movementSpeed = Mathf.Max(movementSpeed += Input.GetAxis("Mouse ScrollWheel"), 0.0f);
transform.position += (transform.right * Input.GetAxis("Horizontal") + transform.forward * Input.GetAxis("Vertical")) * movementSpeed;
transform.eulerAngles += new Vector3(-Input.GetAxis("Mouse Y"), Input.GetAxis("Mouse X"), 0f);
detectElement();
}
}
//"GALLERY" MODE
else {
if (Input.GetKeyDown(KeyCode.LeftArrow)) {
positionIndex -= 1;
if (positionIndex < 0){
positionIndex = cameraPositions.Length-1;
//CAMERA STUFF
if (Input.GetKeyDown(KeyCode.Tab)) {
freeView = !freeView;
toggleLockedIcon();
if (!freeView) {
setPosition();
setCursorVisibility(false);
}
setPosition();
}

if (Input.GetKeyDown(KeyCode.RightArrow)) {
positionIndex += 1;
if (positionIndex >= cameraPositions.Length){
positionIndex = 0;
//FREE VIEW
if (freeView){
if (lockCursor){
movementSpeed = Mathf.Max(movementSpeed += Input.GetAxis("Mouse ScrollWheel"), 0.0f);
transform.position += (transform.right * Input.GetAxis("Horizontal") + transform.forward * Input.GetAxis("Vertical")) * movementSpeed;
transform.eulerAngles += new Vector3(-Input.GetAxis("Mouse Y"), Input.GetAxis("Mouse X"), 0f);
detectElement();
}
setPosition();
}
//"GALLERY" MODE
else {
if (Input.GetKeyDown(KeyCode.LeftArrow)) {
positionIndex -= 1;
if (positionIndex < 0){
positionIndex = cameraPositions.Length-1;
}
setPosition();
}

//SMOOTH MOVEMENT TO THE DESIRED POSITION
transform.position = Vector3.SmoothDamp(transform.position, targetPos, ref velocity, smoothTime);
transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.Euler(targetRot), Time.deltaTime* rotationSpeed);
if (Input.GetKeyDown(KeyCode.RightArrow)) {
positionIndex += 1;
if (positionIndex >= cameraPositions.Length){
positionIndex = 0;
}
setPosition();
}

}
//SMOOTH MOVEMENT TO THE DESIRED POSITION
transform.position = Vector3.SmoothDamp(transform.position, targetPos, ref velocity, smoothTime);
transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.Euler(targetRot), Time.deltaTime* rotationSpeed);


if (Input.GetKey(KeyCode.Escape)) {
setCursorVisibility(true);
}
if (Input.GetKey(KeyCode.Mouse0)) {
setCursorVisibility(false);
}
}


if (Input.GetKey(KeyCode.Escape)) {
setCursorVisibility(true);
}
if (Input.GetKey(KeyCode.Mouse0)) {
setCursorVisibility(false);
}

}

private void setPosition() {
targetPos = cameraPositions[positionIndex].pos;
targetRot = cameraPositions[positionIndex].rot;
setInfo();
}
}

private void setCursorVisibility(bool visible) {
lockCursor = !visible;
Cursor.visible = visible;
Cursor.lockState = visible ? CursorLockMode.None : CursorLockMode.Locked;
}
private void setPosition() {
targetPos = cameraPositions[positionIndex].pos;
targetRot = cameraPositions[positionIndex].rot;
setInfo();
}

private void detectElement() {
RaycastHit hit;
Ray ray = cam.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit)) {
if (hit.transform.GetComponent<Index>() != null) {
positionIndex = hit.transform.GetComponent<Index>().index;
setInfo();
private void setCursorVisibility(bool visible) {
lockCursor = !visible;
Cursor.visible = visible;
Cursor.lockState = visible ? CursorLockMode.None : CursorLockMode.Locked;
}

private void detectElement() {
RaycastHit hit;
Ray ray = cam.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit)) {
if (hit.transform.GetComponent<Index>() != null) {
positionIndex = hit.transform.GetComponent<Index>().index;
setInfo();
}
}
}
}

private void setInfo() {
nameText.text = cameraPositions[positionIndex].name.ToString();
indexText.text = (positionIndex+1).ToString() + "/" + cameraPositions.Length.ToString();
descriptionText.text = cameraPositions[positionIndex].description.ToString();
}
private void setInfo() {
nameText.text = cameraPositions[positionIndex].name.ToString();
indexText.text = (positionIndex+1).ToString() + "/" + cameraPositions.Length.ToString();
descriptionText.text = cameraPositions[positionIndex].description.ToString();
}

private void toggleLockedIcon() {
lockedIcon.SetActive(!lockedIcon.activeInHierarchy);
unlockedIcon.SetActive(!unlockedIcon.activeInHierarchy);
private void toggleLockedIcon() {
lockedIcon.SetActive(!lockedIcon.activeInHierarchy);
unlockedIcon.SetActive(!unlockedIcon.activeInHierarchy);
}
}
}

21 changes: 12 additions & 9 deletions Assets/AdultLink/TexturePanner/Examples/Scripts/CameraPositions.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AdultLink {

[System.Serializable]
public class CameraPositions : System.Object {

[System.Serializable]
public class CameraPositions : System.Object {
public string name;
public Vector3 pos;
public Vector3 rot;
[TextArea(0,5)]
public string description;

}

public string name;
public Vector3 pos;
public Vector3 rot;
[TextArea(0,5)]
public string description;

}
}
53 changes: 28 additions & 25 deletions Assets/AdultLink/TexturePanner/Examples/Scripts/HueShift.cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AdultLink
{
public class HueShift : MonoBehaviour {

public class HueShift : MonoBehaviour {
// Use this for initialization

// Use this for initialization
private Material mat;
public float speed = 5f;
public Color color;
void Start () {

private Material mat;
public float speed = 5f;
public Color color;
void Start () {
mat = GetComponent<Renderer>().material;
}

// Update is called once per frame
void FixedUpdate () {
float hue;
float sat;
float value;
Color.RGBToHSV(color, out hue, out sat, out value);
mat.SetColor("_Color", color);
hue += Time.fixedDeltaTime * speed;

mat = GetComponent<Renderer>().material;
}

// Update is called once per frame
void FixedUpdate () {
float hue;
float sat;
float value;
Color.RGBToHSV(color, out hue, out sat, out value);
mat.SetColor("_Color", color);
hue += Time.fixedDeltaTime * speed;
if (hue > 1.0f) {
hue = 0f;
}

if (hue > 1.0f) {
hue = 0f;
}

if (hue < 0f) {
hue = 1.0f;
}
color = Color.HSVToRGB(hue,sat,1.3f);
if (hue < 0f) {
hue = 1.0f;
}
color = Color.HSVToRGB(hue,sat,1.3f);
}
}
}

9 changes: 6 additions & 3 deletions Assets/AdultLink/TexturePanner/Examples/Scripts/Index.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AdultLink
{
public class Index : MonoBehaviour {

public class Index : MonoBehaviour {

public int index;
public int index;
}

}
41 changes: 22 additions & 19 deletions Assets/AdultLink/TexturePanner/Examples/Scripts/SetColor.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AdultLink
{
public class SetColor : MonoBehaviour {

public class SetColor : MonoBehaviour {

// Use this for initialization
public GameObject[] objects;
public Color newColor;
private Material[] mats;
void Start () {
mats = new Material[objects.Length];
for (int i = 0; i < objects.Length; i++) {
//Debug.Log(objects[i]);
mats[i] = objects[i].GetComponent<Renderer>().material;
//Debug.Log(mats[i]);
// Use this for initialization
public GameObject[] objects;
public Color newColor;
private Material[] mats;
void Start () {
mats = new Material[objects.Length];
for (int i = 0; i < objects.Length; i++) {
//Debug.Log(objects[i]);
mats[i] = objects[i].GetComponent<Renderer>().material;
//Debug.Log(mats[i]);
}
}
}

// Update is called once per frame
void FixedUpdate () {
for (int i = 0; i < mats.Length; i++) {
//Debug.Log(mats[i]);
mats[i].SetColor("_Color", newColor);
// Update is called once per frame
void FixedUpdate () {
for (int i = 0; i < mats.Length; i++) {
//Debug.Log(mats[i]);
mats[i].SetColor("_Color", newColor);
}
}
}

}

0 comments on commit 43e2d83

Please sign in to comment.