少年修仙传客户端基础资源
dabaoji
2023-11-13 0a23e1b83f8fda8ab9f9e32fe71c26c431faf63a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
using System;
using UnityEngine;
using UnityEditor;
using UnityEngine.Assertions;
using System.Collections.Generic;
using System.Linq;
using UnityEditor.IMGUI.Controls;
 
namespace UnityEngine.AssetBundles
{
    public class MessageSystem
    {
        private static Texture2D m_ErrorIcon = null;
        private static Texture2D m_WarningIcon = null;
        private static Texture2D m_InfoIcon = null;
        private static Dictionary<MessageFlag, Message> m_MessageLookup = null;
 
        [Flags]
        public enum MessageFlag
        {
            None = 0x0,
 
            Info = 0x80,                  //this flag is only used to check bits, not set.
            EmptyBundle = 0x81,
            EmptyFolder = 0x82,
 
            Warning = 0x8000,                  //this flag is only used to check bits, not set.
            WarningInChildren = 0x8100,
            AssetsDuplicatedInMultBundles = 0x8200,
            VariantBundleMismatch = 0x8400,
 
            Error = 0x800000,                  //this flag is only used to check bits, not set.
            ErrorInChildren = 0x810000,
            SceneBundleConflict = 0x820000,
            DependencySceneConflict = 0x840000,
        }
 
        public class MessageState
        {
            //I have an enum and a set of enums to make some logic cleaner.  
            // The enum has masks for Error/Warning/Info that won't ever be in the set
            // this allows for easy checking of IsSet for error rather than specific errors. 
            private MessageFlag m_MessageFlags;
            private HashSet<MessageFlag> m_MessageSet;
 
 
            public MessageState()
            {
                m_MessageFlags = MessageFlag.None;
                m_MessageSet = new HashSet<MessageFlag>();
            }
 
            public void Clear()
            {
                m_MessageFlags = MessageFlag.None;
                m_MessageSet.Clear();
            }
 
            public void SetFlag(MessageFlag flag, bool on)
            {
                if (flag == MessageFlag.Info || flag == MessageFlag.Warning || flag == MessageFlag.Error)
                    return;
 
                if (on)
                {
                    m_MessageFlags |= flag;
                    m_MessageSet.Add(flag);
                }
                else
                {
                    m_MessageFlags &= ~flag;
                    m_MessageSet.Remove(flag);
                }
            }
            public bool IsSet(MessageFlag flag)
            {
                return (m_MessageFlags & flag) == flag;
            }
            public bool HasMessages()
            {
                return (m_MessageFlags != MessageFlag.None);
            }
 
            public MessageType HighestMessageLevel()
            {
                if (IsSet(MessageFlag.Error))
                    return MessageType.Error;
                if (IsSet(MessageFlag.Warning))
                    return MessageType.Warning;
                if (IsSet(MessageFlag.Info))
                    return MessageType.Info;
                return MessageType.None;
            }
            public MessageFlag HighestMessageFlag()
            {
                MessageFlag high = MessageFlag.None;
                foreach(var f in m_MessageSet)
                {
                    if (f > high)
                        high = f;
                }
                return high;
            }
 
            public List<Message> GetMessages()
            {
                var msgs = new List<Message>();
                foreach(var f in m_MessageSet)
                {
                    msgs.Add(GetMessage(f));
                }
                return msgs;
            }
        }
        public static Texture2D GetIcon(MessageType sev)
        {
            if (sev == MessageType.Error)
                return GetErrorIcon();
            else if (sev == MessageType.Warning)
                return GetWarningIcon();
            else if (sev == MessageType.Info)
                return GetInfoIcon();
            else
                return null;
        }
        private static Texture2D GetErrorIcon()
        {
            if (m_ErrorIcon == null)
                FindMessageIcons();
            return m_ErrorIcon;
        }
        private static Texture2D GetWarningIcon()
        {
            if (m_WarningIcon == null)
                FindMessageIcons();
            return m_WarningIcon;
        }
        private static Texture2D GetInfoIcon()
        {
            if (m_InfoIcon == null)
                FindMessageIcons();
            return m_InfoIcon;
        }
 
        private static void FindMessageIcons()
        {
            m_ErrorIcon = EditorGUIUtility.FindTexture("console.errorIcon");
            m_WarningIcon = EditorGUIUtility.FindTexture("console.warnicon");
            m_InfoIcon = EditorGUIUtility.FindTexture("console.infoIcon");
        }
        public class Message
        {
            public Message(string msg, MessageType sev)
            {
                message = msg;
                severity = sev;
            }
 
            public MessageType severity;
            public string message;
            public Texture2D icon
            {
                get
                {
                    return GetIcon(severity);
                }
            }
        }
 
        public static Message GetMessage(MessageFlag lookup)
        {
            if (m_MessageLookup == null)
                InitMessages();
 
            Message msg = null;
            m_MessageLookup.TryGetValue(lookup, out msg);
            if (msg == null)
                msg = m_MessageLookup[MessageFlag.None];
            return msg;
        }
 
        private static void InitMessages()
        {
            m_MessageLookup = new Dictionary<MessageFlag, Message>();
 
            m_MessageLookup.Add(MessageFlag.None, new Message(string.Empty, MessageType.None));
            m_MessageLookup.Add(MessageFlag.EmptyBundle, new Message("This bundle is empty.  Empty bundles cannot get saved with the scene and will disappear from this list if Unity restarts or if various other bundle rename or move events occur.", MessageType.Info));
            m_MessageLookup.Add(MessageFlag.EmptyFolder, new Message("This folder is either empty or contains only empty children.  Empty bundles cannot get saved with the scene and will disappear from this list if Unity restarts or if various other bundle rename or move events occur.", MessageType.Info));
            m_MessageLookup.Add(MessageFlag.WarningInChildren, new Message("Warning in child(ren)", MessageType.Warning));
            m_MessageLookup.Add(MessageFlag.AssetsDuplicatedInMultBundles, new Message("Assets being pulled into this bundle due to dependencies are also being pulled into another bundle.  This will cause duplication in memory", MessageType.Warning));
            m_MessageLookup.Add(MessageFlag.VariantBundleMismatch, new Message("Variants of a given bundle must have exactly the same assets between them based on a Name.Extension (without Path) comparison. These bundle variants fail that check.", MessageType.Warning));
            m_MessageLookup.Add(MessageFlag.ErrorInChildren, new Message("Error in child(ren)", MessageType.Error));
            m_MessageLookup.Add(MessageFlag.SceneBundleConflict, new Message("A bundle with one or more scenes must only contain scenes.  This bundle has scenes and non-scene assets.", MessageType.Error));
            m_MessageLookup.Add(MessageFlag.DependencySceneConflict, new Message("The folder added to this bundle has pulled in scenes and non-scene assets.  A bundle must only have one type or the other.", MessageType.Error));
        }
    }
 
}