-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRotate manager.cs
More file actions
59 lines (56 loc) · 1.7 KB
/
Copy pathRotate manager.cs
File metadata and controls
59 lines (56 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System.Collections;
using System.Collections.Generic;
using System.Reflection.Emit;
using UnityEditor.SceneManagement;
using UnityEngine;
public class Rotatemanager : MonoBehaviour
{
[Header("Assign")]
public float openr;//The angle when open.
public float closer;//The angle when closed.
public GameObject attached;//This is the object you want to rotate. For simple applications, Attach the object this script is attached to
[Header("States")]
public bool open = false;
public bool interactable; //Can you do anything besides opening and closing it/does left click have any effect
public bool closable; // can you close it or smth
public bool Lock=false; // if true the door is locked
// Start is called before the first frame update
public void OnMouseOver()
{
//if you open door
if (!closable)
{
goto interact;
}
if (Input.GetMouseButtonDown(0)&&!Lock)
{
if (open)
{
attached.GetComponent<RotateOpen>().smoothrotation(closer);
}
else
{
attached.GetComponent<RotateOpen>().smoothrotation(openr);
}
open = !open;
}
interact:
if (!interactable)
{
return;
}
//interactable code like running a function
}
public void ForceToggle()
{
if (open)
{
attached.GetComponent<RotateOpen>().smoothrotation(closer);
}
else
{
attached.GetComponent<RotateOpen>().smoothrotation(openr);
}
open = !open;
}
}