Exemplo n.º 1
0
        private static void SelectAotSerializationManager()
        {
            Debug.Log(typeof(A <int, double>).CSharpName(true, true));

            fsAotConfiguration[] configs   = Resources.FindObjectsOfTypeAll <fsAotConfiguration>();
            fsAotConfiguration   aotConfig = configs.FirstOrDefault();

            if (ReferenceEquals(aotConfig, null))
            {
                aotConfig = ScriptableObject.CreateInstance <fsAotConfiguration>();
                AssetDatabase.CreateAsset(aotConfig, Path.Combine(fiSettings.RootGeneratedDirectory, "fsAotConfiguration.asset"));
            }

            Selection.activeObject = aotConfig;
        }
        private int GetIndexForState(fsAotConfiguration.AotState state)
        {
            switch (state) {
                case fsAotConfiguration.AotState.Enabled:
                    return 0;
                case fsAotConfiguration.AotState.Disabled:
                    return 1;
                case fsAotConfiguration.AotState.Default:
                    return 2;
            }

            throw new ArgumentException("state is invalid " + state);
        }
        private void DrawType(fsAotConfiguration.Entry entry, Type resolvedType)
        {
            var target = (fsAotConfiguration)this.target;

            EditorGUILayout.BeginHorizontal();

            int currentIndex = GetIndexForState(entry.State);
            int newIndex = GUILayout.Toolbar(currentIndex, options, GUILayout.ExpandWidth(false));
            if (currentIndex != newIndex) {
                entry.State = GetStateForIndex(newIndex);
                target.UpdateOrAddEntry(entry);
                EditorUtility.SetDirty(target);
            }

            string displayName = entry.FullTypeName;
            string tooltip = "";
            if (resolvedType != null) {
                displayName = resolvedType.CSharpName();
                tooltip = resolvedType.CSharpName(true);
            }
            GUIContent label = new GUIContent(displayName, tooltip);
            GUILayout.Label(label);

            GUILayout.FlexibleSpace();

            GUIStyle messageStyle = new GUIStyle(EditorStyles.label);
            string message;
            if (resolvedType != null) {
                message = GetAotCompilationMessage(resolvedType);
                if (string.IsNullOrEmpty(message) == false) {
                    messageStyle.normal.textColor = Color.red;
                } else {
                    switch (IsOutOfDate(resolvedType)) {
                        case OutOfDateResult.NoAot:
                            message = "No AOT model found";
                            break;
                        case OutOfDateResult.Stale:
                            message = "Stale";
                            break;
                        case OutOfDateResult.Current:
                            message = "\u2713";
                            break;
                    }
                }
            } else {
                message = "Cannot load type";
            }

            GUILayout.Label(message, messageStyle);

            EditorGUILayout.EndHorizontal();
        }