Advertisement
SteamGear

Untitled

Jul 3rd, 2020
1,434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.06 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. [ExecuteInEditMode]
  6. public class MPCNC_Definition : MonoBehaviour
  7. {
  8.     [Range(10, 250)]
  9.     public float sizeX, sizeY, sizeZ;
  10.  
  11.     public Vector3 ToolPosition;
  12.  
  13.     [HideInInspector]
  14.     public GameObject rodX1, rodX2, rodX3, rodZ1, rodZ2, rodZ3;
  15.     [HideInInspector]
  16.     public GameObject CornerBL, CornerTL, CornerTR, CornerBR;
  17.     [HideInInspector]
  18.     public GameObject XBurly, XBurly2, ZBurly, ZBurly2;
  19.  
  20.     private float offsetCorrection = -2.35f;
  21.  
  22.     // Use this for initialization
  23.     void Start()
  24.     {
  25.     }
  26.  
  27.     // Update is called once per frame
  28.     void Update()
  29.     {
  30.         ToolPosition = new Vector3(Mathf.Clamp(ToolPosition.x, 0, sizeX + 2 * offsetCorrection), Mathf.Clamp(ToolPosition.y, -float.MaxValue, float.MaxValue), Mathf.Clamp(ToolPosition.z, 0, sizeZ + 2 * offsetCorrection));
  31.         Vector3 offset = CornerBL.transform.position;
  32.  
  33.         //Rod Resize
  34.         rodZ1.transform.localScale = new Vector3(2.5f, sizeZ / 2, 2.5f);
  35.         rodZ2.transform.localScale = new Vector3(2.5f, sizeZ / 2, 2.5f);
  36.         rodZ3.transform.localScale = new Vector3(2.5f, sizeZ / 2, 2.5f);
  37.         rodX1.transform.localScale = new Vector3(2.5f, sizeX / 2, 2.5f);
  38.         rodX2.transform.localScale = new Vector3(2.5f, sizeX / 2, 2.5f);
  39.         rodX3.transform.localScale = new Vector3(2.5f, sizeX / 2, 2.5f);
  40.  
  41.         //Frame Assembly
  42.         CornerTL.transform.position = offset + new Vector3(0, 0, sizeZ) + 2 * new Vector3(0, 0, offsetCorrection);
  43.         CornerBR.transform.position = offset + new Vector3(sizeX, 0, 0) + 2 * new Vector3(offsetCorrection, 0, 0);
  44.         CornerTR.transform.position = offset + new Vector3(sizeX, 0, sizeZ) + 2 * new Vector3(offsetCorrection, 0, offsetCorrection);
  45.  
  46.         //Rod Positions
  47.         rodZ1.transform.position = offset + new Vector3(0, 15, sizeZ / 2) + new Vector3(0, 0, offsetCorrection);
  48.         rodZ2.transform.position = offset + new Vector3(sizeX, 15, sizeZ / 2) + new Vector3(offsetCorrection * 2, 0, offsetCorrection);
  49.         rodZ3.transform.position = offset + new Vector3(0, 21.5f, sizeZ / 2) + new Vector3(ToolPosition.x, 0, offsetCorrection);
  50.         rodX1.transform.position = offset + new Vector3(sizeX / 2, 17.5f, 0) + new Vector3(offsetCorrection, 0, 0);
  51.         rodX2.transform.position = offset + new Vector3(sizeX / 2, 17.5f, sizeZ) + new Vector3(offsetCorrection, 0, offsetCorrection * 2);
  52.         rodX3.transform.position = offset + new Vector3(sizeX / 2, 19.2f, 0) + new Vector3(offsetCorrection, 0, ToolPosition.z);
  53.  
  54.         //Burly Position
  55.         ZBurly.transform.position = offset + new Vector3(0, 15.45f, ToolPosition.z);
  56.         ZBurly2.transform.position = offset + new Vector3(sizeX, 15.45f, ToolPosition.z) + 2 * new Vector3(offsetCorrection, 0, 0);
  57.         XBurly.transform.position = offset + new Vector3(ToolPosition.x, 17.8f, 0);
  58.         XBurly2.transform.position = offset + new Vector3(ToolPosition.x, 17.8f, sizeZ) + 2 * new Vector3(0, 0, offsetCorrection);
  59.  
  60.         //Middle Assembly
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement