public override void OnInspectorGUI()
        {
            GUILayout.Space(10);
            geometryType = (GeometryTypes)EditorGUILayout.EnumPopup("Type of visual", geometryType);

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Add visual"))
            {
                UrdfVisualExtensions.Create(urdfVisuals.transform, geometryType);
            }
            EditorGUILayout.EndHorizontal();
        }
        public static void Create(Transform parent, List <Link.Visual> visuals = null)
        {
            GameObject visualsObject = new GameObject("Visuals");

            visualsObject.transform.SetParentAndAlign(parent);
            UrdfVisuals urdfVisuals = visualsObject.AddComponent <UrdfVisuals>();

            visualsObject.hideFlags = HideFlags.NotEditable;
            urdfVisuals.hideFlags   = HideFlags.None;

            if (visuals != null)
            {
                foreach (Link.Visual visual in visuals)
                {
                    UrdfVisualExtensions.Create(urdfVisuals.transform, visual);
                }
            }
        }
Пример #3
0
        public static void Synchronize(Transform parent, List <Link.Visual> visuals = null)
        {
            if (parent.FindChildOrCreateWithComponent <UrdfVisuals>("Visuals", out GameObject visualsObject, out UrdfVisuals urdfVisuals))
            {
                visualsObject.hideFlags = HideFlags.NotEditable;
                urdfVisuals.hideFlags   = HideFlags.None;
            }

            //Create all visuals that are in the list but do not yet exist
            if (visuals != null)
            {
                foreach (Link.Visual visual in visuals)
                {
                    UrdfVisualExtensions.Create(urdfVisuals.transform, visual);
                }
            }

            //Destroy existing visuals that are not in the list
            var vis = visualsObject.GetComponentsInSelf <UrdfVisual>();

            vis.RemoveAll(x => visuals.Any(y => y.name == x.name));
            Utils.DestroyAll(vis);
        }