コード例 #1
0
        /**
         * Add a new control button into the scene
         */
        public ControlButton AddControlButton(ControlButtonAsset controlButtonAsset)
        {
            if (!rootMap.ContainsKey(controlButtonAsset.category))
            {
                Debug.LogErrorFormat("ControlButtonManager ({0}) does not contain mapping for the {1} category", name, controlButtonAsset.category.ToString());
                return(null);
            }

            controlButtonPrefab.SetActive(false);
            var controlButtonInstance = Instantiate(controlButtonPrefab);
            var controlButton         = controlButtonInstance.GetComponent <ControlButton>();

            controlButtonInstance.name       = controlButtonAsset.name;
            controlButton.controlButtonAsset = controlButtonAsset;

            controlButton.transform.SetParent(rootMap[controlButtonAsset.category].transform, false);

            controlButtonInstance.SetActive(true);
            return(controlButton);
        }