Exemplo n.º 1
0
    static void BuildApplicationJar()
    {
        string pathClasses = string.Format("{0}/Assets/Plugins/Android/Classes", m_pathUnityProject);

        OuyaPanel.RunProcess(m_pathJar, pathClasses, string.Format("cvfM OuyaUnityPlugin.jar tv/"));
        OuyaPanel.RunProcess(m_pathJavaP, pathClasses, "-s tv.ouya.sdk.OuyaUnityPlugin");
        OuyaPanel.RunProcess(m_pathJavaP, pathClasses, "-s tv.ouya.sdk.TestOuyaFacade");
        OuyaPanel.RunProcess(m_pathJavaP, pathClasses, "-s tv.ouya.sdk.IOuyaActivity");

        string pathAppJar = string.Format("{0}/OuyaUnityPlugin.jar", pathClasses);
        string pathDest   = string.Format("{0}/Assets/Plugins/Android/OuyaUnityPlugin.jar", m_pathUnityProject);

        if (File.Exists(pathDest))
        {
            File.Delete(pathDest);
        }
        if (File.Exists(pathAppJar))
        {
            File.Move(pathAppJar, pathDest);
        }
        if (Directory.Exists(pathClasses))
        {
            Directory.Delete(pathClasses, true);
        }
    }
Exemplo n.º 2
0
 private static void UpdatePaths()
 {
     m_pathUnityProject = new DirectoryInfo(Directory.GetCurrentDirectory()).FullName;
     switch (Application.platform)
     {
         case RuntimePlatform.OSXEditor:
             m_pathUnityEditor = EditorApplication.applicationPath;
             OuyaPanel.FindFile(new DirectoryInfo(string.Format("{0}", EditorApplication.applicationPath)), OuyaPanel.FILE_UNITY_JAR, ref m_pathUnityJar);
             m_pathUnityJar = m_pathUnityJar.Replace(@"\", "/");
             break;
         case RuntimePlatform.WindowsEditor:
             m_pathUnityEditor = new FileInfo(EditorApplication.applicationPath).Directory.FullName;
             OuyaPanel.FindFile(new DirectoryInfo(string.Format("{0}/{1}", m_pathUnityEditor, OuyaPanel.PATH_UNITY_JAR_WIN)), OuyaPanel.FILE_UNITY_JAR, ref m_pathUnityJar);
             break;
     }
     m_pathSDK = EditorPrefs.GetString(OuyaPanel.KEY_PATH_ANDROID_SDK);
     m_pathJDK = EditorPrefs.GetString(OuyaPanel.KEY_PATH_JAVA_JDK);
     switch (Application.platform)
     {
         case RuntimePlatform.OSXEditor:
             m_pathToolsJar = string.Format("{0}/Contents/Classes/classes.jar", m_pathJDK);
             m_pathJar = string.Format("{0}/Contents/Commands/{1}", m_pathJDK, OuyaPanel.FILE_JAR_MAC);
             m_pathJavaC = string.Format("{0}/Contents/Commands/{1}", m_pathJDK, OuyaPanel.FILE_JAVAC_MAC);
             m_pathJavaP = string.Format("{0}/Contents/Commands/{1}", m_pathJDK, OuyaPanel.FILE_JAVAP_MAC);
             break;
         case RuntimePlatform.WindowsEditor:
             m_pathToolsJar = string.Format("{0}/lib/tools.jar", m_pathJDK);
             m_pathJar = string.Format("{0}/{1}/{2}", m_pathJDK, OuyaPanel.REL_JAVA_PLATFORM_TOOLS, OuyaPanel.FILE_JAR_WIN);
             m_pathJavaC = string.Format("{0}/{1}/{2}", m_pathJDK, OuyaPanel.REL_JAVA_PLATFORM_TOOLS, OuyaPanel.FILE_JAVAC_WIN);
             m_pathJavaP = string.Format("{0}/{1}/{2}", m_pathJDK, OuyaPanel.REL_JAVA_PLATFORM_TOOLS, OuyaPanel.FILE_JAVAP_WIN);
             break;
     }
     m_pathOuyaSDKJar = string.Format("{0}/Assets/Plugins/Android/libs/ouya-sdk.jar", m_pathUnityProject);
 }
Exemplo n.º 3
0
    static void BuildApplicationJar()
    {
        string pathClasses = string.Format("{0}/Assets/Plugins/Android/Classes", m_pathUnityProject);
        OuyaPanel.RunProcess(m_pathJar, pathClasses, string.Format("cvfM OuyaUnityPlugin.jar tv/ {0}", OuyaPanel.GetBundlePrefix()));
        OuyaPanel.RunProcess(m_pathJavaP, pathClasses, "-s tv.ouya.sdk.OuyaUnityPlugin", "OuyaUnityPlugin");
        OuyaPanel.RunProcess(m_pathJavaP, pathClasses, "-s tv.ouya.sdk.UnityOuyaFacade", "UnityOuyaFacade");
        OuyaPanel.RunProcess(m_pathJavaP, pathClasses, "-s tv.ouya.sdk.IOuyaActivity", "IOuyaActivity");
        OuyaPanel.RunProcess(m_pathJavaP, pathClasses, "-s tv.ouya.sdk.OuyaUnityActivity", "OuyaUnityActivity");
        OuyaPanel.RunProcess(m_pathJavaP, pathClasses, string.Format("-s {0}/{1}", OuyaPanel.GetBundleId().Replace(".", "/"), OuyaPanel.GetMainActivity()), OuyaPanel.GetMainActivity());

        string pathAppJar = string.Format("{0}/OuyaUnityPlugin.jar", pathClasses);
        string pathDest = string.Format("{0}/Assets/Plugins/Android/OuyaUnityPlugin.jar", m_pathUnityProject);
        if (File.Exists(pathDest))
        {
            File.Delete(pathDest);
        }
        if (File.Exists(pathAppJar))
        {
            File.Move(pathAppJar, pathDest);
        }
        if (Directory.Exists(pathClasses))
        {
            Directory.Delete(pathClasses, true);
        }
    }
Exemplo n.º 4
0
    // post processor event
    private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets,
                                               string[] movedFromPath)
    {
        if (!OuyaPanel.UsePostProcessor)
        {
            return;
        }

        if (EditorApplication.isCompiling)
        {
            return;
        }

        bool detectedCPlusPlus = false;
        bool detectedJava      = false;

        foreach (string path in importedAssets)
        {
            if (Path.GetExtension(path).ToUpper().Equals(".CPP"))
            {
                if (!m_detectedFiles.ContainsKey(path) ||
                    (m_detectedFiles[path] + TimeSpan.FromSeconds(5)) < File.GetLastWriteTime(path))
                {
                    m_detectedFiles[path] = File.GetLastWriteTime(path);
                    Debug.Log(string.Format("{0} C++ change: {1}", File.GetLastWriteTime(path), path));
                    detectedCPlusPlus = true;
                }
            }
            else if (Path.GetExtension(path).ToUpper().Equals(".JAVA") &&
                     !Path.GetFileName(path).ToUpper().Equals("R.JAVA"))
            {
                if (!m_detectedFiles.ContainsKey(path) ||
                    (m_detectedFiles[path] + TimeSpan.FromSeconds(5)) < File.GetLastWriteTime(path))
                {
                    m_detectedFiles[path] = File.GetLastWriteTime(path);
                    Debug.Log(string.Format("{0} Java change: {1}", File.GetLastWriteTime(path), path));
                    detectedJava = true;
                }
            }
        }

        if (detectedCPlusPlus)
        {
            //compile NDK
            OuyaPanel.CompileNDK();
        }

        if (detectedJava)
        {
            //compile Plugin
            OuyaMenuAdmin.MenuGeneratePluginJar();

            //compile Application Java
            OuyaPanel.CompileApplicationJava();
        }
    }
Exemplo n.º 5
0
    static bool CompileApplicationClasses()
    {
        string pathClasses = string.Format("{0}/Assets/Plugins/Android/Classes", m_pathUnityProject);

        if (!Directory.Exists(pathClasses))
        {
            Directory.CreateDirectory(pathClasses);
        }

        string includeFiles = string.Format("\"{0}/OuyaUnityPlugin.java\" \"{0}/IOuyaActivity.java\" \"{0}/TestOuyaFacade.java\"", m_pathSrc);
        string jars         = string.Empty;

        if (File.Exists(m_pathToolsJar))
        {
            Debug.Log(string.Format("Found Java tools jar: {0}", m_pathToolsJar));
        }
        else
        {
            Debug.LogError(string.Format("Failed to find Java tools jar: {0}", m_pathToolsJar));
            return(false);
        }

        if (File.Exists(GetPathAndroidJar()))
        {
            Debug.Log(string.Format("Found Android jar: {0}", GetPathAndroidJar()));
        }
        else
        {
            Debug.LogError(string.Format("Failed to find Android jar: {0}", GetPathAndroidJar()));
            return(false);
        }

        if (File.Exists(m_pathGsonJar))
        {
            Debug.Log(string.Format("Found GJON jar: {0}", m_pathGsonJar));
        }
        else
        {
            Debug.LogError(string.Format("Failed to find GSON jar: {0}", m_pathGsonJar));
            return(false);
        }

        if (File.Exists(m_pathUnityJar))
        {
            Debug.Log(string.Format("Found Unity jar: {0}", m_pathUnityJar));
        }
        else
        {
            Debug.LogError(string.Format("Failed to find Unity jar: {0}", m_pathUnityJar));
            return(false);
        }

        string output = string.Empty;
        string error  = string.Empty;

        switch (Application.platform)
        {
        case RuntimePlatform.OSXEditor:
            jars = string.Format("\"{0}:{1}:{2}:{3}:{4}\"", m_pathToolsJar, GetPathAndroidJar(), m_pathGsonJar, m_pathUnityJar, m_pathOuyaSDKJar);

            OuyaPanel.RunProcess(m_pathJavaC, string.Empty, string.Format("-g -source 1.6 -target 1.6 {0} -classpath {1} -bootclasspath {1} -d \"{2}\"",
                                                                          includeFiles,
                                                                          jars,
                                                                          pathClasses),
                                 ref output,
                                 ref error);
            break;

        case RuntimePlatform.WindowsEditor:
            jars = string.Format("\"{0}\";\"{1}\";\"{2}\";\"{3}\";\"{4}\"", m_pathToolsJar, GetPathAndroidJar(), m_pathGsonJar, m_pathUnityJar, m_pathOuyaSDKJar);

            OuyaPanel.RunProcess(m_pathJavaC, string.Empty, string.Format("-Xlint:deprecation -g -source 1.6 -target 1.6 {0} -classpath {1} -bootclasspath {1} -d \"{2}\"",
                                                                          includeFiles,
                                                                          jars,
                                                                          pathClasses),
                                 ref output,
                                 ref error);
            break;

        default:
            return(false);
        }

        if (!string.IsNullOrEmpty(error))
        {
            Debug.LogError(error);
            return(false);
        }

        return(true);
    }
Exemplo n.º 6
0
    static bool CompileApplicationClasses()
    {
        string pathClasses = string.Format("{0}/Assets/Plugins/Android/Classes", m_pathUnityProject);

        if (!Directory.Exists(pathClasses))
        {
            Directory.CreateDirectory(pathClasses);
        }

        Dictionary <string, string> javaFiles = new Dictionary <string, string>();

        GetAssets("*.java", javaFiles, new DirectoryInfo("Assets/Plugins/Android/src"));

        string includeFiles = string.Empty;
        int    index        = 0;

        foreach (KeyValuePair <string, string> kvp in javaFiles)
        {
            //Debug.Log(string.Format("Found: {0}", kvp.Value));

            if (index == 0)
            {
                includeFiles = string.Format("\"{0}\"", kvp.Value);
            }
            else
            {
                includeFiles += string.Format(" \"{0}\"", kvp.Value);
            }

            ++index;
        }

        Debug.Log(string.Format("includeFiles: {0}", includeFiles));


        string jars = string.Empty;

        if (File.Exists(m_pathToolsJar))
        {
            Debug.Log(string.Format("Found Java tools jar: {0}", m_pathToolsJar));
        }
        else
        {
            Debug.LogError(string.Format("Failed to find Java tools jar: {0}", m_pathToolsJar));
            return(false);
        }

        if (File.Exists(GetPathAndroidJar()))
        {
            Debug.Log(string.Format("Found Android jar: {0}", GetPathAndroidJar()));
        }
        else
        {
            Debug.LogError(string.Format("Failed to find Android jar: {0}", GetPathAndroidJar()));
            return(false);
        }

        if (File.Exists(m_pathUnityJar))
        {
            Debug.Log(string.Format("Found Unity jar: {0}", m_pathUnityJar));
        }
        else
        {
            Debug.LogError(string.Format("Failed to find Unity jar: {0}", m_pathUnityJar));
            return(false);
        }

        string output = string.Empty;
        string error  = string.Empty;

        switch (Application.platform)
        {
        case RuntimePlatform.OSXEditor:
            jars = string.Format("\"{0}:{1}:{2}:{3}\"", m_pathToolsJar, GetPathAndroidJar(), m_pathUnityJar, m_pathOuyaSDKJar);

            OuyaPanel.RunProcess(m_pathJavaC, string.Empty, string.Format("-g -source 1.6 -target 1.6 {0} -classpath {1} -bootclasspath {1} -d \"{2}\"",
                                                                          includeFiles,
                                                                          jars,
                                                                          pathClasses),
                                 ref output,
                                 ref error);
            break;

        case RuntimePlatform.WindowsEditor:
            jars = string.Format("\"{0}\";\"{1}\";\"{2}\";\"{3}\"", m_pathToolsJar, GetPathAndroidJar(), m_pathUnityJar, m_pathOuyaSDKJar);

            OuyaPanel.RunProcess(m_pathJavaC, string.Empty, string.Format("-Xlint:deprecation -g -source 1.6 -target 1.6 {0} -classpath {1} -bootclasspath {1} -d \"{2}\"",
                                                                          includeFiles,
                                                                          jars,
                                                                          pathClasses),
                                 ref output,
                                 ref error);
            break;

        default:
            return(false);
        }

        if (!string.IsNullOrEmpty(error))
        {
            Debug.LogError(error);
            if (OuyaPanel.StopOnErrors)
            {
                return(false);
            }
        }

        return(true);
    }