public static bool Handle(WidgetContainer container) { if (!container) { return(false); } if (PrefabUtility.IsPartOfAnyPrefab(container)) { return(false); } var widgetPrefab = WidgetsLibrary.GetWidgetProperty(container.PropertyId)?.Value; var widgetPrefabPath = widgetPrefab ? GetAssetPath(widgetPrefab) : string.Empty; var currentPrefabPath = container.Current ? GetAssetPath(container.Current) : string.Empty; if (string.IsNullOrEmpty(widgetPrefabPath) || currentPrefabPath == widgetPrefabPath) { return(false); } var siblingIndex = ClearCurrentWidget(container); SetCurrentWidget(container, widgetPrefab, siblingIndex); AlignWidgetByContainer(container.Container, container.Current); return(true); }
public static void DeleteWidget(string id) { var prop = WidgetsLibrary.GetWidgetProperty(id); if (prop != null) { WidgetsLibrary.Widgets.Remove(prop); } }
public static void ChangeWidgetName(string id, string name) { if (string.IsNullOrEmpty(id)) { throw new InvalidOperationException(nameof(id)); } if (string.IsNullOrEmpty(name)) { throw new InvalidOperationException(nameof(name)); } var prop = WidgetsLibrary.GetWidgetProperty(id); if (prop != null) { prop.Name = name; } }