public override void OnInspectorGUI() { base.OnInspectorGUI(); CBControls wt = (CBControls)target; //wt.mAuto = GUILayout.Toggle(wt.mAuto, "mAuto"); if (GUILayout.Button("Up")) { wt.MoveFor(0); } //if (GUILayout.Button("Down")) //wt.MoveFor(1); if (GUILayout.Button("Forward")) { wt.MoveFor(2); } if (GUILayout.Button("Backward")) { wt.MoveFor(3); } if (GUILayout.Button("Left")) { wt.MoveFor(4); } if (GUILayout.Button("Right")) { wt.MoveFor(5); } }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { mStart = Input.mousePosition; if (duration < 0) { duration = Time.time; } else { duration = Time.time - duration; if (duration < 0.5f) { control.MoveFor((int)CBControls.MoveDir.Up); } duration = -1f; } } if (Input.GetMouseButtonUp(0)) { mEnd = Input.mousePosition; if (Vector3.Distance(mEnd, mStart) > 100f) { duration = -1f; mDirection = mEnd - mStart; if (Mathf.Abs(mDirection.x) > Mathf.Abs(mDirection.y)) { if (mDirection.x < 0) { control.MoveFor((int)CBControls.MoveDir.Lt); } else { control.MoveFor((int)CBControls.MoveDir.Rt); } } else { if (mDirection.y < 0) { control.MoveFor((int)CBControls.MoveDir.Bk); } else { control.MoveFor((int)CBControls.MoveDir.Fwd); } } } } }