Unity 5.6.0f3中IActiveBuildTargetChanged缺失编译报错求助
Hey there, let's work through this error step by step since you're new to Unity. Here's the breakdown and how to fix it:
Why this error happens
The script MobileControlRig.cs is trying to use an interface called IActiveBuildTargetChanged that doesn't exist in Unity 5.6.0f3. This interface was added in later Unity versions (around 2017+), so the code you're working with is incompatible with your school computer's older Unity install.
Step-by-step solution
Follow these straightforward steps to get your project compiling again:
Locate the problematic script
- In Unity's Project window (usually bottom-left of the editor), navigate to
Assets/_Complete-Game/MobileInput/Scripts/ - Double-click the
MobileControlRig.csfile to open it in your code editor (MonoDevelop or Visual Studio, whichever Unity launches by default).
- In Unity's Project window (usually bottom-left of the editor), navigate to
Remove the unsupported code from the script
- First, find the line at the top that reads
using UnityEditor.Build;— delete this entire line. - Next, look for the class definition line, which will look similar to:
Remove thepublic class MobileControlRig : MonoBehaviour, IActiveBuildTargetChanged, IActiveBuildTargetChangedportion so it becomes:public class MobileControlRig : MonoBehaviour - Finally, find the method that implements this interface (it will look like the code below) and delete the entire method, including its curly braces:
public void OnActiveBuildTargetChanged(BuildTarget previousTarget, BuildTarget newTarget) { // Any code inside these braces }
- First, find the line at the top that reads
Save and let Unity recompile
- Save the script in your code editor (press Ctrl+S on Windows).
- Switch back to Unity — it will automatically recompile the scripts. You should see the error disappear from the Console window.
Once compilation finishes without errors, you can click the Play button to test your player movement script!
内容的提问来源于stack exchange,提问作者Vampi Step

