Exemplo n.º 1
0
        public void Init(Rect position, SerializedProperty property, GUIContent label)
        {
            if (property == null)
            {
                return;
            }
            if (this.inited == true)
            {
                return;
            }

            this.window = (property.serializedObject.targetObject as LayoutWindowType);

            this.items      = new List <SerializedProperty>();
            this.components = new List <UnityEngine.UI.Windows.Types.Layout.Component>();
            for (int i = 0; i < property.arraySize; ++i)
            {
                var element = property.GetArrayElementAtIndex(i);
                if (this.window.GetCurrentLayout().layout == null)
                {
                    continue;
                }

                var rootElement = this.window.GetCurrentLayout().layout.GetRootByTag(this.window.GetCurrentLayout().components[i].tag);
                if (rootElement != null && rootElement.showInComponentsList == true)
                {
                    this.components.Add(this.window.GetCurrentLayout().components[i]);
                    this.items.Add(element);
                }
            }

            this.onItemDraw = (rect, item) => {
                var h = 0f;
                return(LayoutSettingsEditor.OnItemDraw(this.window, this.items, this.components, true, true, rect, item, out h));
            };

            System.Func <int, float> getHeight = (index) => {
                var h = 56f;
                LayoutSettingsEditor.OnItemDraw(this.window, this.items, this.components, false, true, new Rect(), this.items[index], out h);

                return(h);
            };

            this.elements = new ReorderableListControl(ReorderableListFlags.HideAddButton |
                                                       ReorderableListFlags.HideRemoveButtons |
                                                       ReorderableListFlags.DisableAutoScroll |
                                                       ReorderableListFlags.DisableReordering);

            this.adaptor = new ComponentsListAdaptor <SerializedProperty>(this.items, this.onItemDraw, getHeight);

            this.inited = true;
        }
		public void Init(Rect position, SerializedProperty property, GUIContent label) {
			
			if (property == null) return;
			if (this.inited == true) return;
			
			this.window = (property.serializedObject.targetObject as LayoutWindowType);

			this.items = new List<SerializedProperty>();
			this.components = new List<UnityEngine.UI.Windows.Types.Layout.Component>();
			for (int i = 0; i < property.arraySize; ++i) {
				
				var element = property.GetArrayElementAtIndex(i);
				if (this.window.layout.layout == null) continue;
				
				var rootElement = this.window.layout.layout.GetRootByTag(this.window.layout.components[i].tag);
				if (rootElement != null && rootElement.showInComponentsList == true) {
					
					this.components.Add(this.window.layout.components[i]);
					this.items.Add(element);
					
				}
				
			}
			
			this.onItemDraw = (rect, item) => {
				
				var h = 0f;
				return LayoutSettingsEditor.OnItemDraw(this.window, this.items, this.components, true, true, rect, item, out h);
				
			};
			
			System.Func<int, float> getHeight = (index) => {
				
				var h = 56f;
				LayoutSettingsEditor.OnItemDraw(this.window, this.items, this.components, false, true, new Rect(), this.items[index], out h);
				
				return h;
				
			};
			
			this.elements = new ReorderableListControl(ReorderableListFlags.HideAddButton |
			                                           ReorderableListFlags.HideRemoveButtons |
			                                           ReorderableListFlags.DisableAutoScroll |
			                                           ReorderableListFlags.DisableReordering);
			
			this.adapter = new ComponentsListAdaptor<SerializedProperty>(this.items, this.onItemDraw, getHeight);
			
			this.inited = true;
			
		}
Exemplo n.º 3
0
        public static void CreateLayout()
        {
            LayoutWindowType layoutScreen = null;

            var obj  = Selection.activeObject;
            var path = AssetDatabase.GetAssetPath(obj.GetInstanceID());

            if (path.Length > 0 && Directory.Exists(path) == true)
            {
            }
            else if (Selection.activeGameObject != null)
            {
                var screen = Selection.activeGameObject.GetComponent <WindowBase>();
                if (screen != null)
                {
                    var splitted = path.Split('/');
                    path = string.Join("/", splitted, 0, splitted.Length - 2).Trim('/');

                    path = path + "/Layouts";
                    if (Directory.Exists(path) == true)
                    {
                        layoutScreen = screen as LayoutWindowType;
                    }
                }
            }

            FlowChooserFilterWindow.Show <FlowWindowLayoutTemplate>(null, (element) => {
                // on select

                // Create an instance
                var layoutPrefab = FlowDatabase.GenerateLayout(path + "/" + element.name + "Layout.prefab", element);

                if (layoutScreen != null)
                {
                    layoutScreen.layout.layout = layoutPrefab;
                    EditorUtility.SetDirty(layoutScreen);
                }

                Selection.activeObject = layoutPrefab;
            }, (element) => {
                // on gui

                var style      = new GUIStyle(GUI.skin.label);
                style.wordWrap = true;

                GUILayout.Label(element.comment, style);
            }, strongType: true);
        }
			public Rect GetComponentRect(LayoutWindowType screen, WindowComponentBase component) {

				//var rect = (component.transform as RectTransform).rect;
				
				var corners = new Vector3[4];
				(component.transform as RectTransform).GetWorldCorners(corners);
				
				var leftBottom = this.GetScreenPoint(screen, component, corners[0]);
				var topRight = this.GetScreenPoint(screen, component, corners[2]);

				var rect = new Rect();
				rect.x = leftBottom.x;
				rect.y = leftBottom.y;
				rect.width = topRight.x - leftBottom.x;
				rect.height = topRight.y - leftBottom.y;

				return rect;

			}
Exemplo n.º 5
0
        public static WindowLayout GetLayout(int windowId, out LayoutWindowType screen)
        {
            screen = null;

            var window = FlowSystem.GetWindow(windowId);

            if (window == null)
            {
                return(null);
            }

            screen = window.GetScreen() as LayoutWindowType;
            if (screen == null || screen.layout.layout == null)
            {
                return(null);
            }

            return(screen.layout.layout);
        }
Exemplo n.º 6
0
        public override void OnFlowWindowScreenMenuGUI(FD.FlowWindow windowSource, GenericMenu menu)
        {
            menu.AddItem(new GUIContent("Components Editor..."), on: false, func: (object win) => {
                var window = win as FD.FlowWindow;
                var screen = window.GetScreen() as LayoutWindowType;
                if (screen != null)
                {
                    this.flowEditor.SetDisabled();
                    //this.window = window;
                    this.screen = screen;
                    this.editor = Editor.CreateEditor(window.GetScreen()) as IPreviewEditor;

                    this.component          = null;
                    this.hovered            = null;
                    this.element            = null;
                    this.listScrollPosition = Vector2.zero;
                    var serializedObject    = new SerializedObject(this.screen);
                    var layout     = serializedObject.FindProperty("layout");
                    var components = layout.FindPropertyRelative("components");
                    this.props.Clear();
                    for (int i = 0; i < components.arraySize; ++i)
                    {
                        var component = components.GetArrayElementAtIndex(i);
                        this.props.Add(component);

                        var componentParametersEditor = this.screen.layout.components[i].OnComponentChanged(this.screen, this.screen.layout.components[i].component);
                        if (componentParametersEditor != null)
                        {
                            var e = Editor.CreateEditor(componentParametersEditor) as IParametersEditor;
                            this.screen.layout.components[i].componentParametersEditor = e;
                        }
                    }

                    this.settingsScrollPosition = Vector2.zero;

                    this.opened = true;
                }
            }, userData: windowSource);
        }
Exemplo n.º 7
0
        public static SerializedProperty OnItemDraw(LayoutWindowType window, List <SerializedProperty> items, List <UnityEngine.UI.Windows.Types.Layout.Component> components, bool draw, bool withParameters, Rect rect, SerializedProperty item, out float elementHeight)
        {
            if (LayoutSettingsEditor.componentParametersSearched == null ||
                LayoutSettingsEditor.componentParametersSearched.Count != components.Count)
            {
                LayoutSettingsEditor.componentParametersSearched = new List <bool>();
                for (int i = 0; i < components.Count; ++i)
                {
                    LayoutSettingsEditor.componentParametersSearched.Add(false);
                }
            }

            var startY       = rect.y + 2f;
            var offset       = 2f;
            var heightOffset = 20f;

            elementHeight = 0f;
            rect.y        = startY;

            var index = items.IndexOf(item);

            if (index < 0 || index >= items.Count)
            {
                return(item);
            }
            if (item == null)
            {
                return(null);
            }

            var descr        = item.FindPropertyRelative("description");
            var tag          = item.FindPropertyRelative("tag");
            var component    = item.FindPropertyRelative("component");
            var sortingOrder = item.FindPropertyRelative("sortingOrder");

            if (descr == null ||
                tag == null ||
                component == null ||
                sortingOrder == null)
            {
                return(item);
            }

            var parameters = item.FindPropertyRelative("componentParameters");
            var componentParametersEditor = components[index].componentParametersEditor;

            if (rect.Contains(Event.current.mousePosition) == true)
            {
                //WindowLayoutElement.waitForComponentConnectionElementTemp = window.GetCurrentLayout().layout.GetRootByTag((LayoutTag)tag.enumValueIndex);
                LayoutSettingsEditor.selectedTagIndex = tag.enumValueIndex;
            }

            if (LayoutSettingsEditor.selectedTagIndex == tag.enumValueIndex)
            {
                var _offset = 4f;
                var newRect = new Rect(rect.x - _offset, rect.y - _offset, rect.width + _offset * 2f, rect.height + _offset);

                LayoutSettingsEditor.selectedTagRect = newRect;

                var oldColor = GUI.color;
                GUI.color = new Color(0f, 1f, 0f, 0.2f);
                GUI.Box(newRect, string.Empty, EditorStyles.textArea);
                GUI.Box(newRect, string.Empty, EditorStyles.popup);
                GUI.color = oldColor;
            }

            /*if (active == true && focused == true) {
             *
             *      //var window = (property.serializedObject.targetObject as LayoutWindowType);
             *      WindowLayoutElement.waitForComponentConnectionElementTemp = window.layout.layout.GetRootByTag((LayoutTag)tag.enumValueIndex);
             *      WindowLayoutElement.waitForComponentConnectionTemp = true;
             *
             * } else {
             *
             *      if (active == true) {
             *
             *              WindowLayoutElement.waitForComponentConnectionElementTemp = null;
             *              WindowLayoutElement.waitForComponentConnectionTemp = false;
             *
             *      }
             *
             * }*/

            var title  = "Description";
            var height = EditorGUI.GetPropertyHeight(descr, new GUIContent(title)) + offset;

            rect.height = height - offset;
            if (draw == true)
            {
                EditorGUI.LabelField(rect, descr.stringValue, EditorStyles.boldLabel);
                EditorGUI.LabelField(rect, tag.enumNames[tag.enumValueIndex], ME.Utilities.CacheStyle("WindowLayoutProperty.Styles.tag", "tag", (name) => {
                    var style       = new GUIStyle(EditorStyles.boldLabel);
                    style.alignment = TextAnchor.MiddleRight;
                    return(style);
                }));
            }

            title       = "Component";
            rect.y     += height;
            height      = EditorGUI.GetPropertyHeight(component, new GUIContent(title)) + offset;
            rect.height = height - offset;

            {
                var oldComponent = component.objectReferenceValue;

                var nRect       = rect;
                var buttonWidth = 30f;
                nRect.width -= buttonWidth;
                if (draw == true)
                {
                    EditorGUI.PropertyField(nRect, component, new GUIContent(title), true);
                }

                //Debug.Log(oldComponent + " == " + component.objectReferenceValue + " :: " + (oldComponent == component.objectReferenceValue));
                var newComponent = component.objectReferenceValue;
                if (oldComponent != newComponent)
                {
                    //Debug.Log("NEW COMP: " + newComponent);
                    parameters.objectReferenceValue = components[index].OnComponentChanged(window, newComponent as WindowComponent);
                    //Debug.Log("NEW COMP: " + parameters.objectReferenceValue);
                    components[index].componentParametersEditor = null;
                    item.serializedObject.ApplyModifiedPropertiesWithoutUndo();

                    UnityEditor.EditorUtility.SetDirty(window);
                }

                if (newComponent == null && components[index].componentResource.id != 0)
                {
                    components[index].OnComponentChanged(window, null);
                    components[index].componentParametersEditor = null;
                    item.serializedObject.ApplyModifiedPropertiesWithoutUndo();

                    UnityEditor.EditorUtility.SetDirty(window);
                }

                nRect.x    += nRect.width;
                nRect.width = buttonWidth;
                if (draw == true)
                {
                    var i = index;
                    GUILayoutExt.DrawComponentChooser(nRect, window.gameObject, components[i].component, (elem) => {
                        if (component.objectReferenceValue != elem)
                        {
                            component.objectReferenceValue = elem;
                            var c = component.objectReferenceValue;
                            parameters.objectReferenceValue         = components[i].OnComponentChanged(window, c as WindowComponent);
                            components[i].componentParametersEditor = null;
                            item.serializedObject.ApplyModifiedPropertiesWithoutUndo();

                            UnityEditor.EditorUtility.SetDirty(window);
                        }
                    });
                }
            }

            title       = "Sorting Order";
            rect.y     += height;
            height      = EditorGUI.GetPropertyHeight(sortingOrder, new GUIContent(title)) + offset;
            rect.height = height - offset;
            if (draw == true)
            {
                var oldValue = sortingOrder.intValue;
                EditorGUI.PropertyField(rect, sortingOrder, new GUIContent(title), true);
                if (sortingOrder.intValue < 0)
                {
                    sortingOrder.intValue = 0;
                }
                if (oldValue != sortingOrder.intValue)
                {
                    item.serializedObject.ApplyModifiedPropertiesWithoutUndo();
                    UnityEditor.EditorUtility.SetDirty(window);
                }
            }

            if (parameters.objectReferenceValue == null && LayoutSettingsEditor.componentParametersSearched[index] == false)
            {
                components[index].OnComponentChanged(window, components[index].component);
                LayoutSettingsEditor.componentParametersSearched[index] = true;

                UnityEditor.EditorUtility.SetDirty(window);
            }

            if (withParameters == true)
            {
                var editor = componentParametersEditor;
                if (editor == null && parameters.objectReferenceValue != null)
                {
                    var e = Editor.CreateEditor(parameters.objectReferenceValue) as IParametersEditor;
                    components[index].componentParametersEditor = componentParametersEditor = e;
                }

                if (editor != null)
                {
                    title   = "Parameters";
                    rect.y += height;
                    var _height = height = 16f;
                    rect.height = height - offset;
                    var editorFoldout = item.FindPropertyRelative("editorParametersFoldout");
                    if (draw == true)
                    {
                        ++EditorGUI.indentLevel;
                        var newValue = EditorGUI.Foldout(rect, editorFoldout.boolValue, new GUIContent(title));
                        if (newValue != editorFoldout.boolValue)
                        {
                            editorFoldout.boolValue = newValue;
                            editorFoldout.serializedObject.ApplyModifiedProperties();
                        }
                        --EditorGUI.indentLevel;
                    }

                    if (editorFoldout.boolValue == true)
                    {
                        rect.y += height;
                        height  = 0f;

                        if (draw == true)
                        {
                            ++EditorGUI.indentLevel;
                            editor.OnParametersGUI(rect);
                            --EditorGUI.indentLevel;

                            //parameters.objectReferenceValue = editor.target;
                            //editor.serializedObject.ApplyModifiedPropertiesWithoutUndo();
                        }

                        height      = editor.GetHeight() + offset;
                        rect.y     += height - _height;
                        rect.height = height - offset;
                    }
                }
            }

            elementHeight = (rect.y - startY) + heightOffset;

            return(item);
        }
		public static SerializedProperty OnItemDraw(LayoutWindowType window, List<SerializedProperty> items, List<UnityEngine.UI.Windows.Types.Layout.Component> components, bool draw, bool withParameters, Rect rect, SerializedProperty item, out float elementHeight) {

			if (LayoutSettingsEditor.componentParametersSearched == null ||
				LayoutSettingsEditor.componentParametersSearched.Count != components.Count) {

				LayoutSettingsEditor.componentParametersSearched = new List<bool>();
				for (int i = 0; i < components.Count; ++i) {

					LayoutSettingsEditor.componentParametersSearched.Add(false);

				}

			}

			var startY = rect.y + 2f;
			var offset = 2f;
			var heightOffset = 20f;
			
			elementHeight = 0f;
			rect.y = startY;
			
			var index = items.IndexOf(item);
			if (index < 0 || index >= items.Count) return item;
			if (item == null) return null;

			var descr = item.FindPropertyRelative("description");
			var tag = item.FindPropertyRelative("tag");
			var component = item.FindPropertyRelative("component");
			var sortingOrder = item.FindPropertyRelative("sortingOrder");
			
			if (descr == null ||
			    tag == null ||
			    component == null ||
			    sortingOrder == null) return item;

			var parameters = item.FindPropertyRelative("componentParameters");
			var componentParametersEditor = components[index].componentParametersEditor;
			
			/*if (active == true && focused == true) {
						
				//var window = (property.serializedObject.targetObject as LayoutWindowType);
				WindowLayoutElement.waitForComponentConnectionElementTemp = window.layout.layout.GetRootByTag((LayoutTag)tag.enumValueIndex);
				WindowLayoutElement.waitForComponentConnectionTemp = true;
				
			} else {
				
				if (active == true) {
					
					WindowLayoutElement.waitForComponentConnectionElementTemp = null;
					WindowLayoutElement.waitForComponentConnectionTemp = false;
					
				}
				
			}*/
			
			var title = "Description";
			var height = EditorGUI.GetPropertyHeight(descr, new GUIContent(title)) + offset;
			rect.height = height - offset;
			if (draw == true) {
				
				EditorGUI.LabelField(rect, descr.stringValue, EditorStyles.boldLabel);
				EditorGUI.LabelField(rect, tag.enumNames[tag.enumValueIndex], ME.Utilities.CacheStyle("WindowLayoutProperty.Styles.tag", "tag", (name) => {
					
					var style = new GUIStyle(EditorStyles.boldLabel);
					style.alignment = TextAnchor.MiddleRight;
					return style;
					
				}));
				
			}
			
			title = "Component";
			rect.y += height;
			height = EditorGUI.GetPropertyHeight(component, new GUIContent(title)) + offset;
			rect.height = height - offset;
			
			{
				
				var oldComponent = component.objectReferenceValue;
				
				var nRect = rect;
				var buttonWidth = 30f;
				nRect.width -= buttonWidth;
				if (draw == true) EditorGUI.PropertyField(nRect, component, new GUIContent(title), true);
				
				var newComponent = component.objectReferenceValue;
				if (oldComponent != newComponent) {
					
					parameters.objectReferenceValue = components[index].OnComponentChanged(window, newComponent as WindowComponent);
					components[index].componentParametersEditor = null;
					
					UnityEditor.EditorUtility.SetDirty(window);

				}
				
				nRect.x += nRect.width;
				nRect.width = buttonWidth;
				if (draw == true) {

					var i = index;
					GUILayoutExt.DrawComponentChooser(nRect, window.gameObject, components[i].component, (elem) => {
						
						if (component.objectReferenceValue != elem) {
							
							component.objectReferenceValue = elem;
							var c = component.objectReferenceValue;
							parameters.objectReferenceValue = components[i].OnComponentChanged(window, c as WindowComponent);
							components[i].componentParametersEditor = null;
							item.serializedObject.ApplyModifiedPropertiesWithoutUndo();
							
							UnityEditor.EditorUtility.SetDirty(window);

						}
						
					});

				}
				
			}
			
			title = "Sorting Order";
			rect.y += height;
			height = EditorGUI.GetPropertyHeight(sortingOrder, new GUIContent(title)) + offset;
			rect.height = height - offset;
			if (draw == true) EditorGUI.PropertyField(rect, sortingOrder, new GUIContent(title), true);
			if (sortingOrder.intValue < 0) sortingOrder.intValue = 0;
			
			if (parameters.objectReferenceValue == null && LayoutSettingsEditor.componentParametersSearched[index] == false) {
				
				components[index].OnComponentChanged(window, components[index].component);
				LayoutSettingsEditor.componentParametersSearched[index] = true;
				
				UnityEditor.EditorUtility.SetDirty(window);

			}

			if (withParameters == true) {

				var editor = componentParametersEditor;
				if (editor == null && parameters.objectReferenceValue != null) {
					
					var e = Editor.CreateEditor(parameters.objectReferenceValue) as IParametersEditor;
					components[index].componentParametersEditor = componentParametersEditor = e;
					
				}
				
				if (editor != null) {
					
					title = "Parameters";
					rect.y += height;
					var _height = height = 16f;
					rect.height = height - offset;
					var foldout = false;
					var editorFoldout = item.FindPropertyRelative("editorParametersFoldout");
					foldout = editorFoldout.boolValue;
					if (draw == true) {
						
						++EditorGUI.indentLevel;
						editorFoldout.boolValue = foldout = EditorGUI.Foldout(rect, editorFoldout.boolValue, new GUIContent(title));
						--EditorGUI.indentLevel;
						
					}
					
					if (foldout == true) {
						
						rect.y += height;
						height = 0f;
						
						if (draw == true) {
							
							++EditorGUI.indentLevel;
							editor.OnParametersGUI(rect);
							--EditorGUI.indentLevel;
							
							//parameters.objectReferenceValue = editor.target;
							//editor.serializedObject.ApplyModifiedPropertiesWithoutUndo();
							
						}
						
						height = editor.GetHeight() + offset;
						rect.y += height - _height;
						rect.height = height - offset;
						
					}
					
				}

			}

			elementHeight = (rect.y - startY) + heightOffset;
			
			return item;
			
		}
Exemplo n.º 9
0
		public static WindowLayout GetLayout(int windowId, out LayoutWindowType screen) {
			
			var window = FlowSystem.GetWindow(windowId);
			
			screen = window.GetScreen() as LayoutWindowType;
			if (screen == null || screen.layout.layout == null) return null;
			
			return screen.layout.layout;
			
		}
			private Vector3 GetScreenPoint(LayoutWindowType screen, WindowComponentBase component, Vector3 worldPoint) {
				
				return screen.workCamera.WorldToScreenPoint(worldPoint);
				
			}
		public override void OnFlowWindowScreenMenuGUI(FD.FlowWindow windowSource, GenericMenu menu) {

			menu.AddItem(new GUIContent("Components Editor..."), on: false, func: (object win) => {

				var window = win as FD.FlowWindow;
				var screen = window.GetScreen() as LayoutWindowType;
				if (screen != null) {

					FlowSystemEditorWindow.GetWindow<FlowSystemEditorWindow>().SetDisabled();
					//this.window = window;
					this.screen = screen;
					this.editor = Editor.CreateEditor(window.GetScreen()) as IPreviewEditor;
					
					this.component = null;
					this.hovered = null;
					this.element = null;
					this.listScrollPosition = Vector2.zero;
					var serializedObject = new SerializedObject(this.screen);
					var layout = serializedObject.FindProperty("layout");
					var components = layout.FindPropertyRelative("components");
					this.props.Clear();
					for (int i = 0; i < components.arraySize; ++i) {
						
						var component = components.GetArrayElementAtIndex(i);
						this.props.Add(component);
						
						this.screen.layout.components[i].OnComponentChanged(this.screen, this.screen.layout.components[i].component);
						
					}
					
					this.settingsScrollPosition = Vector2.zero;
					
					this.opened = true;

				}

			}, userData: windowSource);

		}
        public void DrawVideo(TransitionVideoInputTemplateParameters _target)
        {
            if (_target.transition == null)
            {
                return;
            }

            if (this.hovered == true)
            {
                var lastTime = this.lastTime;
                var curTime  = EditorApplication.timeSinceStartup;
                var delta    = (float)(curTime - lastTime);
                this.lastTime = curTime;

                this.sliderPosition += delta;
                if (this.sliderPosition > 2f)
                {
                    this.sliderPosition = -0.5f;
                }

                this.changed = true;
                this.Repaint();
            }

            if (this.sceneTestContainer == null || this.windowA == null)
            {
                this.sceneTestContainer           = new GameObject("Transition-Temp");
                this.sceneTestContainer.hideFlags = HideFlags.DontSave;                //HideFlags.HideAndDontSave;

                var screenSource = Resources.Load <GameObject>("UI.Windows/Core/Transitions/TransitionScreen");
                var windowSource = screenSource.GetComponent <LayoutWindowType>();

                ImageComponent image = null;

                // Create 2 windows

                this.windowA = WindowSystem.Show(windowSource);
                if (this.windowA != null)
                {
                    this.windowA.transform.SetParent(this.sceneTestContainer.transform);
                    image = this.windowA.GetLayoutComponent <ImageComponent>();
                    image.SetImage(this.styles.transitionA.normal.background);

                    this.windowB = WindowSystem.Show(windowSource);
                    if (this.windowB != null)
                    {
                        this.windowB.transform.SetParent(this.sceneTestContainer.transform);
                        image = this.windowB.GetLayoutComponent <ImageComponent>();
                        image.SetImage(this.styles.transitionB.normal.background);

                        this.changed = true;
                    }
                    else
                    {
                        Object.DestroyImmediate(this.windowA.gameObject);
                    }
                }
            }

            if (this.targetTexture == null)
            {
                this.targetTexture = new RenderTexture(TransitionInputTemplateParametersEditor.WIDTH, TransitionInputTemplateParametersEditor.HEIGHT, 24, RenderTextureFormat.ARGB32);

                this.changed = true;
            }

            if (this.changed == true)
            {
                var videoParameters = _target.GetParameters <TransitionBase.ParametersVideoBase>();
                if (videoParameters != null)
                {
                    this.sceneTestContainer.SetActive(true);

                    this.material = videoParameters.GetMaterialInstance();
                    var lerpA = videoParameters.materialLerpA;
                    var lerpB = videoParameters.materialLerpB;

                    // Take screenshot
                    Graphics.Blit(Texture2D.blackTexture, this.targetTexture);

                    // Rewind to value
                    this.windowA.transition.Setup(this.windowA);
                    _target.transition.SetInState(_target, this.windowA, null);
                    this.windowA.transition.Apply(_target.transition, _target, forward: false, value: this.sliderPosition, reset: false);

                    if (this.material == null || lerpA == false)
                    {
                        Graphics.Blit(this.TakeScreenshot(this.windowA.workCamera), this.targetTexture);
                    }
                    else
                    {
                        Graphics.Blit(this.TakeScreenshot(this.windowA.workCamera), this.targetTexture, this.material);
                    }

                    this.windowB.transition.Setup(this.windowB);
                    this.windowB.transition.Apply(_target.transition, _target, forward: true, value: this.sliderPosition, reset: true);

                    if (this.material == null || lerpB == false)
                    {
                        Graphics.Blit(this.TakeScreenshot(this.windowB.workCamera), this.targetTexture);
                    }
                    else
                    {
                        Graphics.Blit(this.TakeScreenshot(this.windowB.workCamera), this.targetTexture, this.material);
                    }

                    // Deactivate
                    this.sceneTestContainer.SetActive(false);
                }
            }

            if (this.hovered == true)
            {
                this.Repaint();
            }
        }
		public void DrawVideo(TransitionVideoInputTemplateParameters _target) {

			if (_target.transition == null) return;

			if (this.hovered == true) {

				var lastTime = this.lastTime;
				var curTime = EditorApplication.timeSinceStartup;
				var delta = (float)(curTime - lastTime);
				this.lastTime = curTime;

				this.sliderPosition += delta;
				if (this.sliderPosition > 2f) {
					
					this.sliderPosition = -0.5f;
					
				}

				this.changed = true;
				this.Repaint();

			}

			if (this.sceneTestContainer == null) {

				this.sceneTestContainer = new GameObject("Transition-Temp");
				this.sceneTestContainer.hideFlags = HideFlags.DontSave;//HideFlags.HideAndDontSave;
				
				var screenSource = Resources.Load<GameObject>("UI.Windows/Core/Transitions/TransitionScreen");
				var windowSource = screenSource.GetComponent<LayoutWindowType>();
				
				ImageComponent image = null;
				
				// Create 2 windows
				
				this.windowA = WindowSystem.Show(windowSource);
				if (this.windowA != null) {

					this.windowA.transform.SetParent(this.sceneTestContainer.transform);
					image = this.windowA.GetLayoutComponent<ImageComponent>();
					image.SetImage(this.styles.transitionA.normal.background);
					
					this.windowB = WindowSystem.Show(windowSource);
					if (this.windowB != null) {

						this.windowB.transform.SetParent(this.sceneTestContainer.transform);
						image = this.windowB.GetLayoutComponent<ImageComponent>();
						image.SetImage(this.styles.transitionB.normal.background);
						
						this.changed = true;

					} else {

						Object.DestroyImmediate(this.windowA.gameObject);

					}

				}

			}
			
			if (this.targetTexture == null) {
				
				this.targetTexture = new RenderTexture(TransitionInputTemplateParametersEditor.WIDTH, TransitionInputTemplateParametersEditor.HEIGHT, 24, RenderTextureFormat.ARGB32);
				
				this.changed = true;
				
			}
			
			if (this.changed == true) {
				
				var videoParameters = _target.GetParameters<TransitionBase.ParametersVideoBase>();
				if (videoParameters != null) {

					this.sceneTestContainer.SetActive(true);

					this.material = videoParameters.GetMaterialInstance();
					var lerpA = videoParameters.materialLerpA;
					var lerpB = videoParameters.materialLerpB;

					// Take screenshot
					Graphics.Blit(Texture2D.blackTexture, this.targetTexture);

					// Rewind to value
					this.windowA.transition.Setup(this.windowA);
					_target.transition.SetInState(_target, this.windowA, null);
					this.windowA.transition.Apply(_target.transition, _target, forward: false, value: this.sliderPosition, reset: false);

					if (this.material == null || lerpA == false) {
						
						Graphics.Blit(this.TakeScreenshot(this.windowA.workCamera), this.targetTexture);
						
					} else {
						
						Graphics.Blit(this.TakeScreenshot(this.windowA.workCamera), this.targetTexture, this.material);
						
					}

					this.windowB.transition.Setup(this.windowB);
					this.windowB.transition.Apply(_target.transition, _target, forward: true, value: this.sliderPosition, reset: true);

					if (this.material == null || lerpB == false) {
						
						Graphics.Blit(this.TakeScreenshot(this.windowB.workCamera), this.targetTexture);
						
					} else {
						
						Graphics.Blit(this.TakeScreenshot(this.windowB.workCamera), this.targetTexture, this.material);
						
					}

					// Deactivate
					this.sceneTestContainer.SetActive(false);

				}

			}

			if (this.hovered == true) {
				
				this.Repaint();

			}

		}
Exemplo n.º 14
0
        public static void CreateLayout(Object activeObject, GameObject activeGameObject, System.Action callback = null)
        {
            LayoutWindowType layoutScreen = null;

            var name = string.Empty;

            var obj  = activeObject;
            var path = AssetDatabase.GetAssetPath(obj.GetInstanceID());

            if (path.Length > 0 && Directory.Exists(path) == true)
            {
            }
            else if (activeGameObject != null)
            {
                var screen = activeGameObject.GetComponent <WindowBase>();
                if (screen != null)
                {
                    var splitted = path.Split('/');
                    path = string.Join("/", splitted, 0, splitted.Length - 2).Trim('/');

                    path = path + "/Layouts";
                    if (Directory.Exists(path) == true)
                    {
                        layoutScreen = screen as LayoutWindowType;
                        name         = layoutScreen.name.Replace("Screen", "Layout");
                    }
                }
            }

            FlowChooserFilterWindow.Show <FlowWindowLayoutTemplate>(null, (element) => {
                // on select

                if (string.IsNullOrEmpty(name) == true)
                {
                    name = element.name + "Layout";
                }

                // Create an instance
                var layoutPrefab = FlowDatabase.GenerateLayout(path + "/" + name + ".prefab", element);

                if (layoutScreen != null)
                {
                    layoutScreen.GetCurrentLayout().layout = layoutPrefab;
                    layoutScreen.OnValidate();
                    EditorUtility.SetDirty(layoutScreen);
                }

                Selection.activeObject = layoutPrefab;

                if (callback != null)
                {
                    callback();
                }
            }, (element) => {
                // on gui

                var style      = new GUIStyle(GUI.skin.label);
                style.wordWrap = true;

                GUILayout.Label(element.comment, style);
            }, strongType: true);
        }