示例#1
0
        public static Vector2 ConvertPointWindowToGLScreen(Vector2 point, WindowObject handler)
        {
            var size       = (handler.GetWindow <UnityEngine.UI.Windows.Types.LayoutWindowType>().layout.GetLayoutInstance().transform as RectTransform).sizeDelta;
            var screenSize = new Vector2(Screen.width, Screen.height);

            var result = new Vector2(screenSize.x / size.x, screenSize.y / size.y);

            result.Scale(new Vector2(size.x * 0.5f + point.x, size.y * 0.5f - point.y));

            return(result);
        }
示例#2
0
        public static void RegisterObject(WindowObject obj)
        {
            if (WindowSystem.IsDebugWeakReferences() == false)
            {
                return;
            }
            if (Application.isPlaying == false)
            {
                return;
            }

            //if ((obj.GetWindow() is MW2.UI.EditorTools.Console.ConsoleScreen) == false/*obj.GetComponentsInParent<MW2.UI.EditorTools.Console.ConsoleScreen>(true).Length == 0*/) {

            //Debug.Log("ADD: " + obj.name + " :: " + obj.GetInstanceID());

            var item = WindowSystemResources.instance.registered.FirstOrDefault(x => x.instanceId == obj.GetInstanceID());

            if (item != null)
            {
                Debug.LogError("Object is already in list: " + item.name + " :: " + item.instanceId);
            }
            WindowSystemResources.instance.registered.Add(new ObjectEntity()
            {
                name = string.Format("{0} ({1})", obj.name, obj.GetInstanceID()), instanceId = obj.GetInstanceID(), reference = obj, window = obj.GetWindow()
            });
            WeakReferenceInfo.Register(obj);

            //}
        }
示例#3
0
        public static Vector2 ConvertPointScreenToWindow(Vector2 screenPoint, WindowObject handler)
        {
            var k = (handler.GetWindow().GetLayoutRoot() as RectTransform).sizeDelta.x / Screen.width;

            return(screenPoint * k);
        }
示例#4
0
        public static Vector2 ConvertPointWindowToUnityScreen(Vector2 point, WindowObject handler)
        {
            var size = (handler.GetWindow <UnityEngine.UI.Windows.Types.LayoutWindowType>().layout.GetLayoutInstance().transform as RectTransform).sizeDelta;

            return(new Vector2(size.x * 0.5f + point.x, size.y * 0.5f + point.y));
        }