public void DeleteProfile(GenericGamepadProfile toDelete)
 {
     if (EditorUtility.DisplayDialog("Delete Gamepad Profile", "Are you sure you want to delete profile: " + toDelete.name + "?", "Yes", "No"))
     {
         AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(toDelete));
         RefreshAndSaveAssets();
     }
 }
Ejemplo n.º 2
0
 void NewProfile(GenericGamepadProfile profile)
 {
     if (!InputManager.instance._gamepads.Contains(profile))
     {
         InputManager.instance._gamepads.Add(profile);
         EditorUtility.SetDirty(InputManager.instance);
         ProjectTools.RefreshAndSave();
     }
 }
Ejemplo n.º 3
0
        private void Update()
        {
            for (int i = 0; i < m_gamepadStateText.Length; i++)
            {
                m_gamepadStateText[i].text = GamepadState.IsConnected((GamepadIndex)i) ? "Connected" : "Not Connected";
            }

            for (int i = 0; i < m_gamepadButtonText.Length; i++)
            {
                m_gamepadButtonText[i].text = GamepadState.GetButton((GamepadButton)i, m_selectedGamepad).ToString();
            }

            for (int i = 0; i < m_gamepadAxisText.Length; i++)
            {
                m_gamepadAxisText[i].text = GamepadState.GetAxis((GamepadAxis)i, m_selectedGamepad).ToString();
            }

            GenericGamepadStateAdapter adapter = GamepadState.Adapter as GenericGamepadStateAdapter;
            GenericGamepadProfile      profile = adapter[m_selectedGamepad];

            if (profile != null && profile.DPadType == GamepadDPadType.Axis)
            {
                if (GamepadState.GetButtonDown(GamepadButton.DPadUp, m_selectedGamepad))
                {
                    Debug.Log("DPadUp was pressed!");
                }
                if (GamepadState.GetButtonDown(GamepadButton.DPadDown, m_selectedGamepad))
                {
                    Debug.Log("DPadDown was pressed!");
                }
                if (GamepadState.GetButtonDown(GamepadButton.DPadLeft, m_selectedGamepad))
                {
                    Debug.Log("DPadLeft was pressed!");
                }
                if (GamepadState.GetButtonDown(GamepadButton.DPadRight, m_selectedGamepad))
                {
                    Debug.Log("DPadRight was pressed!");
                }

                if (GamepadState.GetButtonUp(GamepadButton.DPadUp, m_selectedGamepad))
                {
                    Debug.Log("DPadUp was released!");
                }
                if (GamepadState.GetButtonUp(GamepadButton.DPadDown, m_selectedGamepad))
                {
                    Debug.Log("DPadDown was released!");
                }
                if (GamepadState.GetButtonUp(GamepadButton.DPadLeft, m_selectedGamepad))
                {
                    Debug.Log("DPadLeft was released!");
                }
                if (GamepadState.GetButtonUp(GamepadButton.DPadRight, m_selectedGamepad))
                {
                    Debug.Log("DPadRight was released!");
                }
            }
        }
Ejemplo n.º 4
0
 public void DeleteProfile(GenericGamepadProfile toDelete)
 {
     if (EditorUtility.DisplayDialog("Delete Gamepad Profile", "Are you sure you want to delete profile: " + toDelete.name + "?", "Yes", "No"))
     {
         InputManager.instance._gamepads.Remove(toDelete);
         EditorUtility.SetDirty(InputManager.instance);
         AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(toDelete));
         ProjectTools.RefreshAndSave();
     }
 }
Ejemplo n.º 5
0
        public void DuplicateProfile(GenericGamepadProfile source)
        {
            string sourcePath = AssetDatabase.GetAssetPath(source);

            if (sourcePath.EndsWith(".asset"))
            {
                sourcePath = sourcePath.Substring(0, sourcePath.Length - 6);
            }
            GenericGamepadProfile newProfile = CreateNewGamepadProfile(System.IO.Path.GetFileName(sourcePath) + "_Duplicate");

            DuplicateGamepadProfile(source, newProfile);
            NewProfile(newProfile);
        }
        public void DuplicateProfile(GenericGamepadProfile source)
        {
            // GenericGamepadProfile source = gamepadProfiles[selectedProfileIndex];
            string sourcePath = AssetDatabase.GetAssetPath(source);

            if (sourcePath.EndsWith(".asset"))
            {
                sourcePath = sourcePath.Substring(0, sourcePath.Length - 6);
            }

            GenericGamepadProfile newProfile = CreateNewGamepadProfile(System.IO.Path.GetFileName(sourcePath) + "_Duplicate");

            DuplicateGamepadProfile(source, newProfile);
            RefreshAndSaveAssets();
        }
        public GenericGamepadProfile CreateNewGamepadProfile(string name)
        {
            string dir  = InputManager.fullResourcesDirectory + GamepadHandler.gamepadProfilesResourcesDirectory;
            string path = dir + "/" + name + ".asset";

            int x = 0;

            while (System.IO.File.Exists(path))
            {
                path = dir + "/" + name + x.ToString() + ".asset";
                x++;
            }
            GenericGamepadProfile profile = ScriptableObject.CreateInstance <GenericGamepadProfile>();

            AssetDatabase.CreateAsset(profile, path);
            RefreshAndSaveAssets();
            return(profile);
        }
Ejemplo n.º 8
0
        void DuplicateGamepadProfile(GenericGamepadProfile source, GenericGamepadProfile target)
        {
            SerializedObject s = new SerializedObject(source);
            SerializedObject t = new SerializedObject(target);

            for (int i = 0; i < buttons.Length; i++)
            {
                t.FindProperty(buttons[i]).intValue = s.FindProperty(buttons[i]).intValue;
            }
            for (int i = 0; i < axes.Length; i++)
            {
                t.FindProperty(axes[i]).intValue = s.FindProperty(axes[i]).intValue;
            }

            t.ApplyModifiedProperties();
            target.m_dpadType     = source.m_dpadType;
            target.platforms.list = source.platforms.list.MakeCopy();
            EditorUtility.SetDirty(target);
        }
Ejemplo n.º 9
0
        public GenericGamepadProfile CreateNewGamepadProfile(string name)
        {
            string dir  = InputManager.fullResourcesDirectory + GamepadHandler.gamepadProfilesResourcesDirectory;
            string path = dir + "/" + name + ".asset";

            int x = 0;

            while (System.IO.File.Exists(path))
            {
                path = dir + "/" + name + x.ToString() + ".asset";
                x++;
            }

            GenericGamepadProfile profile = AssetTools.CreateScriptableObject <GenericGamepadProfile>(path, true);

            NewProfile(profile);

            return(profile);
        }
 public void RenameProfile(GenericGamepadProfile profile, string newName)
 {
     AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(profile), newName);
     RefreshAndSaveAssets();
 }
 public void OnNewProfileSelection(GenericGamepadProfile profile)
 {
     profileSO = new SerializedObject(profile);
 }