コード例 #1
0
    //keep track of the game objects with icons to be display
    //takes in the parameter of the object that owns the icon object and the icon object itself
    public static void RegisterMapObject(GameObject o, GameObject i)
    {
        //create new game object to remove reference to prefab
        GameObject   img          = Instantiate(i);
        IconDropdown iconDropdown = img.GetComponent <IconDropdown>();

        //assign the icon script to have the camera object
        if (iconDropdown != null)
        {
            GameObject cam = o.transform.Find("Camera").gameObject;
            //if (cam != null)
            //    //iconDropdown.SetInteractiveObject(cam);
            //else
            //    Debug.LogError("Map Controller script cannot find the child object 'Camera' from " + cam.name + "game object");
        }
        else
        {
            Debug.LogError("Map Controller script cannot find container child from " + img.name);
        }

        fixedMapObjects.Add(new MapObject()
        {
            Icon = img.GetComponent <Sprite>(), Self = img, Owner = o
        });
    }
コード例 #2
0
 private void OnEnable()
 {
     icons = new Lazy <DropdownButton>(() => {
         var icon         = new IconDropdown(IconsGenerator.GetAllIcons().ToArray());
         icon.onSelected += item => {
             texture     = item.name;
             var t       = item.GetTexture();
             textureSize = new Vector2(t.width, t.height);
         };
         return(new DropdownButton(icon));
     });
 }