Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @script ExecuteInEditMode()
- var rotateObj:Transform; //This is the empty object. The object being rotated is parented to this object.
- private var focusTrigger = false;
- private var smooth: float = 2;
- var speed:float = 150;
- var iDetails:Texture2D;
- var iDetailsOffset:Vector2;
- var iDetailStyle:GUIStyle;
- private var iDetailsB = false;
- var iFocus:Texture2D;
- var iFocusOffset:Vector2;
- var iFocusStyle:GUIStyle;
- private var iFocusB = false;
- var iFocusR:Texture2D;
- var iFocusROffset:Vector2;
- var iFocusRStyle:GUIStyle;
- private var iFocusRB = false;
- var iFocusT:Texture2D;
- var iFocusTOffset:Vector2;
- var iFocusTStyle:GUIStyle;
- private var iFocusTB = false;
- var iInfo:Texture2D;
- var iInfoOffset:Vector2;
- var iInfoStyle:GUIStyle;
- private var iInfoB = false;
- var info:Texture2D;
- var infoOffset:Vector2;
- var infoStyle:GUIStyle;
- private var infoB = false;
- function OnGUI() {
- iDetailsB = GUI.Button(Rect(iDetailsOffset.x,iDetailsOffset.y,iDetails.width,iDetails.height),"",iDetailStyle);
- iFocusB = GUI.Button(Rect(iFocusOffset.x,iFocusOffset.y,iFocus.width,iFocus.height),"",iFocusStyle);
- iFocusRB = GUI.Button(Rect(iFocusROffset.x,iFocusROffset.y,iFocusR.width,iFocusR.height),"",iFocusRStyle);
- iFocusTB = GUI.Button(Rect(iFocusTOffset.x,iFocusTOffset.y,iFocusT.width,iFocusT.height),"",iFocusTStyle);
- iInfoB = GUI.Button(Rect(iInfoOffset.x,iInfoOffset.y,iInfo.width,iInfo.height),"",iInfoStyle);
- infoB = GUI.Button(Rect(infoOffset.x,infoOffset.y,info.width,info.height),"",infoStyle);
- }
- function start(){
- Camera.main.transform.LookAt(rotateObj);
- }
- function Update(){
- if(iDetailsB){
- }
- if(iFocusB){
- focusTrigger = true;
- }
- if(focusTrigger == true){//Rotate the object to view it from a 3/4 view. Currently it isn't a smooth transition, just a quick jump.
- //Also focusTrigger never equals false even though the if statement it is part of triggers fine.
- rotateObj.transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.identity, Time.deltaTime*smooth);;
- if(rotateObj.transform.rotation == Quaternion.identity) focusTrigger = false;
- Camera.main.transform.LookAt(rotateObj);
- }
- if(iFocusRB){//Rotate the object to view it from the right side. Currently it isn't a smooth transition, just a quick jump.
- rotateObj.transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(90, 0, 0), Time.deltaTime*smooth);;
- Camera.main.transform.LookAt(rotateObj);
- }
- if(iFocusTB){//Rotate the objec to view it from the top
- }
- if(iInfoB){//Show info
- }
- if(infoB){//More info
- }
- if(Input.GetMouseButton(0)){//Checks to see if the mouse is pressed and rotates the object accordingly. This code works!!!
- rotateObj.transform.Rotate(Vector3(Input.GetAxis("Mouse Y"), Input.GetAxis("Mouse X")*-1, 0) * Time.deltaTime * speed);
- Camera.main.transform.LookAt(rotateObj);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement