David Aronson
David Aronson

Reputation: 1

How do I find Assembly Reference?

I am currently making a 2D Platformer in Unity, and I still can't move the character because of the errors I have in this code. I am not sure how to find the assembly reference, so if someone could please explain it, that would be great.

Here's the error: Error CS0234 The type or namespace name 'IActiveBuildTargetChanged' does not exist in the namespace 'UnityEditor.Build' (are you missing an assembly reference?)

Thanks

using System;
    using UnityEngine;
    #if UNITY_EDITOR
using UnityEditor;
#endif

namespace UnityStandardAssets.Utility
{
#if UNITY_EDITOR

    [ExecuteInEditMode]
#endif
    public class PlatformSpecificContent : MonoBehaviour
#if UNITY_EDITOR
        , UnityEditor.Build.IActiveBuildTargetChanged
#endif
    {
        private enum BuildTargetGroup
        {
            Standalone,
            Mobile
        }

        [SerializeField]
        private BuildTargetGroup m_BuildTargetGroup;
        [SerializeField]
        private GameObject[] m_Content = new GameObject[0];
        [SerializeField]
        private MonoBehaviour[] m_MonoBehaviours = new MonoBehaviour[0];
        [SerializeField]
        private bool m_ChildrenOfThisObject;

#if !UNITY_EDITOR
    void OnEnable()
    {
        CheckEnableContent();
    }
#else
        public int callbackOrder
        {
            get
            {
                return 1;
            }
        }
#endif

#if UNITY_EDITOR

        private void OnEnable()
        {
            EditorApplication.update += Update;
        }


        private void OnDisable()
        {
            EditorApplication.update -= Update;
        }

        public void OnActiveBuildTargetChanged(BuildTarget previousTarget, BuildTarget newTarget)
        {
            CheckEnableContent();
        }

        private void Update()
        {
            CheckEnableContent();
        }
#endif


        private void CheckEnableContent()
        {
#if (UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_TIZEN || UNITY_STV )
        if (m_BuildTargetGroup == BuildTargetGroup.Mobile)
        {
            EnableContent(true);
        } else {
            EnableContent(false);
        }
#endif

#if !(UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_TIZEN || UNITY_STV )
            if (m_BuildTargetGroup == BuildTargetGroup.Mobile)
            {
                EnableContent(false);
            }
            else
            {
                EnableContent(true);
            }
#endif
        }


        private void EnableContent(bool enabled)
        {
            if (m_Content.Length > 0)
            {
                foreach (var g in m_Content)
                {
                    if (g != null)
                    {
                        g.SetActive(enabled);
                    }
                }
            }
            if (m_ChildrenOfThisObject)
            {
                foreach (Transform t in transform)
                {
                    t.gameObject.SetActive(enabled);
                }
            }
            if (m_MonoBehaviours.Length > 0)
            {
                foreach (var monoBehaviour in m_MonoBehaviours)
                {
                    monoBehaviour.enabled = enabled;
                }
            }
        }
    }
}

Upvotes: 0

Views: 416

Answers (1)

user47589
user47589

Reputation:

Use Google.

Googling IActiveBuildTargetChanged gives us the first result, which says this interface is in UnityEditor.Build starting with version 2017.1.

So include that assembly if you need to, and add a using statement to the top of your file if necessary.

If you already have this assembly referenced, verify your version. You might be using an older version of the assembly.

Upvotes: 1

Related Questions