static void ILogger_filterLogType(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.ILogger _this = (UnityEngine.ILogger)vc.csObj;
         var result = _this.filterLogType;
         JSApi.setEnum((int)JSApi.SetType.Rval, (int)result);
     }
     else
     {
         UnityEngine.LogType arg0  = (UnityEngine.LogType)JSApi.getEnum((int)JSApi.GetType.Arg);
         UnityEngine.ILogger _this = (UnityEngine.ILogger)vc.csObj;
         _this.filterLogType = arg0;
     }
 }
 static void ILogger_logEnabled(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.ILogger _this = (UnityEngine.ILogger)vc.csObj;
         var result = _this.logEnabled;
         JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(result));
     }
     else
     {
         System.Boolean      arg0  = (System.Boolean)JSApi.getBooleanS((int)JSApi.GetType.Arg);
         UnityEngine.ILogger _this = (UnityEngine.ILogger)vc.csObj;
         _this.logEnabled = arg0;
     }
 }
////////////////////// ILogger ///////////////////////////////////////
// constructors

// fields

// properties
    static void ILogger_logHandler(JSVCall vc)
    {
        if (vc.bGet)
        {
            UnityEngine.ILogger _this = (UnityEngine.ILogger)vc.csObj;
            var result = _this.logHandler;
            JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
        }
        else
        {
            UnityEngine.ILogHandler arg0  = (UnityEngine.ILogHandler)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.ILogger     _this = (UnityEngine.ILogger)vc.csObj;
            _this.logHandler = arg0;
        }
    }
        /// <summary>
        /// <para>Gets the type that an editor draws, by extracting it from the editor's <see cref="CustomEditor"/> attribute, if it is declared.</para>
        /// <para>This method returns null for abstract editor types, as those can never draw anything.</para>
        /// </summary>
        /// <param name="editorType">Type of the editor.</param>
        /// <param name="editorForChildClasses">Whether the editor in question is also an editor for types derived from the given type.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">editorType</exception>
        public static Type GetEditorDrawnType(Type editorType, out bool editorForChildClasses)
        {
            if (editorType == null)
            {
                throw new ArgumentNullException("editorType");
            }

            editorForChildClasses = false;

            if (editorType.IsAbstract || CustomEditorInspectedTypeField == null || CustomEditorEditorForChildClassesField == null)
            {
                return(null);
            }

            UnityEngine.ILogger logger = null;

            if (DebugLoggerProperty != null)
            {
                logger = (UnityEngine.ILogger)DebugLoggerProperty.GetValue(null, null);
            }

            bool previous = true;

            if (logger != null)
            {
                previous          = logger.logEnabled;
                logger.logEnabled = false;
            }

            var customEditorAttribute = editorType.GetAttribute <CustomEditor>();

            if (logger != null)
            {
                logger.logEnabled = previous;
            }

            if (customEditorAttribute != null)
            {
                editorForChildClasses = (bool)CustomEditorEditorForChildClassesField.GetValue(customEditorAttribute);
                return((Type)CustomEditorInspectedTypeField.GetValue(customEditorAttribute));
            }

            return(null);
        }
Пример #5
0
        public bool ScanScenes(string[] scenePaths, bool includeSceneDependencies, bool showProgressBar)
        {
            if (scenePaths.Length == 0)
            {
                return(true);
            }

            bool formerForceEditorModeSerialization = UnitySerializationUtility.ForceEditorModeSerialization;

            try
            {
                UnitySerializationUtility.ForceEditorModeSerialization = true;

                bool hasDirtyScenes = false;

                for (int i = 0; i < EditorSceneManager.sceneCount; i++)
                {
                    if (EditorSceneManager.GetSceneAt(i).isDirty)
                    {
                        hasDirtyScenes = true;
                        break;
                    }
                }

                if (hasDirtyScenes && !EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
                {
                    return(false);
                }

                var oldSceneSetup = EditorSceneManager.GetSceneManagerSetup();

                try
                {
                    for (int i = 0; i < scenePaths.Length; i++)
                    {
                        var scenePath = scenePaths[i];

                        if (showProgressBar && DisplaySmartUpdatingCancellableProgressBar("Scanning scenes for AOT support", "Scene " + (i + 1) + "/" + scenePaths.Length + " - " + scenePath, (float)i / scenePaths.Length))
                        {
                            return(false);
                        }

                        if (!System.IO.File.Exists(scenePath))
                        {
                            Debug.LogWarning("Skipped AOT scanning scene '" + scenePath + "' for a file not existing at the scene path.");
                            continue;
                        }

                        Scene openScene = default(Scene);

                        try
                        {
                            openScene = EditorSceneManager.OpenScene(scenePath, OpenSceneMode.Single);
                        }
                        catch
                        {
                            Debug.LogWarning("Skipped AOT scanning scene '" + scenePath + "' for throwing exceptions when trying to load it.");
                            continue;
                        }

                        var sceneGOs = Resources.FindObjectsOfTypeAll <GameObject>();

                        foreach (var go in sceneGOs)
                        {
                            if (go.scene != openScene)
                            {
                                continue;
                            }

                            if ((go.hideFlags & HideFlags.DontSaveInBuild) == 0)
                            {
                                foreach (var component in go.GetComponents <ISerializationCallbackReceiver>())
                                {
                                    try
                                    {
                                        this.allowRegisteringScannedTypes = true;
                                        component.OnBeforeSerialize();

                                        var prefabSupporter = component as ISupportsPrefabSerialization;

                                        if (prefabSupporter != null)
                                        {
                                            // Also force a serialization of the object's prefab modifications, in case there are unknown types in there

                                            List <UnityEngine.Object> objs = null;
                                            var mods = UnitySerializationUtility.DeserializePrefabModifications(prefabSupporter.SerializationData.PrefabModifications, prefabSupporter.SerializationData.PrefabModificationsReferencedUnityObjects);
                                            UnitySerializationUtility.SerializePrefabModifications(mods, ref objs);
                                        }
                                    }
                                    finally
                                    {
                                        this.allowRegisteringScannedTypes = false;
                                    }
                                }
                            }
                        }
                    }

                    // Load a new empty scene that will be unloaded immediately, just to be sure we completely clear all changes made by the scan
                    // Sometimes this fails for unknown reasons. In that case, swallow any exceptions, and just soldier on and hope for the best!
                    // Additionally, also eat any debug logs that happen here, because logged errors can stop the build process, and we don't want
                    // that to happen.

                    UnityEngine.ILogger logger = null;

                    if (Debug_Logger_Property != null)
                    {
                        logger = (UnityEngine.ILogger)Debug_Logger_Property.GetValue(null, null);
                    }

                    bool previous = true;

                    try
                    {
                        if (logger != null)
                        {
                            previous          = logger.logEnabled;
                            logger.logEnabled = false;
                        }

                        EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);
                    }
                    catch { }
                    finally
                    {
                        if (logger != null)
                        {
                            logger.logEnabled = previous;
                        }
                    }
                }
                finally
                {
                    if (oldSceneSetup != null && oldSceneSetup.Length > 0)
                    {
                        if (showProgressBar)
                        {
                            EditorUtility.DisplayProgressBar("Restoring scene setup", "", 1.0f);
                        }
                        EditorSceneManager.RestoreSceneManagerSetup(oldSceneSetup);
                    }
                }

                if (includeSceneDependencies)
                {
                    for (int i = 0; i < scenePaths.Length; i++)
                    {
                        var scenePath = scenePaths[i];
                        if (showProgressBar && DisplaySmartUpdatingCancellableProgressBar("Scanning scene dependencies for AOT support", "Scene " + (i + 1) + "/" + scenePaths.Length + " - " + scenePath, (float)i / scenePaths.Length))
                        {
                            return(false);
                        }

                        string[] dependencies = AssetDatabase.GetDependencies(scenePath, recursive: true);

                        foreach (var dependency in dependencies)
                        {
                            this.ScanAsset(dependency, includeAssetDependencies: false); // All dependencies of this asset were already included recursively by Unity
                        }
                    }
                }

                return(true);
            }
            finally
            {
                if (showProgressBar)
                {
                    EditorUtility.ClearProgressBar();
                }

                UnitySerializationUtility.ForceEditorModeSerialization = formerForceEditorModeSerialization;
            }
        }
Пример #6
0
        private static bool ScanScenes(string[] scenePaths, bool includeSceneDependencies, bool showProgressBar)
        {
            if (scenePaths.Length == 0)
            {
                return(true);
            }

            bool formerForceEditorModeSerialization = UnitySerializationUtility.ForceEditorModeSerialization;

            try
            {
                UnitySerializationUtility.ForceEditorModeSerialization = true;

                bool hasDirtyScenes = false;

                for (int i = 0; i < EditorSceneManager.sceneCount; i++)
                {
                    if (EditorSceneManager.GetSceneAt(i).isDirty)
                    {
                        hasDirtyScenes = true;
                        break;
                    }
                }

                if (hasDirtyScenes && !EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
                {
                    return(false);
                }

                var oldSceneSetup = EditorSceneManager.GetSceneManagerSetup();

                try
                {
                    for (int i = 0; i < scenePaths.Length; i++)
                    {
                        var scenePath = scenePaths[i];

                        // if (showProgressBar && DisplaySmartUpdatingCancellableProgressBar("Scanning scenes for AOT support", "Scene " + (i + 1) + "/" + scenePaths.Length + " - " + scenePath, (float)i / scenePaths.Length))
                        // {
                        //     return false;
                        // }

                        if (!System.IO.File.Exists(scenePath))
                        {
                            Debug.LogWarning("Skipped AOT scanning scene at " + scenePath + " doesn't exist.");
                            continue;
                        }

                        Scene openScene = default(Scene);

                        try
                        {
                            openScene = EditorSceneManager.OpenScene(scenePath, OpenSceneMode.Single);
                        }
                        catch
                        {
                            Debug.LogWarning("Skipped AOT scanning scene '" + scenePath +
                                             "' for throwing exceptions when trying to load it.");
                            continue;
                        }

                        var sceneGOs = Resources.FindObjectsOfTypeAll <DashController>();

                        foreach (var dashController in sceneGOs)
                        {
                            if (dashController.gameObject.scene != openScene || dashController.Graph == null)
                            {
                                continue;
                            }

                            if ((dashController.gameObject.hideFlags & HideFlags.DontSaveInBuild) == 0)
                            {
                                try
                                {
                                    dashController.Graph.SerializeToBytes(DataFormat.Binary, ref unityRefs);
                                }
                                finally
                                {
                                }
                            }
                        }
                    }

                    // Load a new empty scene that will be unloaded immediately, just to be sure we completely clear all changes made by the scan
                    // Sometimes this fails for unknown reasons. In that case, swallow any exceptions, and just soldier on and hope for the best!
                    // Additionally, also eat any debug logs that happen here, because logged errors can stop the build process, and we don't want
                    // that to happen.

                    UnityEngine.ILogger logger = null;

                    if (Debug_Logger_Property != null)
                    {
                        logger = (UnityEngine.ILogger)Debug_Logger_Property.GetValue(null, null);
                    }

                    bool previous = true;

                    try
                    {
                        if (logger != null)
                        {
                            previous          = logger.logEnabled;
                            logger.logEnabled = false;
                        }

                        EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);
                    }
                    catch
                    {
                    }
                    finally
                    {
                        if (logger != null)
                        {
                            logger.logEnabled = previous;
                        }
                    }
                }
                finally
                {
                    if (oldSceneSetup != null && oldSceneSetup.Length > 0)
                    {
                        if (showProgressBar)
                        {
                            EditorUtility.DisplayProgressBar("Restoring scene setup", "", 1.0f);
                        }

                        EditorSceneManager.RestoreSceneManagerSetup(oldSceneSetup);
                    }
                }

                if (includeSceneDependencies)
                {
                    for (int i = 0; i < scenePaths.Length; i++)
                    {
                        var scenePath = scenePaths[i];
                        // if (showProgressBar && DisplaySmartUpdatingCancellableProgressBar("Scanning scene dependencies for AOT support", "Scene " + (i + 1) + "/" + scenePaths.Length + " - " + scenePath, (float)i / scenePaths.Length))
                        // {
                        //     return false;
                        // }

                        string[] dependencies = AssetDatabase.GetDependencies(scenePath, recursive: true);

                        foreach (var dependency in dependencies)
                        {
                            ScanAsset(dependency,
                                      includeAssetDependencies:
                                      false); // All dependencies of this asset were already included recursively by Unity
                        }
                    }
                }

                return(true);
            }
            finally
            {
                if (showProgressBar)
                {
                    EditorUtility.ClearProgressBar();
                }

                UnitySerializationUtility.ForceEditorModeSerialization = formerForceEditorModeSerialization;
            }
        }
Пример #7
0
 void Start()
 {
     logger = GameController.Instance.SystemLogger;
     GameController.Instance.OnGameReset.TakeUntilDestroy(this).Subscribe(OnGameReset);
 }