public static void checkAnimatorControllers()
 {
     foreach (var genTemplate in genTemplates)
     {
         characterTemplate = genTemplate;
         foreach (var directory in Directory.GetDirectories(genTemplate.prefix))
         {
             characterName = directory.Substring(characterTemplate.prefix.Length);
             var low  = characterName.ToLower();
             var path = characterTemplate.controllerPath(characterName);
             if (File.Exists(path))
             {
                 checkAnimatorController();
             }
             else if (low.Equals("common"))
             {
                 //ignore
             }
             else
             {
                 EditorLogger.Log("AnimatorController不存在 {0}", path);
             }
         }
     }
 }
Esempio n. 2
0
        void OnEnable()
        {
            // Connect to or create the backend
            if (!EditorLogger)
            {
                EditorLogger = Logger.GetLogger <uNodeLoggerEditor>();
                if (!EditorLogger)
                {
                    EditorLogger = uNodeLoggerEditor.Create();
                }
            }

            Logger.AddLogger(EditorLogger);
            EditorLogger.AddWindow(this);
            titleContent.text = "uNode Console";
            ClearSelectedMessage();

            SmallErrorIcon   = EditorGUIUtility.FindTexture("d_console.erroricon.sml");
            SmallWarningIcon = EditorGUIUtility.FindTexture("d_console.warnicon.sml");
            SmallMessageIcon = EditorGUIUtility.FindTexture("d_console.infoicon.sml");
            ErrorIcon        = SmallErrorIcon;
            WarningIcon      = SmallWarningIcon;
            MessageIcon      = SmallMessageIcon;
            Dirty            = true;
            Repaint();
        }
Esempio n. 3
0
    void OnEnable()
    {
        // Connect to or create the backend
        if (!EditorLogger)
        {
            EditorLogger = UberLogger.Logger.GetLogger <UberLoggerEditor>();
            if (!EditorLogger)
            {
                EditorLogger = UberLoggerEditor.Create();
            }
        }

        // UberLogger doesn't allow for duplicate loggers, so this is safe
        // And, due to Unity serialisation stuff, necessary to do to it here.
        UberLogger.Logger.AddLogger(EditorLogger);
        EditorLogger.AddWindow(this);

// _OR_NEWER only became available from 5.3
#if UNITY_5 || UNITY_5_3_OR_NEWER
        titleContent.text = "Uber Console";
#else
        title = "Uber Console";
#endif

        ClearSelectedMessage();

        SmallErrorIcon   = EditorGUIUtility.FindTexture("d_console.erroricon.sml");
        SmallWarningIcon = EditorGUIUtility.FindTexture("d_console.warnicon.sml");
        SmallMessageIcon = EditorGUIUtility.FindTexture("d_console.infoicon.sml");
        ErrorIcon        = SmallErrorIcon;
        WarningIcon      = SmallWarningIcon;
        MessageIcon      = SmallMessageIcon;
        Dirty            = true;
        Repaint();
    }
Esempio n. 4
0
    /// <summary>
    /// Draws the thin, Unity-style toolbar showing error counts and toggle buttons
    /// </summary>
    void DrawToolbar()
    {
        EditorGUILayout.BeginHorizontal();
        if (ButtonClamped("Clear", EditorStyles.toolbarButton))
        {
            EditorLogger.Clear();
        }
        EditorLogger.ClearOnPlay  = ToggleClamped(EditorLogger.ClearOnPlay, "Clear On Play", EditorStyles.toolbarButton);
        EditorLogger.PauseOnError = ToggleClamped(EditorLogger.PauseOnError, "Pause On Error", EditorStyles.toolbarButton);
        ShowTimes = ToggleClamped(ShowTimes, "Show Times", EditorStyles.toolbarButton);

        var buttonSize = EditorStyles.toolbarButton.CalcSize(new GUIContent("T")).y;

        GUILayout.FlexibleSpace();

        var showErrors   = ToggleClamped(ShowErrors, new GUIContent(EditorLogger.NoErrors.ToString(), SmallErrorIcon), EditorStyles.toolbarButton, GUILayout.Height(buttonSize));
        var showWarnings = ToggleClamped(ShowWarnings, new GUIContent(EditorLogger.NoWarnings.ToString(), SmallWarningIcon), EditorStyles.toolbarButton, GUILayout.Height(buttonSize));
        var showMessages = ToggleClamped(ShowMessages, new GUIContent(EditorLogger.NoMessages.ToString(), SmallMessageIcon), EditorStyles.toolbarButton, GUILayout.Height(buttonSize));

        //If the errors/warning to show has changed, clear the selected message
        if (showErrors != ShowErrors || showWarnings != ShowWarnings || showMessages != ShowMessages)
        {
            ClearSelectedMessage();
        }
        ShowWarnings = showWarnings;
        ShowMessages = showMessages;
        ShowErrors   = showErrors;
        EditorGUILayout.EndHorizontal();
    }
Esempio n. 5
0
    private static void DoOpenChunkInMainScene()
    {
        EditorLogger.NotifyAndLog("Opening Chunk in the Main Scene");

        var chunkScene = SceneManager.GetActiveScene();

        var scene = EditorSceneManager.OpenScene(
            MainSceneIndexEditor.MainScene.path,
            OpenSceneMode.Additive
            );

        SceneManager.SetActiveScene(scene);

        var chunk = Object.FindObjectsOfType <Chunk>()
                    .FirstOrDefault(c => chunkScene.name.ToUpper().Contains(c.ChunkName.ToUpper()));

        if (chunk == null)
        {
            EditorLogger.NotifyAndLogWarning("No chunk object in the Main Scene references the current scene");
            EditorSceneManager.SaveModifiedScenesIfUserWantsTo(new[] { scene });
            EditorSceneManager.CloseScene(scene, true);
        }
        else
        {
            chunk.RelocateChunkObjectsToChunk(chunkScene.GetRootGameObjects());
        }
    }
Esempio n. 6
0
        private static void DoBuild(BuildTarget target)
        {
            var platform   = GetPlatformForAssetBundles(target);
            var outputPath = "AssetBundles/" + platform;

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

            Dictionary <string, DateTime> oldFileLastWriteTimes = collectFileLastWriteTimes(outputPath, true);

            var sw = Stopwatch.StartNew();

            EditorLogger.Log("BuildAssetBundles to {0} Start ========================", outputPath);
            var manifest = BuildPipeline.BuildAssetBundles(outputPath,
                                                           BuildAssetBundleOptions.DeterministicAssetBundle | BuildAssetBundleOptions.ChunkBasedCompression |
                                                           BuildAssetBundleOptions.DisableWriteTypeTree,
                                                           target);

            EditorLogger.Log("BuildAssetBundles to {0} Ok, Used {1}", outputPath, sw.Elapsed);

            HashSet <string> neededFiles = collectNeededFiles(manifest, platform);

            CheckFiles(outputPath, neededFiles, oldFileLastWriteTimes);
        }
 private static void printUnusedMotions()
 {
     foreach (var kv in motions)
     {
         if (!usedmotions.Contains(kv.Key))
         {
             EditorLogger.Log("动画文件未使用 {0}", kv.Key);
         }
     }
 }
Esempio n. 8
0
    private static void DoCloseChunksInMainScene()
    {
        EditorLogger.NotifyAndLog("Closing all Chunks in the Main Scene");

        foreach (var scene in MyEditorSceneManager.GetOpenScenes().Where(s => s.buildIndex != MainSceneIndexEditor.MainSceneIndex))
        {
            EditorSceneManager.SaveModifiedScenesIfUserWantsTo(new[] { scene });
            EditorSceneManager.CloseScene(scene, true);
        }
    }
Esempio n. 9
0
        public static void CopyToAssets()
        {
            var platform   = GetPlatformForAssetBundles(EditorUserBuildSettings.activeBuildTarget);
            var outputPath = "AssetBundles/" + platform;
            var sw         = Stopwatch.StartNew();

            EditorLogger.Log("CopyToAssets from {0} Start ========================", outputPath);
            CopyFiles(outputPath, platform, "Assets/StreamingAssets");
            EditorLogger.Log("CopyToAssets from {0} Ok, Used {1}", outputPath, sw.Elapsed);
        }
Esempio n. 10
0
    private static void DoOpenChunksInMainScene()
    {
        EditorLogger.NotifyAndLog("Opening all Chunks in the Main Scene");

        var chunks = Object.FindObjectsOfType <Chunk>();

        foreach (var chunk in chunks)
        {
            OpenChunk(chunk);
        }
    }
        public static void generateAnimatorController()
        {
            AnimatorController originController =
                AssetDatabase.LoadAssetAtPath <AnimatorController>(characterTemplate.templatePath());
            string             controllername = characterTemplate.controllerPath(characterName);
            AnimatorController newController  = AnimatorController.CreateAnimatorControllerAtPath(controllername);

            EditorLogger.Log("----生成开始 {0}", controllername);
            initMotions();
            copyController(originController, newController);
            assignControllerToAnimator(newController);
            printUnusedMotions();
            EditorLogger.Log("----生成完毕 {0}", controllername);
        }
Esempio n. 12
0
        public void OnGUI()
        {
            _clip = EditorGUILayout.ObjectField("Clip", _clip, typeof(AnimationClip), false) as AnimationClip;

            if (_clip != null)
            {
                var bindings = AnimationUtility.GetCurveBindings(_clip);
                EditorGUILayout.LabelField("Curve Count=" + bindings.Length);

                var propertyCount = new Dictionary <string, ClipPropStat>();
                foreach (var binding in bindings)
                {
                    var          curve = AnimationUtility.GetEditorCurve(_clip, binding);
                    ClipPropStat old;

                    if (propertyCount.TryGetValue(binding.propertyName, out old))
                    {
                        old.Count  += 1;
                        old.KeySum += curve.keys.Length;
                    }
                    else
                    {
                        propertyCount[binding.propertyName] = new ClipPropStat()
                        {
                            Count  = 1,
                            KeySum = curve.keys.Length
                        };
                    }
                }

                foreach (var pc in propertyCount)
                {
                    EditorGUILayout.LabelField(pc.Key + " count = " + pc.Value.Count + ", keysum = " + pc.Value.KeySum);
                }

                _filter = EditorGUILayout.TextField("Property Filter", _filter);

                if (GUILayout.Button("Log"))
                {
                    foreach (var binding in bindings)
                    {
                        var curve = AnimationUtility.GetEditorCurve(_clip, binding);
                        if (binding.propertyName.Contains(_filter))
                        {
                            EditorLogger.Log(binding.path + ", " + binding.propertyName + ", Keys: " + curve.keys.Length);
                        }
                    }
                }
            }
        }
Esempio n. 13
0
    private static void OpenChunk(Chunk chunk)
    {
        var chunkAssetGuid = AssetDatabase.FindAssets($"{chunk.ChunkName} t:scene").FirstOrDefault();

        if (chunkAssetGuid == null)
        {
            EditorLogger.NotifyAndLogWarning($"No scene file found for the chunk name {chunk.ChunkName}");
            return;
        }

        var chunkPath  = AssetDatabase.GUIDToAssetPath(chunkAssetGuid);
        var chunkScene = EditorSceneManager.OpenScene(chunkPath, OpenSceneMode.Additive);

        chunk.RelocateChunkObjectsToChunk(chunkScene.GetRootGameObjects());
    }
Esempio n. 14
0
    List <string> GetChannels()
    {
        if (Dirty)
        {
            CurrentChannels = EditorLogger.CopyChannels();
        }

        var categories = CurrentChannels;

        var channelList = new List <string>();

        channelList.Add("All");
        channelList.Add("No Channel");
        channelList.AddRange(categories);
        return(channelList);
    }
Esempio n. 15
0
        private static void Trim(string dir)
        {
            foreach (var animFile in Directory.GetFiles(dir, "*.anim", SearchOption.AllDirectories))
            {
                var           anim = animFile.Replace("\\", "/");
                AnimationClip clip = AssetDatabase.LoadAssetAtPath(anim, typeof(AnimationClip)) as AnimationClip;
                if (clip != null)
                {
                    if (clip.length > 0)
                    {
                        AnimationClip copiedClip = Object.Instantiate(clip);
                        copiedClip.ClearCurves();
                        int trimScale = 0;

                        foreach (var editorCurveBinding in AnimationUtility.GetCurveBindings(clip))
                        {
                            var curve = AnimationUtility.GetEditorCurve(clip, editorCurveBinding);

                            if (editorCurveBinding.propertyName.StartsWith("m_LocalScale"))
                            {
                                trimScale++;
                            }
                            else
                            {
                                copiedClip.SetCurve(editorCurveBinding.path, editorCurveBinding.type,
                                                    editorCurveBinding.propertyName, curve);
                            }
                        }

                        if (trimScale > 0)
                        {
                            EditorLogger.Log("{0} trim scale count ={1}", anim, trimScale);
                            AssetDatabase.CreateAsset(copiedClip, anim);
                        }
                    }
                    else
                    {
                        Debug.LogErrorFormat("animation clip length <= 0: {0} {1}", anim, clip.length);
                    }
                }
                else
                {
                    Debug.LogErrorFormat("Can't load animation clip: {0}", anim);
                }
            }
        }
        public static void checkAnimatorController()
        {
            string             controllername = characterTemplate.controllerPath(characterName);
            AnimatorController controller     = AssetDatabase.LoadAssetAtPath <AnimatorController>(controllername);

            if (controller == null)
            {
                return;
            }


            EditorLogger.Log("----检测开始 {0}", controllername);
            initMotions();
            if (controller.layers.Length > 0)
            {
                foreach (ChildAnimatorState cstate in controller.layers[0].stateMachine.states)
                {
                    var statename = cstate.state.name;
                    if (!containsMotion(statename))
                    {
                        EditorLogger.Log("动画文件不存在 {0}", statename);
                    }
                }

                foreach (AnimatorStateTransition anyTransition in controller.layers[0].stateMachine.anyStateTransitions)
                {
                    var statename = anyTransition.destinationState.name;
                    if (anyTransition.conditions.Length == 1)
                    {
                        var param = anyTransition.conditions[0].parameter;
                        if (param != statename)
                        {
                            EditorLogger.Log("AnyState 到 {0} 的condition {1} 和目的状态名字不一致", statename, param);
                        }
                    }
                    else
                    {
                        EditorLogger.Log("AnyState 到 {0} 不止一个condition", statename);
                    }
                }
            }

            printUnusedMotions();
            EditorLogger.Log("----检测完毕 {0}", controllername);
        }
Esempio n. 17
0
    public void OnGUI()
    {
        if (NeedToUpdateStyles)
        {
            UpdateStyles();
        }

        ResizeTopPane();
        DrawPos = Vector2.zero;
        DrawToolbar();
        DrawFilter();

        DrawChannels();

        float logPanelHeight = CurrentTopPaneHeight - DrawPos.y;

        if (Dirty)
        {
            CurrentLogList.Clear();
            EditorLogger.CopyLogInfoTo(CurrentLogList);
        }
        DrawLogList(logPanelHeight);

        DrawPos.y += DividerHeight;

        DrawLogDetails();

        HandleCopyToClipboard();

        //If we're dirty, do a repaint
        Dirty = false;
        if (MakeDirty)
        {
            Dirty     = true;
            MakeDirty = false;
            Repaint();
        }
        else
        {
            FilterChanged = false;
        }
    }
        private static void assignControllerToAnimator(AnimatorController newController)
        {
            string     prefabPath = string.Format("{0}{1}.prefab", characterTemplate.prefix, characterName);
            GameObject prefab     = AssetDatabase.LoadAssetAtPath <GameObject>(prefabPath);

            if (prefab == null)
            {
                EditorLogger.Log("找不到怪物预制体: {0}", prefabPath);
                return;
            }

            Animator animator = prefab.GetComponent <Animator>();

            if (animator == null)
            {
                EditorLogger.Log("怪物预制体上没有Animator组件: {0}", prefabPath);
                return;
            }
            animator.runtimeAnimatorController = newController;
        }
Esempio n. 19
0
        public static void ExportAnimationTime()
        {
            var anim2Time = new Dictionary <string, float>();

            Collect("Assets/Hero", anim2Time);
            Collect("Assets/Monster", anim2Time);
            Collect("Assets/Npc", anim2Time);
            Collect("Assets/Pet", anim2Time);

            using (var sw = new StreamWriter("../config/animationtime.csv", false, Encoding.GetEncoding("GBK")))
            {
                sw.WriteLine("DO NOT EDIT,clip length in second");
                sw.WriteLine("anim,time");

                foreach (var animtime in anim2Time)
                {
                    sw.WriteLine(animtime.Key.ToLower() + "," + animtime.Value);
                }
            }

            EditorLogger.Log("generated animationtime.csv count={0}", anim2Time.Count);
        }
Esempio n. 20
0
        public void MarkAllAndSave(string saveTo)
        {
            AssetDatabase.RemoveUnusedAssetBundleNames();
            notInterestedOldAssets.Clear();
            allMarks.Clear();

            foreach (var bundle in AssetDatabase.GetAllAssetBundleNames())
            {
                foreach (var assetpath in AssetDatabase.GetAssetPathsFromAssetBundle(bundle))
                {
                    var asset = assetpath.Replace("\\", "/");
                    if (notInterestedOldAssets.ContainsKey(asset))
                    {
                        EditorLogger.Log("duplicate {0}", asset);
                    }
                    else
                    {
                        //EditorLogger.Log("old asset = {0}, bundle = {1}", asset, bundle);
                        notInterestedOldAssets.Add(asset, bundle);
                    }
                }
            }

            DoMark();

            foreach (var old in notInterestedOldAssets)
            {
                var importer = AssetImporter.GetAtPath(old.Key);
                importer.assetBundleName = null;
                EditorLogger.Log("unmark asset = {0}, bundle = {1}", old.Key, old.Value);
            }
            using (var sw = new StreamWriter(saveTo, false)) //no bom
            {
                foreach (var kv in allMarks)
                {
                    sw.WriteLine(kv.Key + "," + kv.Value);
                }
            }
        }
Esempio n. 21
0
        protected void MarkName(string assetPath, string assetBundleName)
        {
            var asset     = assetPath.Replace("\\", "/");
            var bundle    = assetBundleName.Replace("\\", "/").ToLower() + ".bundle";
            var brifasset = asset.Substring(7).ToLower();

            //EditorLogger.Log("asset = {0}, bundle = {1}", brifasset, bundle);
            allMarks[brifasset] = bundle;
            string oldBundle;

            if (notInterestedOldAssets.TryGetValue(asset, out oldBundle))
            {
                notInterestedOldAssets.Remove(asset);
                if (oldBundle.Equals(bundle))
                {
                    return;
                }
            }
            var importer = AssetImporter.GetAtPath(asset);

            EditorLogger.Log("mark asset = {0}, bundle = {1}", asset, bundle);
            importer.assetBundleName = bundle;
        }
Esempio n. 22
0
 private static void logAdd(string fn)
 {
     EditorLogger.Log(EditorLogger.AddColor("ADD FILE " + fn, LoggerColor.orange));
 }
Esempio n. 23
0
    /// <summary>
    /// Draws the thin, Unity-style toolbar showing error counts and toggle buttons
    /// </summary>
    void DrawToolbar()
    {
        var toolbarStyle = EditorStyles.toolbarButton;

        Vector2 elementSize;

        if (ButtonClamped("Clear", EditorStyles.toolbarButton, out elementSize))
        {
            EditorLogger.Clear();
        }
        DrawPos.x += elementSize.x;
        EditorLogger.ClearOnPlay = ToggleClamped(EditorLogger.ClearOnPlay, "Clear On Play", EditorStyles.toolbarButton, out elementSize);
        DrawPos.x += elementSize.x;
        EditorLogger.PauseOnError = ToggleClamped(EditorLogger.PauseOnError, "Error Pause", EditorStyles.toolbarButton, out elementSize);
        DrawPos.x += elementSize.x;
        var showTimes = ToggleClamped(ShowTimes, "Times", EditorStyles.toolbarButton, out elementSize);

        if (showTimes != ShowTimes)
        {
            MakeDirty = true;
            ShowTimes = showTimes;
        }
        DrawPos.x += elementSize.x;
        var collapse = ToggleClamped(Collapse, "Collapse", EditorStyles.toolbarButton, out elementSize);

        if (collapse != Collapse)
        {
            MakeDirty         = true;
            Collapse          = collapse;
            SelectedRenderLog = -1;
        }
        DrawPos.x += elementSize.x;

        ScrollFollowMessages = ToggleClamped(ScrollFollowMessages, "Follow", EditorStyles.toolbarButton, out elementSize);
        DrawPos.x           += elementSize.x;

        var errorToggleContent   = new GUIContent(EditorLogger.NoErrors.ToString(), SmallErrorIcon);
        var warningToggleContent = new GUIContent(EditorLogger.NoWarnings.ToString(), SmallWarningIcon);
        var messageToggleContent = new GUIContent(EditorLogger.NoMessages.ToString(), SmallMessageIcon);

        float totalErrorButtonWidth = toolbarStyle.CalcSize(errorToggleContent).x + toolbarStyle.CalcSize(warningToggleContent).x + toolbarStyle.CalcSize(messageToggleContent).x;

        float errorIconX = position.width - totalErrorButtonWidth;

        if (errorIconX > DrawPos.x)
        {
            DrawPos.x = errorIconX;
        }

        var showErrors = ToggleClamped(ShowErrors, errorToggleContent, toolbarStyle, out elementSize);

        DrawPos.x += elementSize.x;
        var showWarnings = ToggleClamped(ShowWarnings, warningToggleContent, toolbarStyle, out elementSize);

        DrawPos.x += elementSize.x;
        var showMessages = ToggleClamped(ShowMessages, messageToggleContent, toolbarStyle, out elementSize);

        DrawPos.x += elementSize.x;

        DrawPos.y += elementSize.y;
        DrawPos.x  = 0;

        //If the errors/warning to show has changed, clear the selected message
        if (showErrors != ShowErrors || showWarnings != ShowWarnings || showMessages != ShowMessages)
        {
            ClearSelectedMessage();
            MakeDirty = true;
        }
        ShowWarnings = showWarnings;
        ShowMessages = showMessages;
        ShowErrors   = showErrors;
    }
Esempio n. 24
0
    public void OnGUI()
    {
        //Set up the basic style, based on the Unity defaults
        //A bit hacky, but means we don't have to ship an editor guistyle and can fit in to pro and free skins
        Color    defaultLineColor  = GUI.backgroundColor;
        GUIStyle unityLogLineEven  = null;
        GUIStyle unityLogLineOdd   = null;
        GUIStyle unitySmallLogLine = null;

        foreach (var style in GUI.skin.customStyles)
        {
            if (style.name == "CN EntryBackEven")
            {
                unityLogLineEven = style;
            }
            else if (style.name == "CN EntryBackOdd")
            {
                unityLogLineOdd = style;
            }
            else if (style.name == "CN StatusInfo")
            {
                unitySmallLogLine = style;
            }
        }

        EntryStyleBackEven = new GUIStyle(unitySmallLogLine);

        EntryStyleBackEven.normal      = unityLogLineEven.normal;
        EntryStyleBackEven.margin      = new RectOffset(0, 0, 0, 0);
        EntryStyleBackEven.border      = new RectOffset(0, 0, 0, 0);
        EntryStyleBackEven.fixedHeight = 0;

        EntryStyleBackOdd        = new GUIStyle(EntryStyleBackEven);
        EntryStyleBackOdd.normal = unityLogLineOdd.normal;
        // EntryStyleBackOdd = new GUIStyle(unityLogLine);


        SizerLineColour = new Color(defaultLineColor.r * 0.5f, defaultLineColor.g * 0.5f, defaultLineColor.b * 0.5f);

        // GUILayout.BeginVertical(GUILayout.Height(topPanelHeaderHeight), GUILayout.MinHeight(topPanelHeaderHeight));
        ResizeTopPane();
        DrawPos = Vector2.zero;
        DrawToolbar();
        DrawFilter();

        DrawChannels();

        float logPanelHeight = CurrentTopPaneHeight - DrawPos.y;

        if (Dirty)
        {
            CurrentLogList = EditorLogger.CopyLogInfo();
        }
        DrawLogList(logPanelHeight);

        DrawPos.y += DividerHeight;

        DrawLogDetails();

        HandleCopyToClipboard();

        //If we're dirty, do a repaint
        Dirty = false;
        if (MakeDirty)
        {
            Dirty     = true;
            MakeDirty = false;
            Repaint();
        }
    }
Esempio n. 25
0
 private static void logDel(string fn)
 {
     EditorLogger.Log(EditorLogger.AddColor("DELETE FILE " + fn, LoggerColor.purple));
 }
Esempio n. 26
0
 private static void logDelDir(string dir)
 {
     EditorLogger.Log(EditorLogger.AddColor("DELETE DIR " + dir, LoggerColor.purple));
 }
Esempio n. 27
0
        void DrawToolbar()
        {
            var toolbarStyle = EditorStyles.toolbarButton;

            var errorToggleContent   = new GUIContent(EditorLogger.NoErrors.ToString(), SmallErrorIcon);
            var warningToggleContent = new GUIContent(EditorLogger.NoWarnings.ToString(), SmallWarningIcon);
            var messageToggleContent = new GUIContent(EditorLogger.NoMessages.ToString(), SmallMessageIcon);

            GUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.Height(100));
            if (GUILayout.Button(new GUIContent("Clear"), EditorStyles.toolbarButton, GUILayout.Width(50), GUILayout.Height(15)))
            {
                EditorLogger.Clear();
            }
            var collapse = GUILayout.Toggle(Collapse, "Collapse", EditorStyles.toolbarButton, GUILayout.Width(65), GUILayout.Height(15));

            if (collapse != Collapse)
            {
                MakeDirty         = true;
                Collapse          = collapse;
                SelectedRenderLog = -1;
            }
            EditorLogger.ClearOnPlay  = GUILayout.Toggle(EditorLogger.ClearOnPlay, "Clear On Play", EditorStyles.toolbarButton, GUILayout.Width(85), GUILayout.Height(15));
            EditorLogger.PauseOnError = GUILayout.Toggle(EditorLogger.PauseOnError, "Error Pause", EditorStyles.toolbarButton, GUILayout.Width(75), GUILayout.Height(15));
            GUILayout.FlexibleSpace();
            Vector2 size         = EditorStyles.toolbarButton.CalcSize(messageToggleContent);
            var     showMessages = GUILayout.Toggle(ShowMessages, messageToggleContent, EditorStyles.toolbarButton, GUILayout.Width(size.x), GUILayout.Height(15));

            size = EditorStyles.toolbarButton.CalcSize(warningToggleContent);
            var showWarnings = GUILayout.Toggle(ShowWarnings, warningToggleContent, EditorStyles.toolbarButton, GUILayout.Width(size.x), GUILayout.Height(15));

            size = EditorStyles.toolbarButton.CalcSize(errorToggleContent);
            var showErrors = GUILayout.Toggle(ShowErrors, errorToggleContent, EditorStyles.toolbarButton, GUILayout.Width(size.x), GUILayout.Height(15));

            GUILayout.EndHorizontal();
            DrawPos.y += 18;
            //var showTimes = ToggleClamped(ShowTimes, "Times", EditorStyles.toolbarButton, out elementSize);
            //if(showTimes!=ShowTimes)
            //{
            //    MakeDirty = true;
            //    ShowTimes = showTimes;
            //}
            //DrawPos.x += elementSize.x;

            //var showChannels = ToggleClamped(ShowChannels, "Channels", EditorStyles.toolbarButton, out elementSize);
            //if (showChannels != ShowChannels)
            //{
            //    MakeDirty = true;
            //    ShowChannels = showChannels;
            //}
            //DrawPos.x += elementSize.x;

            //If the errors/warning to show has changed, clear the selected message
            if (showErrors != ShowErrors || showWarnings != ShowWarnings || showMessages != ShowMessages)
            {
                ClearSelectedMessage();
                MakeDirty = true;
            }
            ShowWarnings = showWarnings;
            ShowMessages = showMessages;
            ShowErrors   = showErrors;
        }
Esempio n. 28
0
        public void OnGUI()
        {
            Color    defaultLineColor  = GUI.backgroundColor;
            GUIStyle unityLogLineEven  = null;
            GUIStyle unityLogLineOdd   = null;
            GUIStyle unitySmallLogLine = null;

            foreach (var style in GUI.skin.customStyles)
            {
                if (style.name == "CN EntryBackEven")
                {
                    unityLogLineEven = style;
                }
                else if (style.name == "CN EntryBackOdd")
                {
                    unityLogLineOdd = style;
                }
                else if (style.name == "CN StatusInfo")
                {
                    unitySmallLogLine = style;
                }
            }

            EntryStyleBackEven = new GUIStyle(unitySmallLogLine);

            EntryStyleBackEven.normal      = unityLogLineEven.normal;
            EntryStyleBackEven.margin      = new RectOffset(0, 0, 0, 0);
            EntryStyleBackEven.border      = new RectOffset(0, 0, 0, 0);
            EntryStyleBackEven.fixedHeight = 0;

            EntryStyleBackOdd        = new GUIStyle(EntryStyleBackEven);
            EntryStyleBackOdd.normal = unityLogLineOdd.normal;
            // EntryStyleBackOdd = new GUIStyle(unityLogLine);


            SizerLineColour = new Color(defaultLineColor.r * 0.5f, defaultLineColor.g * 0.5f, defaultLineColor.b * 0.5f);

            // GUILayout.BeginVertical(GUILayout.Height(topPanelHeaderHeight), GUILayout.MinHeight(topPanelHeaderHeight));
            ResizeTopPane();
            DrawPos = Vector2.zero;
            DrawToolbar();

            float logPanelHeight = position.height - CurrentTopPaneHeight - DrawPos.y;

            logPanelHeight = Mathf.Clamp(logPanelHeight, 100, position.height - 100);

            if (Dirty)
            {
                CurrentLogList = EditorLogger.CopyLogInfo();
            }
            DrawLogList(logPanelHeight);

            DrawPos.y += DividerHeight;

            DrawLogDetails();

            HandleCopyToClipboard();

            //If we're dirty, do a repaint
            Dirty = false;
            if (MakeDirty)
            {
                Dirty     = true;
                MakeDirty = false;
                Repaint();
            }
        }
Esempio n. 29
0
 private static void logModifiy(string fn)
 {
     EditorLogger.Log("MODIFY FILE {0}", fn);
 }
Esempio n. 30
0
 private static void logMiss(string fn)
 {
     EditorLogger.Log(EditorLogger.AddColor("ERROR MISS FILE " + fn, LoggerColor.red));
 }