コード例 #1
0
    public override IEnumerator Execute(UTContext context)
    {
        var theGameObject = gameObject.EvaluateIn(context);

        if (theGameObject == null)
        {
            throw new UTFailBuildException("You need to specify a game object for which the static flags should be changed.", this);
        }

        var theStaticFlags = staticFlags.EvaluateIn(context);

        var theCurrentStaticFlags = GameObjectUtility.GetStaticEditorFlags(theGameObject);

        switch (changeType.EvaluateIn(context))
        {
        case UTSetOperation.Add:
            theStaticFlags = theStaticFlags | theCurrentStaticFlags;
            break;

        case UTSetOperation.Replace:
            break;

        case UTSetOperation.Subtract:
            theStaticFlags = theCurrentStaticFlags & ~theStaticFlags;
            break;

        default:
            throw new UTFailBuildException("Change type is unsupported.", this);              // should never happen(tm)
        }
        GameObjectUtility.SetStaticEditorFlags(theGameObject, theStaticFlags);

        yield return("");
    }
    public override IEnumerator Execute(UTContext context)
    {
        var theGameObject = gameObject.EvaluateIn (context);
        if (theGameObject == null) {
            throw new UTFailBuildException ("You need to specify a game object for which the static flags should be changed.", this);
        }

        var theStaticFlags = staticFlags.EvaluateIn (context);

        var theCurrentStaticFlags = GameObjectUtility.GetStaticEditorFlags (theGameObject);
        switch (changeType.EvaluateIn (context)) {
        case UTSetOperation.Add:
            theStaticFlags = theStaticFlags | theCurrentStaticFlags;
            break;
        case UTSetOperation.Replace:
            break;
        case UTSetOperation.Subtract:
            theStaticFlags = theCurrentStaticFlags & ~theStaticFlags;
            break;
        default:
            throw new UTFailBuildException ("Change type is unsupported.", this); // should never happen(tm)
        }
        GameObjectUtility.SetStaticEditorFlags (theGameObject, theStaticFlags);

        yield return "";
    }
コード例 #3
0
    public override System.Collections.IEnumerator Execute(UTContext context)
    {
        var theBaseDirectory = baseDirectory.EvaluateIn(context);

        if (string.IsNullOrEmpty(theBaseDirectory))
        {
            theBaseDirectory = UTFileUtils.ProjectAssets;
        }

        if (!Directory.Exists(theBaseDirectory))
        {
            throw new UTFailBuildException("The base directory " + theBaseDirectory + " does not exist.", this);
        }

        theBaseDirectory = UTFileUtils.NormalizeSlashes(theBaseDirectory);
        var theIncludes = EvaluateAll(includes, context);
        var theExcludes = EvaluateAll(excludes, context);

        var theFiles = UTFileUtils.CalculateFileset(theBaseDirectory, theIncludes, theExcludes, UTFileUtils.FileSelectionMode.Files);

        var now = DateTime.Now;

        foreach (var file in theFiles)
        {
            FileInfo src = new FileInfo(file);
            src.LastWriteTime = now;
            yield return("");
        }
    }
コード例 #4
0
    public override IEnumerator Execute(UTContext context)
    {
        var thePackageToImport = packageToImport.EvaluateIn(context);

        if (string.IsNullOrEmpty(thePackageToImport))
        {
            throw new UTFailBuildException("Package to import must be set", this);
        }

        FileInfo info = new FileInfo(thePackageToImport);

        if (!info.Exists)
        {
            // try to resolve relative to the project root
            info = new FileInfo(Application.dataPath + "\\" + thePackageToImport);
            if (!info.Exists)
            {
                throw new UTFailBuildException("Unable to locate input package " + thePackageToImport, this);
            }
        }
        var doInteractive = interactive.EvaluateIn(context);

        AssetDatabase.ImportPackage(thePackageToImport, doInteractive);
        Debug.Log("Package imported from " + thePackageToImport, this);
        yield return("");
    }
コード例 #5
0
    public override IEnumerator Execute(UTContext context)
    {
        Debug.Log("Start Copy Asset Bundles.");

        string assetBundlesPath = context["AssetBundlesPath"] as string;
        string targetDirectory  = "Assets/StreamingAssets";

        Debug.Log("My-uTmote: Copy AssetBundles, Path is " + assetBundlesPath);

        if (!Directory.Exists(assetBundlesPath))
        {
            Debug.Log("My-uTmote: AssetBundles Path(" + assetBundlesPath.ToString() + ") is empty!");
            throw new UTFailBuildException("AssetBundles Path " + assetBundlesPath + " does not exist.", this);
        }

        FileUtil.DeleteFileOrDirectory(targetDirectory);
        Debug.Log("My-uTmote: DeleteFile StreamingAssets ==" + targetDirectory);

        if (!Directory.Exists(targetDirectory))
        {
            Debug.Log("My-uTmote: targetDirectory is empty!");
        }

        FileUtil.CopyFileOrDirectory(assetBundlesPath, targetDirectory);

        Debug.Log("Complete Copy Asset Bundles.");
        yield return("");
    }
コード例 #6
0
    public override IEnumerator Execute(UTContext context)
    {
        var theInputFileName = inputFileName.EvaluateIn (context);
        if (!File.Exists (theInputFileName)) {
            throw new UTFailBuildException ("The input file " + theInputFileName + " does not exist.", this);
        }

        var theOutputFolder = outputFolder.EvaluateIn (context);

        if (string.IsNullOrEmpty (theOutputFolder)) {
            throw new UTFailBuildException ("You need to specify an output folder.", this);
        }

        if (File.Exists (theOutputFolder)) {
            throw new UTFailBuildException ("The output folder " + theOutputFolder + " is a file.", this);
        }

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

        var doOverwrite = overwriteExistingFiles.EvaluateIn (context);
        using (ZipFile zip = ZipFile.Read(theInputFileName)) {
            foreach (ZipEntry e in zip) {
                if (UTPreferences.DebugMode) {
                    Debug.Log ("Extracting " + e.FileName, this);
                }
                e.Extract( theOutputFolder, doOverwrite ? ExtractExistingFileAction.OverwriteSilently : ExtractExistingFileAction.DoNotOverwrite);
                yield return "";
            }
        }

        Debug.Log ("ZIP at " + theInputFileName + " extracted to " + theOutputFolder, this);
        yield return "";
    }
コード例 #7
0
    /// <summary>
    /// Applies the editor properties to the given context.
    /// </summary>
    public static void ApplyTo(UTContext context)
    {
        if (isDirty) {
            RebuildCaches ();
        }

        foreach (var prop in properties) {
            bool propIsExpression = prop.UseExpression;
            bool propIsPrivate = prop.IsPrivate;

            object theRealValue = null;
            if (propIsExpression) {
                theRealValue = context.Evaluate (prop.Expression);
            } else {
                theRealValue = prop.Value;
            }

            if (UTPreferences.DebugMode) {
                var valueOutput = theRealValue;
                if (propIsPrivate && !propIsExpression && valueOutput != null) {
                    valueOutput = new string ('*', valueOutput.ToString ().Length);
                }

                Type valueType = theRealValue != null ? theRealValue.GetType () : null;
                Debug.Log ("Setting property '" + prop.Name + "' to " +
                (valueType != null ? "[" + valueType.Name + "] " : "") + valueOutput);
            }

            context [prop.Name] = theRealValue;
        }
    }
    public override IEnumerator Execute(UTContext context)
    {
        var theOutputFileName = outputFileName.EvaluateIn (context);

        if (string.IsNullOrEmpty (theOutputFileName)) {
            throw new UTFailBuildException ("Output file name must be set",this);
        }

        if (!theOutputFileName.EndsWith (".unitypackage")) {
            Debug.LogWarning ("Output filename should end with .unitypackage.", this);
        }

        var theIncludes = EvaluateAll (includes, context);
        var theExcludes = EvaluateAll (excludes, context);

        var fileList = UTFileUtils.CalculateFileset (theIncludes, theExcludes);
        UTFileUtils.FullPathToProjectPath(fileList);

        var theFinalList = new List<string>();
        theFinalList.AddRange(fileList);

        var doIncludeProjectSettings = includeProjectSettings.EvaluateIn(context);

        if (doIncludeProjectSettings == IncludeProjectSettingsMode.Some) {
            var theSettingsIncludes = EvaluateAll(settingsIncludes, context);
            var theSettingsExcludes = EvaluateAll(settingsExcludes, context);

            var settingsFileList = UTFileUtils.CalculateFileset(UTFileUtils.ProjectSettings, theSettingsIncludes, theSettingsExcludes, UTFileUtils.FileSelectionMode.Files);
            UTFileUtils.FullPathToProjectPath(settingsFileList);
            theFinalList.AddRange(settingsFileList);
        }

        if (theFinalList.Count == 0 && doIncludeProjectSettings != IncludeProjectSettingsMode.All) {
            throw new UTFailBuildException ("There is nothing to export.", this);
        }

        if (UTPreferences.DebugMode) {
            foreach (var entry in theFinalList) {
                Debug.Log ("Exporting: " + entry, this);
            }
        }

        Debug.Log ("Exporting " + theFinalList.Count + " files.", this);

        ExportPackageOptions flags = ExportPackageOptions.Default;

        var doIncludeDependencies = includeDependencies.EvaluateIn (context);
        if (doIncludeDependencies) {
            flags = flags | ExportPackageOptions.IncludeDependencies;
        }

        if (doIncludeProjectSettings == IncludeProjectSettingsMode.All) {
            flags = flags | ExportPackageOptions.IncludeLibraryAssets;
        }

        UTFileUtils.EnsureParentFolderExists(theOutputFileName);
        AssetDatabase.ExportPackage (theFinalList.ToArray(), theOutputFileName, flags);
        Debug.Log ("Package exported to " + theOutputFileName, this);
        yield return "";
    }
コード例 #9
0
    public override IEnumerator Execute(UTContext context)
    {
        Debug.Log("Start Export AssetBundles");
        BundleEditor.ExportBundleData(true, BuildTarget.Android);
        Debug.Log("End Export AssetBundles");

        // string targetDirectory = context["AssetBundlesPath"] as string;
        // CopyAssetBundle(targetDirectory);
        string resourceVersion = context["resourceVersion"] as string;
        string targetPath      = BundleManager.UpdateOutputPath + "/../" + UpdateHelper.VersionFileName;

        Utils.WriteStringToFile(targetPath, resourceVersion);
        Debug.Log("Write resourceVersion[" + resourceVersion + "] to file[" + targetPath + "]");

        string MONTH  = System.DateTime.Now.Month > 9 ? "" + System.DateTime.Now.Month : "0" + System.DateTime.Now.Month;
        string DAY    = System.DateTime.Now.Day > 9 ? "" + System.DateTime.Now.Day : "0" + System.DateTime.Now.Day;
        string CurDay = System.DateTime.Now.Year + "_" + MONTH + "_" + DAY;
//        string productName = PlayerSettings.productName;
        string hour    = System.DateTime.Now.Hour > 9 ? "" + System.DateTime.Now.Hour : "0" + System.DateTime.Now.Hour;
        string minute  = System.DateTime.Now.Minute > 9 ? "" + System.DateTime.Now.Minute : "0" + System.DateTime.Now.Minute;
        string version = string.Format("{0}_{1}_{2}_{3}", PlatformHelper.GetGameVersion(), PlatformHelper.GetProgramVersion(), GCGame.Table.TableManager.GetPublicConfigByID(GameDefines.PublicResVersionKey, 0).IntValue, UserConfigData.ClientResVersion);

        string zipFileName = "Android_" + version + "_" + CurDay + "_" + hour + "" + minute + ".zip";

        // release文件夹
        string zipFolder = BundleManager.UpdateOutputPath + "/../../";

        CreateFolder(zipFolder);
        zipFolder += CurDay;
        CreateFolder(zipFolder);

        CreateSample(zipFolder + "/" + zipFileName, BundleManager.UpdateOutputPath + "/../");
        yield return("");
    }
コード例 #10
0
    public override IEnumerator Execute(UTContext context)
    {
        if (UTPreferences.DebugMode)
        {
            Debug.Log("Modifying Web player settings.", this);
        }

        PlayerSettings.defaultWebScreenWidth = defaultScreenWidth.EvaluateIn(context);
        PlayerSettings.defaultScreenHeight   = defaultScreenHeight.EvaluateIn(context);
        PlayerSettings.runInBackground       = runInBackground.EvaluateIn(context);

#if !UNITY_3_5
        PlayerSettings.renderingPath = renderingPath.EvaluateIn(context);
#endif
        PlayerSettings.colorSpace = colorSpace.EvaluateIn(context);

#if !UNITY_3_5
        PlayerSettings.useDirect3D11 = useDirect3D11.EvaluateIn(context);
#endif
        //PlayerSettings.firstStreamedLevelWithResources = firstStreamedLevel.EvaluateIn(context);

        PlayerSettings.stripUnusedMeshComponents = optimizeMeshData.EvaluateIn(context);
#if UNITY_3_5
        PlayerSettings.debugUnloadMode = debugUnloadMode.EvaluateIn(context);
#endif

        if (UTPreferences.DebugMode)
        {
            Debug.Log("Web player settings modified.", this);
        }

        yield return("");
    }
コード例 #11
0
    /// <summary>
    /// Runs the specified plan.
    /// </summary>
    public static void Run(UTAutomationPlan plan, Dictionary <string, string> additionalProperties)
    {
        if (UTPreferences.ClearConsoleBeforeStart)
        {
            UTils.ClearConsole();
        }
        var context = new UTContext();

        if (additionalProperties != null)
        {
            foreach (var entry in additionalProperties)
            {
                string name = entry.Key;
                string val  = entry.Value;
                if (UTPreferences.DebugMode)
                {
                    Debug.Log("Setting additional property: " + name + " = " + val);
                }
                context[name] = val;
            }
        }

        UTMainWindow.Init();
        var runner = UTomateRunner.Instance;

        runner.RequestRun(plan, context);
    }
    public override IEnumerator Execute(UTContext context)
    {
        var theGameObject = gameObject.EvaluateIn (context);
        if (theGameObject == null) {
            throw new UTFailBuildException ("You need to specify a game object to transform.", this);
        }

        if (positionAbsolute.EvaluateIn (context)) {
            theGameObject.transform.position = position.EvaluateIn (context);
        } else {
            theGameObject.transform.position += position.EvaluateIn (context);
        }

        if (rotationAbsolute.EvaluateIn (context)) {
            theGameObject.transform.localRotation = Quaternion.Euler (rotation.EvaluateIn (context));
        } else {
            theGameObject.transform.localRotation = Quaternion.Euler (theGameObject.transform.localEulerAngles + rotation.EvaluateIn (context));
        }

        if (scaleAbsolute.EvaluateIn (context)) {
            theGameObject.transform.localScale = scale.EvaluateIn (context);
        } else {
            theGameObject.transform.localScale = Vector3.Scale (theGameObject.transform.localScale, scale.EvaluateIn (context));
        }

        yield return "";
    }
コード例 #13
0
    public override IEnumerator Execute(UTContext context)
    {
#if UNITY_3_5
        if (defines.Length == 0)
        {
            DeleteFileWithMeta(UTFileUtils.ProjectAssets + "/smcs.rsp");
            DeleteFileWithMeta(UTFileUtils.ProjectAssets + "/gmcs.rsp");
            DeleteFileWithMeta(UTFileUtils.ProjectAssets + "/us.rsp");
            DeleteFileWithMeta(UTFileUtils.ProjectAssets + "/boo.rsp");
        }
        else
        {
            string contents = "-define:" + string.Join(",", EvaluateAll(defines, context));
            File.WriteAllText(UTFileUtils.ProjectAssets + "/smcs.rsp", contents);
            File.WriteAllText(UTFileUtils.ProjectAssets + "/gmcs.rsp", contents);
            File.WriteAllText(UTFileUtils.ProjectAssets + "/us.rsp", contents);
            File.WriteAllText(UTFileUtils.ProjectAssets + "/boo.rsp", contents);
        }
#endif

#if !UNITY_3_5
        PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup.EvaluateIn(context), string.Join(";", EvaluateAll(defines, context)));
#endif
        yield return("");
    }
コード例 #14
0
    public override IEnumerator Execute(UTContext context)
    {
        if (startOfSubtree == null)
        {
            Debug.LogError("No subtree specified.");
            yield break;
        }

        Dictionary <string, bool> SDK_Channel = context["SDK_Channel"] as Dictionary <string, bool>;

        Debug.Log("For Each: Items == " + SDK_Channel);

        var i = 0;

        if (SDK_Channel is IEnumerable)
        {
            foreach (string channelID in (IEnumerable)SDK_Channel.Keys)
            {
                i++;
                Debug.Log("For Each: i == " + i + "  channelID==" + channelID);
                Debug.Log("For Each: is Build " + channelID + "?? " + SDK_Channel[channelID]);
                if (SDK_Channel[channelID])
                {
                    context["channelID_forBuild"] = channelID;
                    Debug.Log("ExecutePath next step");
                    var enumerator = UTAutomationPlan.ExecutePath(startOfSubtree, context);
                    do
                    {
                        yield return("");
                    }while (enumerator.MoveNext());
                }
            }
        }
    }
コード例 #15
0
    /// <summary>
    /// Applies the project properties to the given context.
    /// </summary>
    public void ApplyTo(UTContext context)
    {
        for (int i = 0; i < propertyNames.Length; i++)
        {
            var    propName      = propertyNames [i];
            var    propValue     = propertyValues [i];
            var    propIsPrivate = isPrivate [i];
            object theRealValue  = null;
            if (propValue.UseExpression)
            {
                theRealValue = context.Evaluate(propValue.Expression);
            }
            else
            {
                theRealValue = propValue.Value;
            }

            if (UTPreferences.DebugMode)
            {
                var valueOutput = theRealValue;
                if (propIsPrivate && !propValue.UseExpression && valueOutput != null)
                {
                    valueOutput = new string ('*', valueOutput.ToString().Length);
                }
                Type valueType = theRealValue != null?theRealValue.GetType() : null;

                Debug.Log("Setting property '" + propName + "' to " +
                          (valueType != null ? "[" + valueType.Name + "] " : "") + valueOutput, this);
            }

            context [propName] = theRealValue;
        }
    }
コード例 #16
0
    public override IEnumerator Execute(UTContext context)
    {
        //get channelID from last step "setProperty"
        string channelID = context["channelID_forBuild"] as string;

        Debug.Log("My-uTmote: channelID0 ==" + channelID);

        string[] buildScenes;
        //get buildscene from PlayerSettings
        var scenesFromEditor = EditorBuildSettings.scenes;

        if (scenesFromEditor.Length == 0)
        {
            throw new UTFailBuildException("There are no scenes set up in the editor build settings.",
                                           this);
        }
        var active = Array.FindAll(scenesFromEditor, scene => scene.enabled);

        buildScenes = Array.ConvertAll(active, scene => scene.path);
        Debug.Log("My-uTmote: buildScenes ==" + buildScenes);

        bulidApkFile(channelID, buildScenes);

        yield return("");
    }
    public override IEnumerator Execute(UTContext context)
    {
        var theGameObject = gameObject.EvaluateIn (context);
        if (theGameObject == null) {
            throw new UTFailBuildException ("You need to specify a game object.", this);
        }

        UTTypeInfo theComponentInfo = component.EvaluateIn (context);
        if (theComponentInfo == null) {
            throw new UTFailBuildException ("You need to specify a component that should be added.", this);
        }

        Type theComponent = theComponentInfo.Type;
        if ( theComponent == null) {
            throw new UTFailBuildException("There is no component of type " + theComponentInfo.TypeName + " in the current project. Did you delete it accidently?", this );
        }

        var doOnlyIfNotExists = onlyIfNotExists.EvaluateIn (context);
        var doAdd = true;
        if (doOnlyIfNotExists) {

            if (theGameObject.GetComponent (theComponent) != null) {
                if (UTPreferences.DebugMode) {
                    Debug.Log ("Component of type " + theComponent.Name + " already exists at game object " + theGameObject);
                }
                doAdd = false;
            }
        }

        if (doAdd) {
            theGameObject.AddComponent (theComponent);
        }

        yield return "";
    }
コード例 #18
0
    public override IEnumerator Execute(UTContext context)
    {
        var thePrefab = prefab.EvaluateIn (context);
        if (thePrefab == null) {
            throw new UTFailBuildException ("You need to specify a prefab to instantiate.", this);
        }

        var theObjectName = objectName.EvaluateIn(context);
        if (UTPreferences.DebugMode) {
            Debug.Log ("Instantiating prefab: " + thePrefab);
        }

        var theObject = (GameObject) PrefabUtility.InstantiatePrefab(thePrefab);

        if (!string.IsNullOrEmpty(theObjectName)) {
            theObject.name = theObjectName;
        }

        var theProperty = outputProperty.EvaluateIn (context);
        if (!string.IsNullOrEmpty (theProperty)) {
            context [theProperty] = theObject;
        }

        yield return "";
    }
コード例 #19
0
    /// <summary>
    /// Executes the given entry and it's followers (hence 'ExecutePath'). Automatically breaks execution if
    /// the context's CancelRequested flag is set. All UTAutomationPlanEntries should use this function if they
    /// have to execute subtrees.
    /// </summary>
    public static IEnumerator ExecutePath(UTAutomationPlanEntry entry, UTContext context)
    {
        while (entry != null)
        {
            if (context.CancelRequested)
            {
                yield break;
            }
            // can be overwritten by the entry or it's substructures.
            context.LocalProgress = -1;
            context.CurrentEntry  = entry;
            context.Me            = entry.Me;
            var enumerator = entry.Execute(context);
            yield return("");

            while (enumerator.MoveNext())
            {
                yield return("");
            }
            if (context.CancelRequested)
            {
                yield break;
            }
            entry = entry.NextEntry;
        }
    }
コード例 #20
0
    public override IEnumerator Execute(UTContext context)
    {
        var theName = propertyName.EvaluateIn (context);
        if (string.IsNullOrEmpty (theName)) {
            throw new UTFailBuildException ("The name of the property must not be empty.",this);
        }

        object theRealValue = propertyValue.Value;
        if (propertyValue.UseExpression) {
            theRealValue = context.Evaluate (propertyValue.Expression);
        }

        var doSetOnlyIfUnset = onlyIfUnset.EvaluateIn(context);

        if (!doSetOnlyIfUnset || !context.ContainsProperty(theName)) {
            if (UTPreferences.DebugMode) {
                Type valueType = theRealValue != null ? theRealValue.GetType() : null;
                Debug.Log ("Setting property '" + theName + "' to " +
                    (valueType != null ? "[" + valueType.Name + "] " : "") + theRealValue, this);
            }
            context [theName] = theRealValue;
        }
        else {
            if (doSetOnlyIfUnset) {
                if (UTPreferences.DebugMode) {
                    Debug.Log("Not setting property '" + theName + "' because it is already set.");
                }
            }
        }
        yield return "";
    }
コード例 #21
0
    private UTFilter GetByPositionFilter(UTContext context)
    {
        var thePosition = position.EvaluateIn(context);
        var theDistance = distance.EvaluateIn(context);

        return(new UTPositionFilter(thePosition, theDistance));
    }
コード例 #22
0
    /// <summary>
    /// Applies the project properties to the given context.
    /// </summary>
    public void ApplyTo(UTContext context)
    {
        for (int i = 0; i < propertyNames.Length; i++) {
            var propName = propertyNames [i];
            var propValue = propertyValues [i];
            var propIsPrivate = isPrivate [i];
            object theRealValue = null;
            if (propValue.UseExpression) {
                theRealValue = context.Evaluate (propValue.Expression);
            } else {
                theRealValue = propValue.Value;
            }

            if (UTPreferences.DebugMode) {
                var valueOutput = theRealValue;
                if (propIsPrivate && !propValue.UseExpression && valueOutput != null) {
                    valueOutput = new string ('*', valueOutput.ToString ().Length);
                }
                Type valueType = theRealValue != null ? theRealValue.GetType () : null;
                Debug.Log ("Setting property '" + propName + "' to " +
                (valueType != null ? "[" + valueType.Name + "] " : "") + valueOutput, this);
            }

            context [propName] = theRealValue;
        }
    }
コード例 #23
0
    public override IEnumerator Execute(UTContext context)
    {
        var theScene = scene.EvaluateIn(context);

        if (theScene.Contains("*"))
        {
            var finalList = UTFileUtils.CalculateFileset(new string[] { theScene }, new string[0]);
            if (finalList.Length != 1)
            {
                throw new UTFailBuildException("Scene wildcard " + theScene + " yielded " +
                                               finalList.Length + " results but should yield exactly one scene.", this);
            }
            UTFileUtils.FullPathToProjectPath(finalList);
            theScene = finalList[0];
        }

        theScene = UTFileUtils.FullPathToProjectPath(theScene);

        if (UTPreferences.DebugMode)
        {
            Debug.Log("Opening scene: " + theScene, this);
        }
        var result = EditorApplication.OpenScene(theScene);

        if (!result)
        {
            throw new UTFailBuildException("Scene " + theScene + " could not be opened.", this);
        }
        yield return("");
    }
コード例 #24
0
    public override IEnumerator Execute(UTContext context)
    {
        var theGameObject = gameObject.EvaluateIn(context);

        if (theGameObject == null)
        {
            throw new UTFailBuildException("You need to specify a game object to tag.", this);
        }

        var theTagName = tagName.EvaluateIn(context);

        if (string.IsNullOrEmpty(theTagName))
        {
            theGameObject.tag = string.Empty;
        }
        else
        {
            if (Array.IndexOf(InternalEditorUtility.tags, theTagName) == -1)
            {
                throw new UTFailBuildException("There is currently no tag '" + theTagName +
                                               "' defined. Please define it in the tag manager and then run this action again.", this);
            }
            theGameObject.tag = theTagName;
        }

        yield return("");
    }
コード例 #25
0
    private UTFilter GetFilterForMode(UTContext context)
    {
        switch (mode)
        {
        case UTFindGameObjectMode.ByTag:
            return(GetByTagFilter(context));

        case UTFindGameObjectMode.ByName:
            return(GetByNameFilter(context));

        case UTFindGameObjectMode.ByLayer:
            return(GetByLayerFilter(context));

        case UTFindGameObjectMode.IsStatic:
            return(GetIsStaticFilter(context));

        case UTFindGameObjectMode.IsActive:
            return(GetIsActiveFilter(context));

        case UTFindGameObjectMode.ByPrefab:
            return(GetByPrefabFilter(context));

        case UTFindGameObjectMode.ByComponent:
            return(GetByComponentFilter(context));

        case UTFindGameObjectMode.ByExpression:
            return(GetByExpressionFilter(context));

        case UTFindGameObjectMode.ByPosition:
            return(GetByPositionFilter(context));
        }
        throw new UTFailBuildException("Unsupported filter type.", this);
    }
コード例 #26
0
    public override IEnumerator Execute(UTContext context)
    {
        var theScene = scene.EvaluateIn(context);

        if (theScene.Contains("*")) {
            var finalList = UTFileUtils.CalculateFileset(new string[]{theScene}, new string[0]);
            if (finalList.Length != 1) {
                throw new UTFailBuildException("Scene wildcard " + theScene + " yielded " +
                    finalList.Length + " results but should yield exactly one scene.", this);
            }
            UTFileUtils.FullPathToProjectPath(finalList);
            theScene = finalList[0];
        }

        theScene = UTFileUtils.FullPathToProjectPath(theScene);

        if (UTPreferences.DebugMode) {
            Debug.Log("Opening scene: " + theScene, this);
        }
        var result = EditorApplication.OpenScene(theScene);
        if (!result) {
            throw new UTFailBuildException("Scene " + theScene + " could not be opened.", this);
        }
        yield return "";
    }
コード例 #27
0
    public override IEnumerator Execute(UTContext context)
    {
        string finalout = context["pngquant"] as string;

        UDebug.Log("finalout = " + finalout);

        string directory = Directory.GetCurrentDirectory();
        //UDebug.Log("directory = "+directory);
        Process process = new Process();

        process.StartInfo.FileName        = directory + "/Assets/BuildTools/Android/pngquant-windows/pngquant.exe";
        process.StartInfo.Arguments       = "256 " + finalout + " --ext .png --force";
        process.StartInfo.UseShellExecute = false;

        process.StartInfo.WorkingDirectory = "";

        process.StartInfo.RedirectStandardOutput = true;
        process.StartInfo.RedirectStandardError  = true;
        process.OutputDataReceived += (sender, argv) => UDebug.Log("[Execute]" + argv.Data);
        process.ErrorDataReceived  += (sender, argv) => UDebug.LogWarning("[Execute]" + argv.Data);

        try {
            process.Start();
            process.BeginOutputReadLine();
        } catch (Win32Exception e) {
            throw new UTFailBuildException("Couldn't start process: " + e.Message, this);
        }
        yield return("");
    }
コード例 #28
0
    public override IEnumerator Execute(UTContext context)
    {
        var theMessage = messageOnFail.EvaluateIn(context);

        foreach (var condition in conditions) {
            if (UTPreferences.DebugMode) {
                if (condition.UseExpression) {
                    Debug.Log ("Evaluating expression " + condition.Expression);
                }
            }

            var result = condition.EvaluateIn (context);
            if (result == false) {
                if (UTPreferences.DebugMode) {
                    Debug.Log ("Condition was not true. Aborting.");
                }
                if (!string.IsNullOrEmpty(theMessage)) {
                    Debug.LogError(theMessage);
                }
                throw new UTFailBuildException ("Assertion failed. Aborting plan execution.", this);
            }
            else {
                if (UTPreferences.DebugMode) {
                    Debug.Log("Condition was true. Continuing.");
                }
            }
        }

        yield return "";
    }
コード例 #29
0
    public override IEnumerator Execute(UTContext context)
    {
        var thePrefab = prefab.EvaluateIn(context);

        if (thePrefab == null)
        {
            throw new UTFailBuildException("You need to specify a prefab to instantiate.", this);
        }

        var theObjectName = objectName.EvaluateIn(context);

        if (UTPreferences.DebugMode)
        {
            Debug.Log("Instantiating prefab: " + thePrefab);
        }

        var theObject = (GameObject)PrefabUtility.InstantiatePrefab(thePrefab);

        if (!string.IsNullOrEmpty(theObjectName))
        {
            theObject.name = theObjectName;
        }


        var theProperty = outputProperty.EvaluateIn(context);

        if (!string.IsNullOrEmpty(theProperty))
        {
            context [theProperty] = theObject;
        }

        yield return("");
    }
コード例 #30
0
 private UTFilter GetByComponentFilter(UTContext context)
 {
     if (components.Length == 0)
     {
         throw new UTFailBuildException("You need to specify at least one component to search for.", this);
     }
     return(new UTComponentFilter(EvaluateAll(components, context)));
 }
コード例 #31
0
 private UTFilter GetByPrefabFilter(UTContext context)
 {
     if (prefabs.Length == 0)
     {
         throw new UTFailBuildException("You need to specify at least one prefab to search for.", this);
     }
     return(new UTPrefabFilter(EvaluateAll(prefabs, context)));
 }
コード例 #32
0
 private UTFilter GetByLayerFilter(UTContext context)
 {
     if (layers.Length == 0)
     {
         throw new UTFailBuildException("You need to specify at least one layer to search for.", this);
     }
     return(new UTLayerFilter(EvaluateAll(layers, context)));
 }
コード例 #33
0
 private UTFilter GetByNameFilter(UTContext context)
 {
     if (names.Length == 0)
     {
         throw new UTFailBuildException("You need to specify at least one name to search for.", this);
     }
     return(new UTNameFilter(EvaluateAll(names, context)));
 }
コード例 #34
0
 private UTFilter GetByTagFilter(UTContext context)
 {
     if (tags.Length == 0)
     {
         throw new UTFailBuildException("You need to specify at least one tag to search for.", this);
     }
     return(new UTTagFilter(EvaluateAll(tags, context)));
 }
コード例 #35
0
 private void SetupVariables(UTContext context)
 {
     // this is intended, so project properties can refer to editor properties
     UTEditorProperties.ApplyTo(context);
     UTomate.ProjectProperties.ApplyTo(context);
     // but editor properties overwrite project properties.
     UTEditorProperties.ApplyTo(context);
 }
コード例 #36
0
	public override IEnumerator Execute (UTContext context)
	{
		string  finalout = context["CurPrefabFile"] as string;
		//HandleMat(context["foreachfile"]);
		//Debug.Log(UTFileUtils.FullPathToProjectPath(finalout), this);
		HandlePrefab(UTFileUtils.FullPathToProjectPath(finalout));
		yield return "";
	}
 private void SetupVariables(UTContext context)
 {
     // this is intended, so project properties can refer to editor properties
     UTEditorProperties.ApplyTo (context);
     UTomate.ProjectProperties.ApplyTo (context);
     // but editor properties overwrite project properties.
     UTEditorProperties.ApplyTo (context);
 }
コード例 #38
0
        public override IEnumerator Execute(UTContext context)
        {
            string _menuItemPath = menuItemPath.EvaluateIn (context);

            EditorApplication.ExecuteMenuItem(_menuItemPath);

            yield return "";
        }
コード例 #39
0
 private UTFilter GetIsStaticFilter(UTContext context)
 {
     if (staticFlags.Length == 0)
     {
         throw new UTFailBuildException("You need to specify at least one static flag combination to search for.", this);
     }
     return(new UTStaticFlagFilter(EvaluateAll(staticFlags, context)));
 }
    public override IEnumerator Execute(UTContext context)
    {
        var theProjectPath = projectPath.EvaluateIn (context);
        if (!Directory.Exists (theProjectPath)) {
            throw new UTFailBuildException ("Project path " + theProjectPath + " does not exist.", this);
        }

        if (UTFileUtils.IsBelow (UTFileUtils.ProjectRoot, theProjectPath)) {
            throw new UTFailBuildException ("You cannot run uTomate externally on the current project. Use the Sub-Plan node if you want to run a plan as part of a plan.", this);
        }

        var thePlanName = planName.EvaluateIn (context);
        var theDebugMode = debugMode.EvaluateIn (context);

        var theProperties = EvaluateAll (properties, context);

        StringBuilder sb = new StringBuilder ();
        foreach (var prop in theProperties) {
            sb.Append (" -prop ").Append (UTExecutableParam.Quote (prop));
        }

        Process process = new Process ();
        process.StartInfo.FileName = UTils.GetEditorExecutable ();
        process.StartInfo.Arguments = "-projectPath " + UTExecutableParam.Quote (theProjectPath) +
            " -executeMethod UTExternalRunner.RunPlan -plan " + UTExecutableParam.Quote (thePlanName) +
                " -debugMode " + theDebugMode + sb.ToString ();
        if (UTPreferences.DebugMode) {
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.UseShellExecute = false;
            process.OutputDataReceived += (sender, args) => UDebug.Log ("[Unity]" + args.Data);
            UDebug.Log ("Executing: " + process.StartInfo.FileName + " with arguments " + process.StartInfo.Arguments);
        }

        try {
            if (!process.Start ()) {
                throw new UTFailBuildException ("Unable to start Unity3D.", this);
            }
            if (UTPreferences.DebugMode) {
                process.BeginOutputReadLine ();
            }
        } catch (Win32Exception e) {
            throw new UTFailBuildException ("Unable to start process " + e.Message, this);
        }
        do {
            yield return "";
            if (context.CancelRequested && !process.HasExited) {
                process.Kill ();
                break;
            }

        } while(!process.HasExited);

        if (!context.CancelRequested && failOnError.EvaluateIn (context)) {
            if (process.ExitCode != 0) {
                throw new UTFailBuildException ("Plan " + thePlanName + " failed or was cancelled.", this);
            }
        }
    }
コード例 #41
0
    public override IEnumerator Execute(UTContext context)
    {
        string finalout = context["MyTextureAction"] as string;

        Debug.Log("finalout = " + finalout);
        LowTexture.doLowTextrue(finalout);
        //BuildAssetProcess.DoAndroidLowTextrue ();
        yield return("");
    }
コード例 #42
0
    public override IEnumerator Execute(UTContext context)
    {
        string finalout = context["CurAssAssetbundleBanshenxiang"] as string;

        //HandleMat(context["foreachfile"]);
        //Debug.Log(UTFileUtils.FullPathToProjectPath(finalout), this);
        HandleAssetbundleBanshenxiang(UTFileUtils.FullPathToProjectPath(finalout));
        yield return("");
    }
コード例 #43
0
    public override IEnumerator Execute(UTContext context)
    {
        var theBaseDirectory = baseDirectory.EvaluateIn(context);
        if (string.IsNullOrEmpty(theBaseDirectory)) {
            theBaseDirectory = UTFileUtils.ProjectRoot;
        }

        if (!Directory.Exists(theBaseDirectory)) {
            throw new UTFailBuildException("The base directory " + theBaseDirectory + " does not exist.", this);
        }

        theBaseDirectory = UTFileUtils.NormalizeSlashes(theBaseDirectory);

        var theTargetDirectory = targetDirectory.EvaluateIn(context);
        if (string.IsNullOrEmpty(theTargetDirectory)) {
            throw new UTFailBuildException("You must specify a target directory.", this);
        }
        theTargetDirectory = UTFileUtils.NormalizeSlashes(theTargetDirectory);

        var theIncludes = EvaluateAll(includes, context);
        var theExcludes = EvaluateAll(excludes, context);
        var doFlatten = flattenStructure.EvaluateIn(context);

        var theFiles = UTFileUtils.CalculateFileset(theBaseDirectory, theIncludes, theExcludes, UTFileUtils.FileSelectionMode.Files);
        var theCopies = UTFileUtils.Repath(theFiles, theBaseDirectory, theTargetDirectory, doFlatten);

        Debug.Log("Copying " + theFiles.Length + " files to " +
            theTargetDirectory + (doFlatten ? " and flattening " : " and preserving ") + " the directory structure.", this);

        var doOverwrite = overwriteExisting.EvaluateIn(context);
        var doOnlyNewer = onlyIfNewer.EvaluateIn(context);

        for(int i = 0; i < theFiles.Length; i++) {
            context.LocalProgress = ((float)i) / ((float) theFiles.Length);
            FileInfo src = new FileInfo(theFiles[i]);
            FileInfo target = new FileInfo(theCopies[i]);
            if (!doOverwrite && target.Exists) {
                if (UTPreferences.DebugMode) {
                    Debug.Log ("File " + theCopies[i] + " exists. Not overwriting it.");
                }
                continue;
            }
            if (doOverwrite && doOnlyNewer && src.LastWriteTime.CompareTo(target.LastWriteTime) <= 0) {
                if (UTPreferences.DebugMode) {
                    Debug.Log ("File " + theFiles[i] + " is not newer than " + theCopies[i] + ". Not copying it.", this);
                }
                continue;
            }
            if (UTPreferences.DebugMode) {
                Debug.Log("Copying " + theFiles[i] + " to " + theCopies[i], this);
            }
            UTFileUtils.EnsureParentFolderExists(theCopies[i]);
            src.CopyTo(theCopies[i], doOverwrite);
            yield return "";
        }
    }
 public override IEnumerator Execute(UTContext context)
 {
     if (forceUpdate != null && forceUpdate.EvaluateIn(context)) { // != null check is because we added this property later.
         AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
     }
     else {
         AssetDatabase.Refresh();
     }
     yield return "";
 }
コード例 #45
0
    public override IEnumerator Execute(UTContext context)
    {
        var debugMode = onlyInDebugMode.EvaluateIn(context);

        if (!debugMode || UTPreferences.DebugMode) {
            var evaluatedText = text.EvaluateIn(context);
            Debug.Log(evaluatedText, this);
        }
        yield return "";
    }
コード例 #46
0
        public override IEnumerator Execute(UTContext context)
        {
            string _filePath = filePath.EvaluateIn (context);
            string _duplicateFilePath = duplicateFilePath.EvaluateIn (context);
            bool _overwrite = overwrite.EvaluateIn (context);

            File.Copy(_filePath, _duplicateFilePath,_overwrite);

            yield return "";
        }
コード例 #47
0
    public override IEnumerator Execute(UTContext context)
    {
        var pathToInstance = assetPath.EvaluateIn (context);
        pathToInstance = UTFileUtils.FullPathToProjectPath (pathToInstance);

        var theAsset = AssetDatabase.LoadMainAssetAtPath (pathToInstance);
        Selection.activeObject = theAsset;

        yield return "";
    }
コード例 #48
0
    public override IEnumerator Execute(UTContext context)
    {
        string finalout = context["AndroidHighRes"] as string;

        Debug.Log("finalout = " + finalout);
        //HandleMat(context["foreachfile"]);
        //Debug.Log(UTFileUtils.FullPathToProjectPath(finalout), this);
        HandleSetAndroidNormalRes(UTFileUtils.FullPathToProjectPath(finalout));
        yield return("");
    }
コード例 #49
0
    public override IEnumerator Execute(UTContext context)
    {
        var theGameObject = gameObject.EvaluateIn(context);
        if (theGameObject == null) {
            throw new UTFailBuildException("Game object is required", this);
        }
        Selection.activeObject = theGameObject;

        yield return "";
    }
コード例 #50
0
ファイル: UTEchoAction.cs プロジェクト: kimch2/PackageClient
    public override IEnumerator Execute(UTContext context)
    {
        var debugMode = onlyInDebugMode.EvaluateIn(context);

        if (!debugMode || UTPreferences.DebugMode)
        {
            var evaluatedText = text.EvaluateIn(context);
            Debug.Log(evaluatedText, this);
        }
        yield return("");
    }
    public override IEnumerator Execute(UTContext context)
    {
        var theGameObject = gameObject.EvaluateIn (context);
        if (theGameObject == null) {
            throw new UTFailBuildException ("You need to specify a game object to revert.", this);
        }

        PrefabUtility.RevertPrefabInstance(theGameObject);

        yield return "";
    }
コード例 #52
0
    public override IEnumerator Execute(UTContext context)
    {
        var files = UTFileUtils.CalculateFileset (EvaluateAll (includes, context), EvaluateAll (excludes, context));
        UTFileUtils.FullPathToProjectPath (files); // repath them to be relative to project root

        var doAmend = amend.EvaluateIn (context);
        var theLabels = EvaluateAll (labels, context);

        Debug.Log("The labels: " + string.Join(", " , theLabels));

        if (doAmend && theLabels.Length == 0) {
            Debug.LogWarning("Amend is set to true but no labels are specified. This will effectively change nothing.");
            yield break;
        }

        Debug.Log ("Updating the labels of " + files.Length + " assets.");

        foreach (var file in files) {
            if (file.EndsWith (".meta")) {
                Debug.LogWarning ("File set contains a meta file: " + file + ". Please exclude meta files from the fileset.", this);
                continue;
            }
            var asset = AssetDatabase.LoadAssetAtPath (file, typeof(UObject));
            string[] finalLabels = theLabels;

            if (doAmend) {
                var currentLabels = AssetDatabase.GetLabels (asset);
                var knownLabels = new HashSet<string> (currentLabels);
                foreach (var aLabel in theLabels) {
                    if (!knownLabels.Contains (aLabel)) {
                        knownLabels.Add (aLabel);
                    }
                }
                finalLabels = new string[knownLabels.Count];
                knownLabels.CopyTo (finalLabels);
            }
            if (UTPreferences.DebugMode) {
                Debug.Log ("Setting labels of " + file + " to [" + string.Join (", ", finalLabels) + "]", this);
            }

            if (finalLabels.Length == 0) {
                AssetDatabase.ClearLabels(asset);
            }
            else {
                AssetDatabase.SetLabels (asset, finalLabels);
            }
            EditorUtility.SetDirty(asset);
            yield return "";
        }

        AssetDatabase.SaveAssets(); // save asset changes.
        Debug.Log ("Assets successfully updated.");
    }
    public override IEnumerator Execute(UTContext context)
    {
        var theGameObject = gameObject.EvaluateIn (context);
        if (theGameObject == null) {
            throw new UTFailBuildException ("You need to specify a game object to tag.", this);
        }

        var theLayer = layer.EvaluateIn (context);
        theGameObject.layer = theLayer;

        yield return "";
    }
コード例 #54
0
    public override IEnumerator Execute(UTContext context)
    {
        string theOutputProperty = outputProperty.EvaluateIn (context);
        if (string.IsNullOrEmpty (theOutputProperty)) {
            throw new UTFailBuildException ("output property is required.", this);
        }

        IEnumerable objects;
        string theInputProperty = inputProperty.EvaluateIn (context);
        if (string.IsNullOrEmpty (theInputProperty)) {
            objects = Resources.FindObjectsOfTypeAll(typeof(GameObject));
        } else {
            var inputList = context [theInputProperty];
            objects = inputList as IEnumerable;
            if (objects == null) {
                if (inputList == null) {
                    throw new UTFailBuildException ("Property '" + theInputProperty + "' has a null value. Cannot use this as input.", this);
                }
                throw new UTFailBuildException ("Property '" + theInputProperty + "' is of type '" + inputList.GetType () + "'. Cannot use this as input.", this);
            }
        }

        var filter = GetFilterForMode (context);

        var doFindNonMatching = findNonMatching.EvaluateIn(context);

        IList result = new ArrayList ();
        var objCount = 0;
        foreach (UObject o in objects) {
            if (o.hideFlags == HideFlags.HideAndDontSave || o.hideFlags == HideFlags.DontSave ) {
                 // skip objects that wouldn't be persisted anyways..
                continue;
            }

            var prefabType = PrefabUtility.GetPrefabType(o);

            if (prefabType == PrefabType.ModelPrefab || prefabType == PrefabType.Prefab) {
                continue; // don't grab any assets.
            }

            objCount++;

            if (filter.Accept (o) != doFindNonMatching) {
                result.Add (o);
            }
        }

        if (UTPreferences.DebugMode) {
            Debug.Log("Filtered " + result.Count + " game objects from " + objCount + ".", this);
        }
        context [theOutputProperty] = result;
        yield return "";
    }
        public override IEnumerator Execute(UTContext context)
        {
            string _filePath = filePath.EvaluateIn (context);
            string _oldValue = oldValue.EvaluateIn (context);
            string _newValue = newValue.EvaluateIn (context);

            string _content = File.ReadAllText(_filePath);

            string _newContent = _content.Replace(_oldValue,_newValue);

            File.WriteAllText(_filePath, _newContent);

            yield return "";
        }
    public override IEnumerator Execute(UTContext context)
    {
        var theGameObject = gameObject.EvaluateIn (context);
        if (theGameObject == null) {
            throw new UTFailBuildException ("You need to specify a game object for which the status should be changed.", this);
        }

        #if UNITY_3_5
        theGameObject.SetActiveRecursively(active.EvaluateIn(context));
        #else
        theGameObject.SetActive(active.EvaluateIn (context));
        #endif
        yield return "";
    }
コード例 #57
0
    public override IEnumerator Execute(UTContext context)
    {
        var theName = propertyName.EvaluateIn (context);
        if (string.IsNullOrEmpty (theName)) {
            throw new UTFailBuildException ("The name of the property must not be empty.",this);
        }

        // get the asset
        var pathToInstance = assetPath.EvaluateIn (context);
        pathToInstance = UTFileUtils.FullPathToProjectPath (pathToInstance);

        var theAsset = AssetDatabase.LoadMainAssetAtPath (pathToInstance);

        yield return "";
    }
コード例 #58
0
    public override IEnumerator Execute(UTContext context)
    {
        string realFolder = folder.EvaluateIn (context);

        try
        {
            System.Diagnostics.Process.Start(new FileInfo(realFolder).Directory.FullName);
        }
        catch(Exception e)
        {
            throw new UTFailBuildException("Opening folder failed. " + e.Message,this);
        }

        yield return "";
    }
コード例 #59
0
    public override IEnumerator Execute(UTContext context)
    {
        string [] realFolders = EvaluateAll(folders, context);

        foreach( var folder in realFolders) {
            Debug.Log("Creating folder " + folder, this);
            try {
                Directory.CreateDirectory(folder);
            }
            catch(Exception e) {
                throw new UTFailBuildException("Creating folder failed. " + e.Message,this);
            }
            yield return "";
        }
    }
        public override IEnumerator Execute(UTContext context)
        {
            string _filePath = filePath.EvaluateIn (context);

            try
            {
                System.Diagnostics.Process.Start(_filePath);
            }
            catch(Exception e)
            {
                throw new UTFailBuildException("Opening File failed. " + e.Message,this);
            }

            yield return "";
        }