Hiya. Im having problems doing what seems like it should be a simple task.
From my Options menu, I simply want to allow the user to swap between MouseAndKeyboard controls or KeyboardOrController.
From reading other posts, I understand that I can write a custom Action using: AC.KickStarter.settingsManager.inputMethod = InputMethod.MouseAndKeyboard;
But I cant seem to figure out how to call this script.
I've followed the tutorial for creating Custom Actions, but I cant seem to get that to work either. Despite following all the steps, nothing ever shows up in my Actions Manager.
I can't figure out what I'm doing wrong. HELP!!!
Comments
Another custom Action tutorial, in which one is made for a custom option field, can be found here.
It sounds like you haven't provided a class type in the GetComponent function - see this entry of Unity's documentation for more on its use. However, without knowing the exact code it's not possible to say for sure. Please post the code line that the error message is referring to. What's on line 41 of your custom Action?
Man, I just cannot get the hang of custom action scripts!
Im still trying to create a custom action that allows the player to set their input type. I tried to write a simple custom action that simply allows an action to set the input type as Mouse and Keyboard, but I keep getting this error:
'..Action_setKeyboardMouse.cs' must derive from AC's Action class in order to be available as an Action.
Here is my script:
/*
*
* Adventure Creator
* by Chris Burton, 2013-2019
*
* "ActionChangeInput.cs"
*
* This is a blank action template.
*
*/
using UnityEngine;
if UNITY_EDITOR
using UnityEditor;
endif
namespace AC
{
}
The Action's class name must match it's filename. Your script shows the class name is "ActionSetMouseKeyboard", but your error message suggests the filename is "Action_setKeyboardMouse". Rename this to match the class name and restart Unity.
Well that seems to have removed the error (Thank you!), but now Im facing a different issue.
I'm using Salsa for Lipsync and facial expressions (Which works great!) but it requires that I set the Custom Action Scripts directory to a specific path:
"..Assets\Crazy Minnow Studio\Addons\AdventureCreator\Actions"
So instead of creating a new directory for my own custom actions (As shown in the tutorials) I dropped my new custom action into this folder. However, when I do this my project opens WITHOUT Adventure Creator. (Removing the script from the folder seems to remedy that problem)
Can I set multiple folder directories for custom action scripts? I'm scared that changing the directory will eliminate/disconnect the custom SALSA based actions Ive been using.
Thoughts?
Why is that? If this is a custom Action, they do need to all be in the same place, but their location should be unimportant. You could likely ignore their advice and just drag the Action scripts they provide into your own custom directory.
If there's a compilation error, all custom tools (not just AC) will fail to load. Check your Console for error messages.
Anyone willing to just write a quick script for me since I cant seem to get the hang of this? A;; I want is a custom action script that will set the input control method as Mouse & Keyboard. (I'll also need another that sets the input method as Controller, but Im hoping once I see a script for Keyboard/Mouse I can figure the rest out for myself.
I have no idea what I'm doing wrong.
Thanks
Your original script should set the input method Mouse And Keyboard - what's the issue, exactly?
To also change the input method to Keyboard Or Controller, it'd be easier to simply expose the intended input method as a control in the same Action. Something like:
(I moved it to the Input category and tidied up, too)
Okay, so Ive copied that script over exactly and named the script appropriately, but Im still getting an error:
Instance of ActionSetMouseKeyboard couldn't be created. The the script class needs to derive from ScriptableObject.
UnityEngine.ScriptableObject:CreateInstance(String)
AC.AdventureCreator:RefreshActions() (at Assets/AdventureCreator/Scripts/Managers/Editor/AdventureCreator.cs:563)
AC.AdventureCreator:OnEnable() (at Assets/AdventureCreator/Scripts/Managers/Editor/AdventureCreator.cs:48)
UnityEditorInternal.InternalEditorUtility:LoadSerializedFileAndForget(String)
UnityEditor.WindowLayout:LoadWindowLayout(String, Boolean)
Also, this error:
Assets/Crazy Minnow Studio/Addons/AdventureCreator/Actions/ActionSetMouseKeyboard.cs(23,31): error CS0161: `AC.ActionSetMouseKeyboard.Run()': not all code paths return a value
As you can see, I'm still using the path inside the CrazyMinnow plug in folder as my Custom Action Scripts folder, but I assume that shouldnt make a difference as long as Ive set that folder as the default for custom action scripts, which I have.
My mistake. Replace the Run function with the following:
Hopefully that should solve both errors.
Fantastic! This is working perfectly! Thank you so much!