public Point(Vector2 point, LayoutTag tag, WindowComponent component) {
				
				this.x = point.x;
				this.y = point.y;

				this.componentInfo = new ComponentInfo(tag, component);
				
			}
			public Point(Vector2 point, LayoutTag tag, WindowComponent component) {
				
				this.x = point.x;
				this.y = point.y;

				this.tag = tag;
				
			}
				public ComponentInfo(LayoutTag tag, WindowComponent component) {
					
					this.tag = tag;

					this.x = 0f;
					this.y = 0f;
					this.w = 0f;
					this.h = 0f;

					//var rect = (component.transform as RectTransform).rect;

					var corners = new Vector3[4];
					(component.transform as RectTransform).GetWorldCorners(corners);

					var leftBottom = this.GetScreenPoint(component, corners[0]);
					var topRight = this.GetScreenPoint(component, corners[2]);

					this.x = leftBottom.x;
					this.y = leftBottom.y;
					this.w = topRight.x - leftBottom.x;
					this.h = topRight.y - leftBottom.y;

				}
            public Point(Vector2 point, Vector2Int screenSize, int screenId, LayoutTag tag, WindowComponent component)
            {
                this.screenId     = screenId;
                this.screenWidth  = screenSize.x;
                this.screenHeight = screenSize.y;

                this.x = point.x;
                this.y = point.y;

                this.tag = tag;
            }
Esempio n. 5
0
 public virtual void OnComponentAdded(WindowComponent windowComponent)
 {
 }
			public Point(Vector2 point, Vector2Int screenSize, int screenId, LayoutTag tag, WindowComponent component) {

				this.screenId = screenId;
				this.screenWidth = screenSize.x;
				this.screenHeight = screenSize.y;

				this.x = point.x;
				this.y = point.y;

				this.tag = tag;
				
			}
		public static void Send(LayoutTag tag, WindowBase window, WindowComponent component, Vector2 localNormalizedPoint) {

			var flowWindow = Flow.FlowSystem.GetWindow(window);
			if (flowWindow == null) {
				
				Debug.LogWarningFormat("[ Heatmap ] FlowWindow not found. Source {0} used ({1}).", window, tag);
				return;

			}

			// TODO: Send to server
			// Request the new map from server.
			// Use tag, window and component as a keys.

			// Offline
			#if UNITY_EDITOR
			var settings = ME.EditorUtilities.GetAssetsOfType<HeatmapSettings>(useCache: false).FirstOrDefault();
			#else
			HeatmapSettings settings = null;
			#endif
			if (settings == null) return;

			var data = settings.data.Get(flowWindow);

			data.status = HeatmapSettings.WindowsData.Window.Status.Loading;

			data.size = (window as LayoutWindowType).layout.GetLayoutInstance().GetSize();
			data.AddPoint(localNormalizedPoint, tag, component);

			#if UNITY_EDITOR
			UnityEditor.EditorUtility.SetDirty(settings);
			#endif

			data.status = HeatmapSettings.WindowsData.Window.Status.Loaded;

		}
Esempio n. 8
0
        public static void DrawComponentChooser(Rect rect, GameObject gameObject, WindowComponent component, System.Action <WindowComponent> onSelect, GUIStyle style = null)
        {
            if (style == null)
            {
                style             = GUILayoutExt.componentChooserStyle;
                style.fixedWidth  = 0f;
                style.fixedHeight = 0f;
            }

            if (GUI.Button(rect, "+", style) == true)
            {
                var anySpecial = Event.current.shift || Event.current.command || Event.current.control || Event.current.alt;

                GenericMenu.MenuFunction2 onAction = (object comp) => {
                    onSelect(comp as WindowComponent);
                };

                var libraries = ME.EditorUtilities.GetAssetsOfType <WindowComponentLibraryLinker>(null, (p) => {
                    return(!p.child);
                });

                var     screenRect = new Rect(rect.x, rect.y + rect.height, 150f, 250f);
                Vector2 vector     = GUIUtility.GUIToScreenPoint(new Vector2(screenRect.x, screenRect.y));
                screenRect.x = vector.x;
                screenRect.y = vector.y;

                Popup       popup = null;
                GenericMenu menu  = null;

                if (anySpecial == false)
                {
                    popup = new Popup()
                    {
                        screenRect = screenRect
                    };
                }
                else
                {
                    menu = new GenericMenu();
                }

                var package = FlowEditorUtilities.GetPackage(gameObject);
                if (package != null)
                {
                    var components = ME.EditorUtilities.GetPrefabsOfType <WindowComponent>(strongType: false, directory: AssetDatabase.GetAssetPath(package));
                    for (int i = 0; i < components.Length; ++i)
                    {
                        var comp        = components[i];
                        var path        = AssetDatabase.GetAssetPath(comp.gameObject);
                        var packagePath = AssetDatabase.GetAssetPath(package);
                        var _path       = path.Replace(packagePath, string.Empty);
                        _path = _path.Replace("/Components", string.Empty);
                        _path = Path.GetDirectoryName(_path);
                        _path = _path.TrimEnd('/');
                        _path = package.name + " Screen" + _path + "/" + comp.gameObject.name.ToSentenceCase();

                        if (anySpecial == false)
                        {
                            var index = i;
                            popup.ItemByPath(_path, () => {
                                onAction(components[index]);
                            });
                        }
                        else
                        {
                            menu.AddItem(new GUIContent(_path), on: (comp == component), func: onAction, userData: comp);
                        }
                    }

                    if (anySpecial == true)
                    {
                        menu.AddSeparator(string.Empty);
                    }
                }

                var k = 0;
                var z = 0;
                foreach (var library in libraries)
                {
                    foreach (var item in library.items)
                    {
                        var path = library.name + "/" + item.localDirectory + "/" + item.title.ToSentenceCase();

                        if (anySpecial == true)
                        {
                            menu.AddItem(new GUIContent(path), on: (item.mainComponent == component), func: onAction, userData: item.mainComponent);
                        }
                        else
                        {
                            var index1 = z;
                            var index2 = k;
                            popup.ItemByPath(path, () => {
                                onAction(libraries[index1].items[index2].mainComponent);
                            });
                        }

                        ++k;
                    }

                    ++z;
                    k = 0;
                }

                if (anySpecial == false)
                {
                    popup.Show();
                }
                else
                {
                    menu.DropDown(rect);
                }
            }
        }
Esempio n. 9
0
		public static void Send(LayoutTag tag, WindowBase window, WindowComponent component, Vector2 localNormalizedPoint) {

			var flowWindow = Flow.FlowSystem.GetWindow(window);
			if (flowWindow == null) {
				
				Debug.LogWarningFormat("[ Heatmap ] FlowWindow not found. Source {0} used ({1}).", window, tag);
				return;

			}

			// Offline
			#if UNITY_EDITOR
			var modulesPath = FlowSystem.GetData().GetModulesPath();
			var settings = ME.EditorUtilities.GetAssetsOfType<HeatmapSettings>(modulesPath, useCache: false).FirstOrDefault();
			#else
			HeatmapSettings settings = null;
			#endif
			if (settings == null) return;

			var data = settings.data.Get(flowWindow);
			data.AddPoint(localNormalizedPoint, new Vector2Int(Screen.width, Screen.height), flowWindow.id, tag, component);

		}
 public void SetComponent(WindowComponent component)
 {
     this.componentNoResource = component;
 }
Esempio n. 11
0
		public static void Send(LayoutTag tag, WindowBase window, WindowComponent component, Vector2 localNormalizedPoint) {

			var flowWindow = Flow.FlowSystem.GetWindow(window);
			if (flowWindow == null) {
				
				Debug.LogWarningFormat("[ Heatmap ] FlowWindow not found. Source {0} used ({1}).", window, tag);
				return;

			}

			// Offline
			#if UNITY_EDITOR
			var settings = ME.EditorUtilities.GetAssetsOfType<HeatmapSettings>(useCache: false).FirstOrDefault();
			#else
			HeatmapSettings settings = null;
			#endif
			if (settings == null) return;

			var data = settings.data.Get(flowWindow);

			data.status = HeatmapSettings.WindowsData.Window.Status.Loading;

			//data.size = new Vector2(Screen.width, Screen.height);
			data.AddPoint(localNormalizedPoint, tag, component);

			//TODO: change to MathX
			//Rounding coords to 2 digets after point
			//var roundedX = Math.Round((double)localNormalizedPoint.x, 2).ToString();
			//var roundedY = Math.Round((double)localNormalizedPoint.y, 2).ToString();
			/*
			HeatmapSystem.sender.Post("http://localhost:8080/hm_save", new Dictionary<string, string>() {
				{"key", settings.authKey},
				{"uid", SystemInfo.deviceUniqueIdentifier},
				{"windowId", data.id.ToString()},
				{"tag", ((int)tag).ToString()},
				{"x",  roundedX},
				{"y",  roundedY}
			}, null);*/

		}
		private static Vector3 GetScreenPoint(WindowComponent component, Vector3 worldPoint) {

		    var window = component.GetWindow();
			if (window == null) return Vector3.zero;

		    var cam = window.workCamera;
            return cam.WorldToScreenPoint(worldPoint);
			
		}
            public WindowComponentParametersBase OnComponentChanged(WindowBase window, WindowComponent newComponent)
            {
                //var hasChanged = (newComponent != this.component);
                this.component = newComponent;

                WindowComponentParametersBase instance = null;

                //if (hasChanged == true) {

                if (newComponent == null)
                {
                    this.componentResource.ResetToDefault();
                }

                if (this.componentParameters != null)
                {
                    var link = this.componentParameters;
                    //UnityEditor.EditorApplication.delayCall += () => {

                    Object.DestroyImmediate(link, allowDestroyingAssets: true);

                    //};
                }

                instance = Layout.AddParametersFor(window, this.component);
                this.componentParameters = instance;

                this.OnValidate();

                //} else {

                //	instance = this.componentParameters;

                //}

                return(instance);
            }
Esempio n. 14
0
 private Vector3 GetScreenPoint(WindowComponent component, Vector3 worldPoint)
 {
     return(component.GetWindow().workCamera.WorldToScreenPoint(worldPoint));
 }
 public virtual void OnNewItem(WindowComponent instance)
 {
 }
Esempio n. 16
0
 void Reset()
 {
     Window     = GetComponentInParent <WindowComponent>();
     ControlBox = GetComponent <UIWidget>();
     DragObject = GetComponent <UIDragObject>();
 }
Esempio n. 17
0
 public virtual void OnComponentRemoved(WindowComponent windowComponent)
 {
 }
Esempio n. 18
0
 public void RegisterOnView(WindowComponent container)
 {
     container.RegisterSubComponent(this);
 }
 public static void DrawComponent(Rect rect, WindowComponent component, int customKey)
 {
     /*
      * var key = UnityEngine.UI.Windows.Utilities.UIWSMath.GetKey(component.GetHashCode(), customKey);
      *
      * if (Event.current.type == EventType.MouseUp ||
      *  Event.current.type == EventType.MouseDown ||
      *  Event.current.type == EventType.MouseMove) {
      *
      *  if (WindowLayoutUtilities.tempPreviewTimers.ContainsKey(key) == true) {
      *
      *      WindowLayoutUtilities.tempPreviewTimers[key] = 0d;
      *
      *  }
      *
      * }
      *
      * if (Event.current.type == EventType.Repaint) {
      *
      *  if (WindowLayoutUtilities.tempPreviewTimers.TryGetValue(key, out var timer) == true) {
      *
      *      if (EditorApplication.timeSinceStartup - timer > 100d) {
      *
      *          if (WindowLayoutUtilities.tempPreviewRects.TryGetValue(key, out var bufferRect) == true) {
      *
      *              if (Mathf.Abs(rect.width - bufferRect.width) > 1f ||
      *                  Mathf.Abs(rect.height - bufferRect.height) > 1f) {
      *
      *                  WindowLayoutUtilities.tempPreviewRects.Remove(key);
      *                  if (WindowLayoutUtilities.tempPreviewBuffer.TryGetValue(key, out var t) == true) {
      *
      *                      Object.DestroyImmediate(t);
      *
      *                  }
      *
      *                  WindowLayoutUtilities.tempPreviewBuffer.Remove(key);
      *                  WindowLayoutUtilities.tempPreviewTimers.Remove(key);
      *
      *              }
      *
      *          }
      *
      *      }
      *
      *  }
      *
      * }
      *
      * if (WindowLayoutUtilities.tempPreviewBuffer.TryGetValue(key, out var buffer) == true) {
      *
      *  EditorGUI.DrawTextureTransparent(rect, buffer, ScaleMode.ScaleToFit);
      *
      * } else if (Event.current.type == EventType.Repaint) {
      *
      *  if (Application.isPlaying == true) return;
      *
      *  var w = (int)rect.width;
      *  var h = (int)rect.height;
      *  if (w <= 0 || h <= 0) return;
      *
      *  var camera = new GameObject("Camera", typeof(Camera));
      *  camera.hideFlags = HideFlags.HideAndDontSave;
      *
      *  var window = component.GetWindow();
      *  var cameraInstance = camera.GetComponent<Camera>();
      *  if (window != null) {
      *
      *      cameraInstance.CopyFrom(window.workCamera);
      *
      *  } else {
      *
      *      cameraInstance.cullingMask = 1 << component.gameObject.layer;
      *
      *  }
      *  var canvas = new GameObject("Canvas", typeof(Canvas), typeof(UnityEngine.UI.CanvasScaler));
      *  canvas.hideFlags = HideFlags.HideAndDontSave;
      *
      *  var instance = Object.Instantiate(component, canvas.transform);
      *  instance.ValidateEditor();
      *  instance.gameObject.hideFlags = HideFlags.HideAndDontSave;
      *  instance.SetTransformAs(component.transform as RectTransform);
      *
      *  var canvasInstance = canvas.GetComponent<Canvas>();
      *  canvasInstance.renderMode = RenderMode.ScreenSpaceCamera;
      *  canvasInstance.worldCamera = cameraInstance;
      *  cameraInstance.clearFlags = CameraClearFlags.Depth;
      *  var canvases = canvas.GetComponentsInChildren<Canvas>();
      *  foreach (var c in canvases) {
      *
      *      c.enabled = false;
      *
      *  }
      *
      *  var canvasScaler = canvas.GetComponent<UnityEngine.UI.CanvasScaler>();
      *  canvasScaler.uiScaleMode = UnityEngine.UI.CanvasScaler.ScaleMode.ScaleWithScreenSize;
      *  canvasScaler.referenceResolution = new Vector2(rect.width, 0f);
      *  canvasScaler.screenMatchMode = UnityEngine.UI.CanvasScaler.ScreenMatchMode.MatchWidthOrHeight;
      *  canvasScaler.matchWidthOrHeight = 0f;
      *
      *  var type = canvasScaler.GetType();
      *  var binds = System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic;
      *  type.GetField("m_Canvas", binds).SetValue(canvasScaler, canvasInstance);
      *  type.GetMethod("Handle", binds).Invoke(canvasScaler, null);
      *  Canvas.ForceUpdateCanvases();
      *
      *  RenderTexture rt = null;
      *  if (w > 0 && h > 0) {
      *
      *      rt = new RenderTexture(w, h, 32, RenderTextureFormat.ARGB32);
      *      WindowLayoutUtilities.tempPreviewBuffer.Add(key, rt);
      *
      *  }
      *
      *  WindowLayoutUtilities.tempPreviewRects.Remove(key);
      *  WindowLayoutUtilities.tempPreviewRects.Add(key, rect);
      *  WindowLayoutUtilities.tempPreviewTimers.Remove(key);
      *  WindowLayoutUtilities.tempPreviewTimers.Add(key, EditorApplication.timeSinceStartup);
      *
      *  cameraInstance.Render();
      *  EditorApplication.delayCall += () => {
      *
      *      foreach (var c in canvases) {
      *
      *          c.enabled = true;
      *
      *      }
      *
      *      cameraInstance.targetTexture = rt;
      *      cameraInstance.Render();
      *      cameraInstance.targetTexture = null;
      *
      *      foreach (var c in canvases) {
      *
      *          c.enabled = false;
      *
      *      }
      *
      *      //EditorApplication.delayCall += () => {
      *
      *          GameObject.DestroyImmediate(camera);
      *          GameObject.DestroyImmediate(canvas);
      *
      *      //};
      *
      *  };
      *
      * }
      */
 }
				public void AddPoint(Vector2 point, LayoutTag tag, WindowComponent component) {

					this.points.Add(new Point(point, tag, component));
					this.changed = true;

					this.UpdateMap();

				}
            public void Create(WindowBase window, WindowLayoutElement root, System.Action <WindowComponent> callback = null, bool async = false, System.Action <WindowObjectElement> onItem = null)
            {
                if (this.stopped == true)
                {
                    return;
                }

                this.window = window;
                this.root   = root;

                System.Action <WindowComponent> onLoaded = (component) => {
                    if (this.stopped == true)
                    {
                        return;
                    }

                    if (component == null && this.root == null)
                    {
                        if (callback != null)
                        {
                            callback.Invoke(null);
                        }
                        return;
                    }

                    if (component == null)
                    {
                        this.root.Setup(null, this);
                        if (callback != null)
                        {
                            callback.Invoke(null);
                        }
                        return;
                    }

                    //if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true) UnityEngine.Debug.Log("Unpack component: " + component.name);
                    var instance = component.Spawn(activeByDefault: false);
                    //instance.SetComponentState(WindowObjectState.NotInitialized);
                    instance.SetParent(root, setTransformAsSource: false, worldPositionStays: false);
                    instance.SetTransformAs();

                    if (this.componentParameters != null)
                    {
                        instance.Setup(this.componentParameters);
                    }

                    var rect = instance.transform as RectTransform;
                    if (rect != null)
                    {
                        rect.sizeDelta        = (component.transform as RectTransform).sizeDelta;
                        rect.anchoredPosition = (component.transform as RectTransform).anchoredPosition;
                    }

                    this.root.Setup(instance, this);
                    instance.Setup(window);

                    if (instance.autoRegisterInRoot == true && root.autoRegisterSubComponents == true)
                    {
                        root.RegisterSubComponent(instance);
                    }

                    instance.transform.SetSiblingIndex(this.sortingOrder);

                    this.instance = instance;
                    instance.DoLoad(async, onItem, () => {
                        if (this.stopped == true)
                        {
                            return;
                        }

                        //if (instance != null) instance.gameObject.SetActive(true);
                        if (callback != null)
                        {
                            callback.Invoke(this.instance as WindowComponent);
                        }
                    });
                };

                WindowComponent loadedComponent = null;

                if (this.componentResource.IsLoadable() == true)
                {
                    WindowSystemResources.LoadRefCounter <WindowComponent>(this, (component) => {
                        loadedComponent = component;
                        onLoaded.Invoke(loadedComponent);

                        WindowSystemResources.Unload(this, this.GetResource(), resetController: false);
                    }, () => {
                                                #if UNITY_EDITOR
                        if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true)
                        {
                            UnityEngine.Debug.LogWarningFormat("[ Layout ] Resource request failed {0} [{1}].", UnityEditor.AssetDatabase.GetAssetPath(this.component.GetInstanceID()), window.name);
                        }
                                                #endif
                    }, async);
                    return;
                }
                else
                {
                    loadedComponent = this.componentNoResource;
                                        #if UNITY_EDITOR
                    if (WindowSystemLogger.IsLogEnabled() == true)
                    {
                        if (loadedComponent != null)
                        {
                            if (UnityEngine.UI.Windows.Constants.LOGS_ENABLED == true)
                            {
                                UnityEngine.Debug.LogWarningFormat("[ Layout ] Resource `{0}` [{1}] should be placed in `Resources` folder to be loaded/unloaded automaticaly. Window `{2}` requested this resource. This warning shown in editor only.", loadedComponent.name, UnityEditor.AssetDatabase.GetAssetPath(loadedComponent.GetInstanceID()), window.name);
                            }
                        }
                    }
                                        #endif
                }

                onLoaded.Invoke(loadedComponent);
            }
Esempio n. 22
0
 public void Setup(WindowComponent component)
 {
     // If there was no implementation
 }
		public void Setup(WindowComponent component) {

			// If there was no implementation

		}
Esempio n. 24
0
 protected WindowDecorator(WindowComponent component)
 {
     Component = component;
 }
            public WindowComponentParametersBase OnComponentChanged(WindowBase window, WindowComponent newComponent)
            {
                var hasChanged = (newComponent != this.component);

                this.component = newComponent;

                WindowComponentParametersBase instance = null;

                if (hasChanged == true)
                {
                                        #if UNITY_EDITOR
                    if (this.componentParameters != null)
                    {
                        var link = this.componentParameters;
                        //UnityEditor.EditorApplication.delayCall += () => {

                        Object.DestroyImmediate(link, allowDestroyingAssets: true);

                        //};
                    }
                                        #endif

                    instance = Layout.AddParametersFor(window, this.component);
                    this.componentParameters = instance;
                }
                else
                {
                    instance = this.componentParameters;
                }

                return(instance);
            }
 public static WindowComponentParametersBase AddParametersFor(WindowBase window, WindowComponent component)
 {
     return(Layout.AddParametersFor(window.gameObject, component));
 }
				public void AddPoint(Vector2 point, Vector2Int screenSize, int screenId, LayoutTag tag, WindowComponent component) {

					var newPoint = new Point(point, screenSize, screenId, tag, component);
					this.points.Add(newPoint);
					this.changed = true;

					Analytics.Analytics.SendScreenPoint(screenId, newPoint.screenWidth, newPoint.screenHeight, (byte)newPoint.tag, newPoint.x, newPoint.y);

				}
 public void UnloadSafe()
 {
     this._instance = null;
 }
		public void PrepareFor(WindowComponent component) {

			var canvasScaler = this.canvasScaler;
			if (canvasScaler != null) {

				var sourceWindow = component.GetWindow<LayoutWindowType>();
				if (sourceWindow != null) {

					var depth = this.workCamera.depth;
					var cullingMask = this.workCamera.cullingMask;
					var clearFlags = this.workCamera.clearFlags;
					var farClipPlane = this.workCamera.farClipPlane;
					var nearClipPlane = this.workCamera.nearClipPlane;

					var pos = this.transform.position;
					this.workCamera.CopyFrom(sourceWindow.workCamera);
					this.transform.position = pos;

					this.workCamera.depth = depth;
					this.workCamera.cullingMask = cullingMask;
					this.workCamera.clearFlags = clearFlags;
					this.workCamera.farClipPlane = farClipPlane;
					this.workCamera.nearClipPlane = nearClipPlane;

					//var sourceCanvasScaler = sourceWindow.layout.layout.canvasScaler;
					/*
					canvasScaler.defaultSpriteDPI = sourceCanvasScaler.defaultSpriteDPI;
					canvasScaler.dynamicPixelsPerUnit = sourceCanvasScaler.dynamicPixelsPerUnit;
					canvasScaler.fallbackScreenDPI = sourceCanvasScaler.fallbackScreenDPI;
					canvasScaler.matchWidthOrHeight = sourceCanvasScaler.matchWidthOrHeight;
					canvasScaler.physicalUnit = sourceCanvasScaler.physicalUnit;
					canvasScaler.referencePixelsPerUnit = sourceCanvasScaler.referencePixelsPerUnit;
					canvasScaler.referenceResolution = sourceCanvasScaler.referenceResolution;
					canvasScaler.scaleFactor = sourceCanvasScaler.scaleFactor;
					canvasScaler.screenMatchMode = sourceCanvasScaler.screenMatchMode;
					canvasScaler.uiScaleMode = sourceCanvasScaler.uiScaleMode;*/

					//this.scaleFactor = 1f / this.uiElementCanvas.transform.localScale.x;//1f / (this.canvas.scaleFactor / sourceWindow.layout.layout.canvas.scaleFactor);

				}
				
			}

		}
        public T Get <T>(ref T instance) where T : IComponent
        {
            instance = this.Get <T>();

            return(instance);
        }
		private static Vector3 GetScreenPoint(WindowComponent component, Vector3 worldPoint) {
			
			return component.GetWindow().workCamera.WorldToScreenPoint(worldPoint);
			
		}
                public void AddPoint(Vector2 point, Vector2Int screenSize, int screenId, LayoutTag tag, WindowComponent component)
                {
                    var newPoint = new Point(point, screenSize, screenId, tag, component);

                    this.points.Add(newPoint);
                    this.changed = true;

                    Analytics.Analytics.SendScreenPoint(screenId, newPoint.screenWidth, newPoint.screenHeight, (byte)newPoint.tag, newPoint.x, newPoint.y);
                }