Beispiel #1
0
    public static void Init(UIMediator mediator)
    {
        LastMessage = new MessageType();

        UIMediator = mediator;
        UIMediator.SetIp(GetLocalIPAddress());

        SetupHardware();

        StartServer();
    }
Beispiel #2
0
 void OnEnable()
 {
     lk = target as UIMediator;
     if (lk.monos == null)
     {
         lk.monos = new Object[0];
     }
     if (lk.names == null)
     {
         lk.names = new List <string>();
     }
 }
Beispiel #3
0
    //Texture tex = null;
    //public Texture GetTextPreview(UIMediator style)
    //{
    //    string id = "" + style.GetInstanceID();
    //    if (tex != null)
    //    {
    //        return tex;
    //    }
    //    GameObject o = AssetDatabase.LoadAssetAtPath<GameObject>(SlothEditorPath.FontStyleRoot + "TextSelector.prefab");
    //    if ((RectTransform)style.transform == null) return null;
    //    o = GameObject.Instantiate(o);
    //    Camera camera = o.GetComponent<Camera>();

    //    string[] ignore = new string[] { "Content/content/btn_shadow" };
    //    GameObject prefab = GameObject.Instantiate(style.gameObject);
    //    for (int i = 0; i < ignore.Length; i++)
    //    {
    //        Transform t = prefab.transform.Find(ignore[i]);
    //        if (t != null)
    //        {
    //            t.gameObject.SetActive(false);
    //        }
    //    }
    //    Canvas canvas = o.transform.Find("Canvas").GetComponent<Canvas>();
    //    prefab.transform.SetParent(canvas.transform, false);
    //    prefab.transform.localPosition = Vector3.zero;
    //    prefab.transform.localScale = Vector3.one;

    //    RectTransform rtt = (RectTransform)prefab.transform;
    //    Bounds bounds = RectTransformUtility.CalculateRelativeRectTransformBounds(canvas.transform, rtt);

    //    Vector3 size = bounds.extents * 2;
    //    float rx = size.x / 160;
    //    float ry = size.y / 90;
    //    Vector3 scale = Vector3.one;
    //    if (rx > 1)
    //        scale.x /= rx;
    //    if (ry > 1)
    //        scale.y /= ry;
    //    scale.x = scale.y = scale.z = Mathf.Min(scale.x, scale.y);
    //    prefab.transform.localScale = scale;
    //    bounds = RectTransformUtility.CalculateRelativeRectTransformBounds(canvas.transform, rtt);
    //    prefab.transform.localPosition -= bounds.center;

    //    RenderTexture rt = new RenderTexture(640, 360, 24, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB);
    //    //RenderTexture rt = new RenderTexture((int)rtt.sizeDelta.x * 4, 360, 24, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB);
    //    camera.targetTexture = rt;

    //    camera.Render();
    //    camera.targetTexture = null;

    //    tex = rt;
    //    GameObject.DestroyImmediate(o);
    //    return rt;
    //}

    public override void OnInteractivePreviewGUI(Rect r, GUIStyle background)
    {
        try
        {
            UIMediator v = (UIMediator)target;
            //if (PrefabUtility.GetPrefabType(target) == PrefabType.Prefab)
            //{
            //    Texture tex = GetTextPreview(v);

            //    float rw = r.width;
            //    float rh = r.height;
            //    float tw = tex.width;
            //    float th = tex.height;


            //    float ws = tw / rw;
            //    float hs = th / rh;
            //    float s = Mathf.Max(ws, hs);

            //    float w = tw / s;
            //    float h = th / s;

            //    float gw = rw - w;
            //    float gh = rh - h;
            //    Rect rect = new Rect();
            //    rect.width = w;
            //    rect.height = h;
            //    rect.x = gw / 2 + r.x;
            //    rect.y = gh / 2 + r.y;

            //    GUI.DrawTexture(rect, tex, ScaleMode.StretchToFill);
            //}
        }
        catch (System.Exception e)
        {
        }
    }