示例#1
0
 //------------------------------------------------------------------------------------------------
 // Use this for initialization
 void Awake()
 {
     bloodEffects        = GetComponentsInChildren <ParticleSystem> ();
     rigidbody           = GetComponent <Rigidbody> ();
     collider            = GetComponent <Collider> ();
     orbSpawner          = transform.FindChild("OrbSpawner");
     bunnySpawner        = GameObject.Find("BunnySpawner").transform;
     spline [0].position = transform.position;
     NewTarget();
     spline.Build();
 }
示例#2
0
        //------------------------------------------------------------------------------------------------
        public void OnSceneGUI()
        {
            Spline spline = target as Spline;

            if (spline.transform.hasChanged)
            {
                spline.Build();
            }

            if (spline.knots.Count > 0)
            {
                Handles.Label(spline.knots[0].position + Vector3.up, "Start");
                Handles.Label(spline.knots[spline.knots.Count - 1].position + Vector3.up, "End");
            }

            for (int index = 0; index < spline.knots.Count; index++)
            {
                EditorGUI.BeginChangeCheck();
                Vector3    newPosition = Vector3.zero;
                Quaternion newRotation = Quaternion.identity;

                if (Tools.current == Tool.Move)
                {
                    newPosition = Handles.PositionHandle(spline.knots[index].position, spline.knots[index].rotation);
                }
                if (Tools.current == Tool.Rotate)
                {
                    newRotation = Handles.RotationHandle(spline.knots[index].rotation, spline.knots[index].position);
                }

                if (EditorGUI.EndChangeCheck())
                {
                    changingKnot = spline.knots[index];
                    Undo.RecordObject(spline.knots[index], spline.knots[index].name + " Changed");
                    if (Tools.current == Tool.Move)
                    {
                        spline.knots[index].position = newPosition;
                    }
                    if (Tools.current == Tool.Rotate)
                    {
                        spline.knots[index].rotation = newRotation;
                    }
                    spline.Build();
                }
                else
                {
                    changingKnot = null;
                    Repaint();
                }
            }
        }
示例#3
0
        //------------------------------------------------------------------------------------------------
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();

            Spline myScript = (Spline)target;

            if (changingKnot != null)
            {
                GUILayout.Label("Changing " + changingKnot.name);
            }
            if (GUILayout.Button("Build"))
            {
                myScript.Build();
                SceneView.RepaintAll();
            }
        }