static void PlaceImageTargetPrefabInScene()
    {
        HelperFunctions.AddTag("ImageTarget");
        if (GameObject.FindWithTag("ImageTarget") != null)
        {
            return;
        }
        GameObject imageTarget      = AssetDatabase.LoadAssetAtPath(pathToUse + "ImageTarget.prefab", typeof(GameObject)) as GameObject;
        GameObject sceneImageTarget = Instantiate(imageTarget, Vector3.zero, Quaternion.identity) as GameObject;

        Selection.activeObject = sceneImageTarget;

        sceneImageTarget.transform.tag = "ImageTarget";
        sceneImageTarget.name          = "ImageTarget";
        sceneImageTarget.AddComponent <ImageTarget>();
    }
    static void PlaceCylinderPrefabInScene()
    {
        GameObject cylinder = AssetDatabase.LoadAssetAtPath(pathToUse + "Cylinder.prefab", typeof(GameObject)) as GameObject;
        GameObject sceneCylinder;

        if (Selection.activeGameObject != null)
        {
            sceneCylinder = Instantiate(cylinder, Vector3.zero, Quaternion.identity, Selection.activeGameObject.transform) as GameObject;
        }
        else
        {
            sceneCylinder = Instantiate(cylinder, Vector3.zero, Quaternion.identity);
        }

        Selection.activeObject = sceneCylinder;
        HelperFunctions.AddTag("Cylinder");
        sceneCylinder.transform.tag = "Cylinder";
        sceneCylinder.name          = "Cylinder";
    }
    static void PlaceSpherePrefabInScene()
    {
        GameObject sphere = AssetDatabase.LoadAssetAtPath(pathToUse + "Sphere.prefab", typeof(GameObject)) as GameObject;
        GameObject sceneSphere;

        if (Selection.activeGameObject != null)
        {
            sceneSphere = Instantiate(sphere, Vector3.zero, Quaternion.identity, Selection.activeGameObject.transform) as GameObject;
        }
        else
        {
            sceneSphere = Instantiate(sphere, Vector3.zero, Quaternion.identity);
        }

        Selection.activeObject = sceneSphere;
        HelperFunctions.AddTag("Sphere");
        sceneSphere.transform.tag = "Sphere";
        sceneSphere.name          = "Sphere";
    }
    static void PlaceVideoPrefabInScene()
    {
        GameObject video = AssetDatabase.LoadAssetAtPath(pathToUse + "Video.prefab", typeof(GameObject)) as GameObject;
        GameObject sceneVideo;

        if (Selection.activeGameObject != null)
        {
            sceneVideo = Instantiate(video, Vector3.zero, Quaternion.identity, Selection.activeGameObject.transform) as GameObject;
        }
        else
        {
            sceneVideo = Instantiate(video, Vector3.zero, Quaternion.identity);
        }

        Selection.activeObject = sceneVideo;
        HelperFunctions.AddTag("Video");
        sceneVideo.transform.tag = "Video";
        sceneVideo.name          = "Video";
        //TODO: Create Dynamic video material and attach it to the video player
        AssetDatabase.Refresh();
    }
Пример #5
0
    void OnWizardCreate()
    {
        GameObject imageTarget = GameObject.FindGameObjectWithTag("ImageTarget");


        if (objFile == null)
        {
            Debug.LogError("You need to at least have an object file to place in scene.");
            return;
        }

        string objName = AssetDatabase.GetAssetPath(objFile).Split('/')[AssetDatabase.GetAssetPath(objFile).Split('/').Length - 1];

        if (!objName.Contains(".obj"))
        {
            Debug.LogError("Only .obj files are supported at this time.");
            return;
        }

        if (!Directory.Exists(GameObject.FindWithTag("ImageTarget").GetComponent <ImageTarget>().destination + "models/"))
        {
            Directory.CreateDirectory(GameObject.FindWithTag("ImageTarget").GetComponent <ImageTarget>().destination + "models/");
        }
        string objDest = GameObject.FindWithTag("ImageTarget").GetComponent <ImageTarget>().destination + "models/" + objName;

        File.Copy(AssetDatabase.GetAssetPath(objFile), objDest, true);

        GameObject model      = objFile as GameObject;
        GameObject sceneModel = Instantiate(model, Vector3.zero, Quaternion.identity, imageTarget.transform) as GameObject;

        sceneModel.AddComponent <CustomModelHelper>();
        Selection.activeObject = sceneModel;
        HelperFunctions.AddTag("Model");
        sceneModel.transform.tag = "Model";
        sceneModel.name          = "Model";

        CustomModelHelper modelHelper = sceneModel.GetComponent <CustomModelHelper>();

        modelHelper.objName = objName;
        if (mtlFile != null)
        {
            string mtlName = AssetDatabase.GetAssetPath(mtlFile).Split('/')[AssetDatabase.GetAssetPath(mtlFile).Split('/').Length - 1];
            string mtlDest = GameObject.FindWithTag("ImageTarget").GetComponent <ImageTarget>().destination + "models/" + mtlName;

            modelHelper.mtlName = mtlName;

            File.Copy(AssetDatabase.GetAssetPath(mtlFile), mtlDest, true);
        }

        if (texture != null)
        {
            string texName = AssetDatabase.GetAssetPath(texture).Split('/')[AssetDatabase.GetAssetPath(texture).Split('/').Length - 1];
            string texDest = GameObject.FindWithTag("ImageTarget").GetComponent <ImageTarget>().destination + "models/" + texName;

            modelHelper.texName = texName;

            File.Copy(AssetDatabase.GetAssetPath(texture), texDest, true);
        }



        AssetDatabase.Refresh();
    }