Пример #1
0
        public static void Create(Transform parent, Plugin plugin = null)
        {
            UrdfPlugin urdfPlugin = parent.gameObject.AddComponent <UrdfPlugin>();

            if (plugin != null)
            {
                urdfPlugin.PluginText = plugin.text;
            }
        }
Пример #2
0
        public static void Create(Transform parent, Plugin plugin = null)
        {
            if (parent.GetComponentsInChildren <UrdfPlugin>().Any(x => x.PluginText == plugin.text))
            {
                //Already added. Skip it.
                return;
            }

            UrdfPlugin urdfPlugin = parent.gameObject.AddComponent <UrdfPlugin>();

            if (plugin != null)
            {
                urdfPlugin.PluginText = plugin.text;
            }
        }
Пример #3
0
        public static void Create(Transform robot, List <Plugin> plugins = null)
        {
            GameObject pluginsObject = new GameObject("Plugins");

            pluginsObject.transform.SetParentAndAlign(robot);
            pluginsObject.AddComponent <UrdfPlugins>();

            if (plugins == null)
            {
                return;
            }

            foreach (var plugin in plugins)
            {
                UrdfPlugin.Create(pluginsObject.transform, plugin);
            }
        }
Пример #4
0
        public static void Synchronize(Transform robot, List <Plugin> plugins = null)
        {
            if (robot.FindChildOrCreate("Plugins", out GameObject pluginsObject))
            {
                pluginsObject.AddComponent <UrdfPlugins>();
            }

            //Add or check all plugins
            foreach (var plugin in plugins)
            {
                UrdfPlugin.Create(pluginsObject.transform, plugin);
            }

            //Remove all plugins that are not in the plugin list
            var existingPlugins = pluginsObject.GetComponentsInSelf <UrdfPlugin>();

            existingPlugins.RemoveAll(x => plugins.Any(y => y.text == x.PluginText));
            Utils.DestroyAll(existingPlugins);
        }