예제 #1
0
        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);
        }
예제 #2
0
        public static void DeleteWidget(string id)
        {
            var prop = WidgetsLibrary.GetWidgetProperty(id);

            if (prop != null)
            {
                WidgetsLibrary.Widgets.Remove(prop);
            }
        }
예제 #3
0
        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;
            }
        }