コード例 #1
0
    public override void OnPreviewGUI(Rect r, GUIStyle background)
    {
        Rect outRect = r;

        float len = Mathf.Min(r.height, r.width);

        outRect.width = outRect.height = len;

        outRect.x = r.width / 2f - len / 2f;

        outRect.y = r.y + r.height / 2f - len / 2f;

        Rect bkgRect = outRect;

        outRect.x      += 3;
        outRect.y      += 3;
        outRect.width  -= 6;
        outRect.height -= 6;

        EditorGUI.DrawPreviewTexture(bkgRect, BkgIcon);

        string prefabPath = "none";
        string imgPath    = XEditorTool.GetEditorAssetPath() + "/no_preview.png";

        if (EditorUtility.IsPersistent(target))
        {
            //is prefab
            prefabPath = AssetDatabase.GetAssetPath(target);
            imgPath    = prefabPath.Substring(0, prefabPath.LastIndexOf(".prefab")) + "_preview.png";
        }
        else
        {
            //is scene obj, check if has prefab instance
            Object prefab = PrefabUtility.GetPrefabParent(target);
            if (prefab != null)
            {
                prefabPath = AssetDatabase.GetAssetPath(prefab);
                imgPath    = prefabPath.Substring(0, prefabPath.LastIndexOf(".prefab")) + "_preview.png";
            }
            else
            {
                imgPath = XEditorTool.GetEditorAssetPath() + "/no_prefab.png";
            }
        }


        Texture2D particleImage = AssetDatabase.LoadAssetAtPath(imgPath, typeof(Texture2D)) as Texture2D;

        if (particleImage == null)
        {
            EditorGUI.DrawPreviewTexture(outRect, NoPreviewIcon);
        }
        else
        {
            EditorGUI.DrawPreviewTexture(outRect, particleImage);
        }


        //GUI.Label(r, target.name + " is being previewed");
    }
コード例 #2
0
    public void Init()
    {
        mSearchString      = "";
        mCurSelectCategory = "All";
        RefreshDic();



        mBkgGrey   = Resources.LoadAssetAtPath(XEditorTool.GetEditorAssetPath() + "/grey.png", typeof(Texture2D)) as Texture2D;
        mBkgWhite  = Resources.LoadAssetAtPath(XEditorTool.GetEditorAssetPath() + "/white.png", typeof(Texture2D)) as Texture2D;
        mNoPreview = Resources.LoadAssetAtPath(XEditorTool.GetEditorAssetPath() + "/no_preview.png", typeof(Texture2D)) as Texture2D;

        RefreshShowingPresetItems(mCurSelectCategory, mSearchString);
    }
コード例 #3
0
    void InitCapture()
    {
        mCaptureLen = 256f;

        mHandleRCLen = 32f;

        HandleImgTL = AssetDatabase.LoadAssetAtPath(XEditorTool.GetEditorAssetPath() + "/handle_tl.png", typeof(Texture2D)) as Texture2D;
        HandleImgTR = AssetDatabase.LoadAssetAtPath(XEditorTool.GetEditorAssetPath() + "/handle_tr.png", typeof(Texture2D)) as Texture2D;
        HandleImgBL = AssetDatabase.LoadAssetAtPath(XEditorTool.GetEditorAssetPath() + "/handle_bl.png", typeof(Texture2D)) as Texture2D;
        HandleImgBR = AssetDatabase.LoadAssetAtPath(XEditorTool.GetEditorAssetPath() + "/handle_br.png", typeof(Texture2D)) as Texture2D;

        HandleImgCT = AssetDatabase.LoadAssetAtPath(XEditorTool.GetEditorAssetPath() + "/handle_center.png", typeof(Texture2D)) as Texture2D;

        mCTOft = Vector2.zero;
    }