コード例 #1
0
    void Start()
    {
        instance = this;
        pfc      = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerFlightControl>();


        //Uncomment for Unity 5 to get rid of the warnings.
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible   = false;

        //Screen.lockCursor = true;


        deadzone_rect = new Rect((Screen.width / 2) - (deadzone_radius), (Screen.height / 2) - (deadzone_radius), deadzone_radius * 2, deadzone_radius * 2);

        if (pointerTexture == null)
        {
            Debug.LogWarning("(FlightControls) Warning: No texture set for the custom pointer!");
        }

        if (use_gamepad_input == false && use_mouse_input == false)
        {
            Debug.LogWarning("Select Input System");
        }
    }
コード例 #2
0
    void Start()
    {
        cp = Camera.main.gameObject.GetComponent <CustomPointer>();

        instance = this;

        mousePos = new Vector2(0, 0);
        DZ       = cp.deadzone_radius;

        roll = 0;         //Setting this equal to 0 here as a failsafe in case the roll axis is not set up.

        //Error handling, in case one of the inputs aren't set up.
        try {
            //Input.GetAxis("Thrust");
            thrustAction.ReadValue <double>();
            print(thrustAction.ReadValue <double>());
        }
        catch {
            thrust_exists = false;
            Debug.LogError("(Flight Controls) Thrust input axis not set up! Go to Edit>Project Settings>Input to create a new axis called 'Thrust' so the ship can change speeds.");
        }

        try {
            //Input.GetAxis("Roll");
            rollAction.ReadValue <double>();
            print(rollAction.ReadValue <double>());
        } catch {
            roll_exists = false;
            Debug.LogError("(Flight Controls) Roll input axis not set up! Go to Edit>Project Settings>Input to create a new axis called 'Roll' so the ship can roll.");
        }
    }
コード例 #3
0
    public override void OnInspectorGUI()
    {
        CustomPointer pointer = (CustomPointer)target;

        pointer.pointerTexture = (Texture)EditorGUILayout.ObjectField(new GUIContent("Pointer Texture", "The image for the pointer, generally a crosshair or dot."), pointer.pointerTexture, typeof(Texture), true);


        GUILayout.Label(new GUIContent("Input Systems (Uncheck for options)", "Choose which input the pointer will use."));
        if (pointer.use_mouse_input)
        {
            pointer.use_mouse_input = EditorGUILayout.Toggle(new GUIContent("Use Mouse", "Pointer will use mouse controls."), pointer.use_mouse_input);
        }
        else if (pointer.use_gamepad_input)
        {
            pointer.use_gamepad_input = EditorGUILayout.Toggle(new GUIContent("Use Gamepad", "Pointer will use gamepad joystick controls."), pointer.use_gamepad_input);
        }
        else
        {
            pointer.use_mouse_input   = EditorGUILayout.Toggle(new GUIContent("Use Mouse", "Pointer will use mouse controls. Uncheck to choose another input option."), pointer.use_mouse_input);
            pointer.use_gamepad_input = EditorGUILayout.Toggle(new GUIContent("Use Gamepad", "Pointer will use gamepad joystick controls. Uncheck to choose another input option."), pointer.use_gamepad_input);
        }

        EditorGUILayout.Separator();
        GUILayout.Label(new GUIContent("Deadzone and Centering", ""));

        pointer.deadzone_radius = EditorGUILayout.FloatField(new GUIContent("Deadzone Radius", "Size of the area in the center of the screen where input will be ignored."), pointer.deadzone_radius);
        pointer.center_lock     = EditorGUILayout.Toggle(new GUIContent("Visual center lock", "The pointer will be visually locked to the center. This is visual only: the cursor still functions as expected in the background, however the cursor will be drawn in the center of the screen. Recommended to be used with the 'Pointer Snaps to Center' option"), pointer.center_lock);

        pointer.pointer_returns_to_center = EditorGUILayout.BeginToggleGroup(new GUIContent("Pointer snaps to center", "The pointer will snap back into the deadzone radius."), pointer.pointer_returns_to_center);

        pointer.center_speed     = EditorGUILayout.FloatField(new GUIContent("Snap Speed", "How quickly the pointer will move towards the screen center, even when input is being received. Generally, this should only be used with controllers."), pointer.center_speed);
        pointer.instant_snapping = EditorGUILayout.Toggle(new GUIContent("Instant Snap on Idle", "If there is no input, the pointer will return to the screen center instantly. WARNING: FOR JOYSTICKS ONLY"), pointer.instant_snapping);

        EditorGUILayout.EndToggleGroup();

        EditorGUILayout.Separator();

        pointer.invert_y_axis = EditorGUILayout.Toggle(new GUIContent("Invert Y Axis", "Inverts Y input."), pointer.invert_y_axis);


        EditorGUILayout.Separator();
        GUILayout.Label(new GUIContent("Sensitivity", ""));
        pointer.mouse_sensitivity_modifier = EditorGUILayout.FloatField(new GUIContent("Mouse Speed Multiplier", "Affects how sensitive mouse input is."), pointer.mouse_sensitivity_modifier);
        pointer.thumbstick_speed_modifier  = EditorGUILayout.FloatField(new GUIContent("Thumbstick Speed Multiplier", "Affects how sensitive thumbstick input is."), pointer.thumbstick_speed_modifier);

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
コード例 #4
0
ファイル: CustomPointer.cs プロジェクト: NoelMelia/SpaceCore
    //The instance of this class (Should only be one)
    // Use this for initialization

    void Awake()
    {
        pointerPosition = new Vector2(Screen.width / 2, Screen.height / 2);
        //Set pointer position to center of screen
        instance = this;
    }
コード例 #5
0
 void Awake()
 {
     pointerPosition = new Vector2(Screen.width / 2, Screen.height / 2); //Set pointer position to center of screen
     instance        = this;
     mode_           = MouseMode.RELATIVE;
 }
コード例 #6
0
ファイル: LandTakeOff.cs プロジェクト: paraszen/ExploWorld
 void Start()
 {
     groundCameraScript = GetComponent <SimpleCameraController>();
     cpointer           = GetComponent <CustomPointer>();
     airCameraScript    = GetComponent <CameraFlightFollow>();
 }
コード例 #7
0
    public static CustomPointer instance; //The instance of this class (Should only be one)
    // Use this for initialization

    void Awake()
    {
        pointerPosition = new Vector2(Screen.width / 2, Screen.height / 2);          //Set pointer position to center of screen
        instance        = this;
        camera          = GetComponent <CameraFlightFollow>();
    }