[AddComponentMenu("...")] 의 기능.

 

using System;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Api;
using GoogleMobileAds.Ump.Api;

namespace GoogleMobileAds.Samples
{
    /// <summary>
    /// Demonstrates how to use the Google Mobile Ads Unity plugin.
    /// </summary>
    [AddComponentMenu("GoogleMobileAds/Samples/GoogleMobileAdsController")]
    public class GoogleMobileAdsController : MonoBehaviour
    {
        // Always use test ads.
        // https://developers.google.com/admob/unity/test-ads
        internal static List<string> TestDeviceIds = new List<string>()
        {
            AdRequest.TestDeviceSimulator,
#if UNITY_IPHONE
            "96e23e80653bb28980d3f40beb58915c",
#elif UNITY_ANDROID
            "702815ACFC14FF222DA1DC767672A573"
#endif
        };
        
...

 

위의 코드는 구글애드몹에서 제공해준는 샘플 프로젝트 중에서 GoogleMobileAdsController.cs 의 일부인데, 

이때에 

    [AddComponentMenu("GoogleMobileAds/Samples/GoogleMobileAdsController")]

라는 어트리뷰트가 무슨 기능을 하는지 몰라서 찾아보았다. 

 

해당 어트리뷰트를 클래스 위에 작성하면, 

이와같이 Component 에 해당 클래스 파일을 등록해둘 수 있고, 

이 메뉴를 통해서 오브젝트에 해당 Component 를 타고 들어가서 원하는 클래스 파일을 선택하면 그 클래스 파일을 오브젝트에 바로 부착할 수 있다. 

 

물론 직접 드래그앤드롭으로 붙일 수 있지만, 이러한 어트리뷰트를 사용하면 클래스의 위치를 직접 알 필요도 없지 깔끔하게 알아서 붙여줄 수 있게 활용할 수 있다. 

혹시 다음에 이러한 기능이 필요하면 사용해보도록 하자. 

 

 

  Comments,     Trackbacks