private Texture2D LoadPrefabPreview(string prefabName)
    {
        string prefabPath = string.Format("{0}/{1}.prefab", BlockPath.Prefab(category, PolygonType.LOW), prefabName);

        if (!File.Exists(prefabPath))
        {
            PEPrefabGeneratorUtil.CreateSinglePrefab(prefabName, this, category, PolygonType.LOW);
            UnityEditor.AssetDatabase.Refresh();
        }
        var texture2D = GetPreviewTex(prefabPath);

        return(texture2D);
    }
Esempio n. 2
0
    public static GameObject CreateTexture(string prefabName)
    {
        string texPath = Path.Combine(BlockPath.Texture_Prefab_Dir, prefabName + ".prefab");

        if (!File.Exists(texPath))
        {
            PEPrefabGeneratorUtil.CreateTexturePrefab(prefabName);
        }

        GameObject texPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(texPath);

        if (texPrefab == null)
        {
            Debug.LogError(">>>>找不到texture prefab:" + texPath);
        }
        GameObject texObj = GameObject.Instantiate(texPrefab);

        texObj.AddComponent <PEBlockAlign>().SetRefPointTypes();
        texObj.AddComponent <BoxCollider>();

        return(texObj);
    }
Esempio n. 3
0
    public static GameObject CreateBlock(string prefabName, PolygonType polygonType)
    {
        Category category   = PBDataBaseManager.Instance.GetCategoryWithPrefabName(prefabName);
        string   dirPath    = BlockPath.Prefab(category, polygonType);
        string   prefabPath = dirPath + "/" + prefabName + ".prefab";

        if (!File.Exists(prefabPath))
        {
            if (prefabName.StartsWith("sticker_"))
            {
                PEPrefabGeneratorUtil.CreateStickerPrefab(prefabName);
            }
            else
            {
                BlockData blockData = PBDataBaseManager.Instance.GetBlockWithPrefabName(prefabName);
                PEPrefabGeneratorUtil.CreateSinglePrefab(prefabName, blockData.model, blockData.material, blockData.material_high, category, polygonType);
            }
        }

        GameObject tobj = AssetDatabase.LoadAssetAtPath <GameObject>(prefabPath);

        if (tobj == null)
        {
            Debug.LogError(">>>>找不到prefab:" + prefabPath);
        }
        GameObject gameObj = GameObject.Instantiate(tobj);

        gameObj.AddComponent <PEBlockAlign>().SetRefPointTypes();
        var boxCollider = gameObj.AddComponent <BoxCollider>();

        if (prefabName.StartsWith("sticker"))
        {
            boxCollider.size = boxCollider.size + Vector3.up * 0.3f;
        }

        return(gameObj);
    }