SingleNose.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEditor;
  5. //double nose -.19, -.16, .45
  6. //scale .1
  7. //single nose z: .4 - .8
  8. //single nose
  9. [ExecuteInEditMode]
  10. public class SingleNose : MonoBehaviour
  11. {
  12. GameObject cameraObject;
  13. [Range(0,1)]
  14. public float yPosition = .5f;
  15. [Range(0,1)]
  16. public float zPosition = .5f;
  17. [Range(0f,1f)]
  18. public float noseWidth = 1;
  19. [Range(0f, 1f)]
  20. public float noseFlatness = 1;
  21. public Color noseColor;
  22. void Awake()
  23. {
  24. //if we found the main camera, set ourselves up as a child
  25. cameraObject = transform.parent.gameObject;
  26. if(cameraObject != null){
  27. transform.parent = cameraObject.transform;
  28. transform.localPosition = new Vector3(0,0,0);
  29. }
  30. }
  31. // Update is called once per frame
  32. void Update()
  33. {
  34. float zPos = Mathf.Lerp(0.4f, 0.8f, zPosition);
  35. float yPos = Mathf.Lerp(-0.5f, 0.5f, yPosition);
  36. float xScale = Mathf.Lerp(0.05f,.15f, noseWidth);
  37. float yScale = Mathf.Lerp(0.05f, .25f, 1 - noseFlatness);
  38. float zScale = Mathf.Lerp(.03f, .15f, .5f);
  39. transform.localScale = new Vector3(xScale,yScale,zScale);
  40. transform.localPosition = new Vector3(transform.localPosition.x,
  41. yPos,
  42. zPos);
  43. GetComponent<Renderer>().sharedMaterial.color = noseColor;
  44. }
  45. }