Пример #1
0
        public static WindowLayoutElement AddLayoutElementComponent(string name, Transform root, int siblingIndex)
        {
            var go = new GameObject(name);

            go.transform.SetParent(root);
            go.transform.localScale    = Vector3.one;
            go.transform.localPosition = Vector3.zero;
            go.transform.localRotation = Quaternion.identity;

            go.AddComponent <RectTransform>();

            go.transform.SetSiblingIndex(siblingIndex);

            var layoutElement = go.AddComponent <WindowLayoutElement>();

            layoutElement.comment = "NEW LAYOUT ELEMENT";

            var canvas = go.AddComponent <CanvasGroup>();

            canvas.alpha              = 1f;
            canvas.blocksRaycasts     = true;
            canvas.interactable       = true;
            canvas.ignoreParentGroups = false;
            layoutElement.canvas      = canvas;

            //FlowSceneView.GetItem().SetLayoutDirty();
            FlowDatabase.SaveLayout(layoutElement.transform.root.GetComponent <WindowLayout>());

            return(layoutElement);
        }
Пример #2
0
        public static WindowLayout GenerateLayout(string filepath, FlowWindowLayoutTemplate layout)
        {
            filepath = filepath.Replace("//", "/");

            WindowLayout instance = null;

            var sourcepath = ADB.GetAssetPath(layout);

            filepath = AssetDatabase.GenerateUniqueAssetPath(filepath);

            System.IO.File.Copy(sourcepath, filepath, true);
            ADB.Refresh();

            var source = ADB.LoadAssetAtPath(filepath, typeof(GameObject)) as GameObject;
            var prefab = source.GetComponent <WindowLayout>();

            instance = UnityEditor.PrefabUtility.InstantiatePrefab(prefab) as WindowLayout;

            instance = FlowDatabase.ReplaceComponents <FlowWindowLayoutTemplate, WindowLayout>(instance as FlowWindowLayoutTemplate, typeof(WindowLayout));

            FlowDatabase.SaveLayout(instance);

            GameObject.DestroyImmediate(instance.gameObject);
            instance = (ADB.LoadAssetAtPath(filepath, typeof(GameObject)) as GameObject).GetComponent <WindowLayout>();

            return(instance);
        }
Пример #3
0
        public static void RemoveLayoutComponent(Transform element)
        {
            var root = element.root;

            GameObject.DestroyImmediate(element.gameObject);

            FlowDatabase.SaveLayout(root.GetComponent <WindowLayout>());
        }