private ActionButtonWithIconRemovable CreateBtn(ActionObjectMetadata metadata) { ActionButtonWithIconRemovable btn = Instantiate(ButtonPrefab, Content.transform); btn.transform.localScale = Vector3.one; btn.SetLabel(metadata.Type); if (metadata.Robot) { btn.SetIcon(AREditorResources.Instance.Robot); } else if (metadata.HasPose) { btn.SetIcon(AREditorResources.Instance.ActionObject); } else { btn.SetIcon(AREditorResources.Instance.NoPose); } btn.RemoveBtn.Button.onClick.AddListener(() => ShowRemoveActionObjectDialog(metadata.Type)); btn.Button.onClick.AddListener(() => AddObjectToScene(metadata.Type)); ButtonWithTooltip btnTooltip = btn.Button.GetComponent <ButtonWithTooltip>(); btnTooltip.SetDescription(metadata.Description); btnTooltip.SetInteractivity(!metadata.Disabled, metadata.Problem); return(btn); }
private void OnObjectTypesAdded(object sender, StringListEventArgs args) { foreach (string objectTypeName in args.Data) { if (ActionsManager.Instance.ActionObjectsMetadata.TryGetValue(objectTypeName, out ActionObjectMetadata actionObjectMetadata) && !actionObjectMetadata.Abstract && !actionObjectMetadata.CollisionObject) { ActionButtonWithIconRemovable btn = CreateBtn(actionObjectMetadata); foreach (ActionButtonWithIconRemovable t in Content.GetComponentsInChildren <ActionButtonWithIconRemovable>()) { if (t.GetLabel().CompareTo(btn.GetLabel()) > 0) { btn.transform.SetSiblingIndex(t.transform.GetSiblingIndex()); return; } } } } }