Example #1
0
        public static void ApplyGizmoInfo(GizmoInfo info, bool addToRecentlyChanged = true)
        {
            int gizmoEnabled = info.gizmoEnabled ? 1 : 0;

            AnnotationUtility.SetGizmoEnabled(info.classID, info.scriptClass, gizmoEnabled, addToRecentlyChanged);
            AnnotationUtility.SetIconEnabled(info.classID, info.scriptClass, info.iconEnabled ? 1 : 0);
        }
        private void SyncToState()
        {
            Annotation[] annotations = AnnotationUtility.GetAnnotations();
            string       str         = string.Empty;

            if (AnnotationWindow.s_Debug)
            {
                str += "AnnotationWindow: SyncToState\n";
            }
            this.m_BuiltinAnnotations = new List <AInfo>();
            this.m_ScriptAnnotations  = new List <AInfo>();
            for (int index = 0; index < annotations.Length; ++index)
            {
                if (AnnotationWindow.s_Debug)
                {
                    str = str + "   same as below: icon " + (object)annotations[index].iconEnabled + " gizmo " + (object)annotations[index].gizmoEnabled + "\n";
                }
                AInfo ainfo = new AInfo(annotations[index].gizmoEnabled == 1, annotations[index].iconEnabled == 1, annotations[index].flags, annotations[index].classID, annotations[index].scriptClass);
                if (ainfo.m_ScriptClass == string.Empty)
                {
                    this.m_BuiltinAnnotations.Add(ainfo);
                    if (AnnotationWindow.s_Debug)
                    {
                        str = str + "   " + BaseObjectTools.ClassIDToString(ainfo.m_ClassID) + ": icon " + (object)ainfo.m_IconEnabled + " gizmo " + (object)ainfo.m_GizmoEnabled + "\n";
                    }
                }
                else
                {
                    this.m_ScriptAnnotations.Add(ainfo);
                    if (AnnotationWindow.s_Debug)
                    {
                        str = str + "   " + annotations[index].scriptClass + ": icon " + (object)ainfo.m_IconEnabled + " gizmo " + (object)ainfo.m_GizmoEnabled + "\n";
                    }
                }
            }
            this.m_BuiltinAnnotations.Sort();
            this.m_ScriptAnnotations.Sort();
            this.m_RecentAnnotations = new List <AInfo>();
            Annotation[] changedAnnotations = AnnotationUtility.GetRecentlyChangedAnnotations();
            for (int index = 0; index < changedAnnotations.Length && index < 5; ++index)
            {
                AInfo ainfo = this.GetAInfo(changedAnnotations[index].classID, changedAnnotations[index].scriptClass);
                if (ainfo != null)
                {
                    this.m_RecentAnnotations.Add(ainfo);
                }
            }
            this.m_SyncWithState = false;
            if (!AnnotationWindow.s_Debug)
            {
                return;
            }
            Debug.Log((object)str);
        }
Example #3
0
        public static bool TryGetGizmoInfo(Type type, out GizmoInfo info)
        {
            GetAnnotationIdAndClass(type, out var id, out var name);
            var annotation = AnnotationUtility.GetAnnotation(id, name);

            if (annotation.gizmoEnabled == -1 && annotation.iconEnabled == -1 && annotation.flags == -1)
            {
                info = new GizmoInfo();
                return(false);
            }

            info = new GizmoInfo(annotation);
            return(true);
        }
 private void SetGizmoState(AInfo ainfo)
 {
     AnnotationUtility.SetGizmoEnabled(ainfo.m_ClassID, ainfo.m_ScriptClass, (!ainfo.m_GizmoEnabled) ? 0 : 1);
     SceneView.RepaintAll();
 }
        private void SyncToState()
        {
            Annotation[] annotations = AnnotationUtility.GetAnnotations();
            string       text        = "";

            if (AnnotationWindow.s_Debug)
            {
                text += "AnnotationWindow: SyncToState\n";
            }
            this.m_BuiltinAnnotations = new List <AInfo>();
            this.m_ScriptAnnotations  = new List <AInfo>();
            for (int i = 0; i < annotations.Length; i++)
            {
                if (AnnotationWindow.s_Debug)
                {
                    string text2 = text;
                    text = string.Concat(new object[]
                    {
                        text2,
                        "   same as below: icon ",
                        annotations[i].iconEnabled,
                        " gizmo ",
                        annotations[i].gizmoEnabled,
                        "\n"
                    });
                }
                bool  gizmoEnabled = annotations[i].gizmoEnabled == 1;
                bool  iconEnabled  = annotations[i].iconEnabled == 1;
                AInfo aInfo        = new AInfo(gizmoEnabled, iconEnabled, annotations[i].flags, annotations[i].classID, annotations[i].scriptClass);
                if (aInfo.m_ScriptClass == "")
                {
                    this.m_BuiltinAnnotations.Add(aInfo);
                    if (AnnotationWindow.s_Debug)
                    {
                        string text2 = text;
                        text = string.Concat(new object[]
                        {
                            text2,
                            "   ",
                            BaseObjectTools.ClassIDToString(aInfo.m_ClassID),
                            ": icon ",
                            aInfo.m_IconEnabled,
                            " gizmo ",
                            aInfo.m_GizmoEnabled,
                            "\n"
                        });
                    }
                }
                else
                {
                    this.m_ScriptAnnotations.Add(aInfo);
                    if (AnnotationWindow.s_Debug)
                    {
                        string text2 = text;
                        text = string.Concat(new object[]
                        {
                            text2,
                            "   ",
                            annotations[i].scriptClass,
                            ": icon ",
                            aInfo.m_IconEnabled,
                            " gizmo ",
                            aInfo.m_GizmoEnabled,
                            "\n"
                        });
                    }
                }
            }
            this.m_BuiltinAnnotations.Sort();
            this.m_ScriptAnnotations.Sort();
            this.m_RecentAnnotations = new List <AInfo>();
            Annotation[] recentlyChangedAnnotations = AnnotationUtility.GetRecentlyChangedAnnotations();
            int          num = 0;

            while (num < recentlyChangedAnnotations.Length && num < 5)
            {
                AInfo aInfo2 = this.GetAInfo(recentlyChangedAnnotations[num].classID, recentlyChangedAnnotations[num].scriptClass);
                if (aInfo2 != null)
                {
                    this.m_RecentAnnotations.Add(aInfo2);
                }
                num++;
            }
            this.m_SyncWithState = false;
            if (AnnotationWindow.s_Debug)
            {
                Debug.Log(text);
            }
        }
 void SetIconState(AInfo ainfo)
 {
     AnnotationUtility.SetIconEnabled(ainfo.m_ClassID, ainfo.m_ScriptClass, ainfo.m_IconEnabled ? 1 : 0);
     SceneView.RepaintAll();
 }
        private void SyncToState()
        {
            // Sync annotations
            Annotation[] a = AnnotationUtility.GetAnnotations();

            string debuginfo = "";

            if (s_Debug)
            {
                debuginfo += "AnnotationWindow: SyncToState\n";
            }

            m_BuiltinAnnotations = new List <AInfo>();
            m_ScriptAnnotations  = new List <AInfo>();
            for (int i = 0; i < a.Length; ++i)
            {
                if (s_Debug)
                {
                    debuginfo += "   same as below: icon " + a[i].iconEnabled + " gizmo " + a[i].gizmoEnabled + "\n";
                }

                bool  ge   = (a[i].gizmoEnabled == 1) ? true : false;
                bool  ie   = (a[i].iconEnabled == 1) ? true : false;
                AInfo anno = new AInfo(ge, ie, a[i].flags, a[i].classID, a[i].scriptClass);

                if (anno.m_ScriptClass == "")
                {
                    m_BuiltinAnnotations.Add(anno);
                    if (s_Debug)
                    {
                        debuginfo += "   " + UnityType.FindTypeByPersistentTypeID(anno.m_ClassID).name + ": icon " + anno.m_IconEnabled + " gizmo " + anno.m_GizmoEnabled + "\n";
                    }
                }
                else
                {
                    m_ScriptAnnotations.Add(anno);
                    if (s_Debug)
                    {
                        debuginfo += "   " + a[i].scriptClass + ": icon " + anno.m_IconEnabled + " gizmo " + anno.m_GizmoEnabled + "\n";
                    }
                }
            }

            m_BuiltinAnnotations.Sort();
            m_ScriptAnnotations.Sort();

            // Sync recently changed annotations
            m_RecentAnnotations = new List <AInfo>();
            Annotation[] recent = AnnotationUtility.GetRecentlyChangedAnnotations();
            for (int i = 0; i < recent.Length && i < maxShowRecent; ++i)
            {
                // Note: ainfo can be null if script has been renamed.
                AInfo ainfo = GetAInfo(recent[i].classID, recent[i].scriptClass);
                if (ainfo != null)
                {
                    m_RecentAnnotations.Add(ainfo);
                }
            }

            m_SyncWithState = false;

            if (s_Debug)
            {
                Debug.Log(debuginfo);
            }
        }
Example #8
0
 void SetGizmoState(AInfo ainfo, bool addToMostRecentChanged = true)
 {
     AnnotationUtility.SetGizmoEnabled(ainfo.m_ClassID, ainfo.m_ScriptClass, ainfo.m_GizmoEnabled ? 1 : 0, addToMostRecentChanged);
     SceneView.RepaintAll();
 }
Example #9
0
 public static void SetIconEnabled(Type type, bool enabled)
 {
     GetAnnotationIdAndClass(type, out var id, out var name);
     AnnotationUtility.SetIconEnabled(id, name, enabled ? 1 : 0);
 }
Example #10
0
 public static void SetGizmoEnabled(Type type, bool enabled, bool addToRecentlyChanged = true)
 {
     GetAnnotationIdAndClass(type, out var id, out var name);
     AnnotationUtility.SetGizmoEnabled(id, name, enabled ? 1 : 0, addToRecentlyChanged);
 }
Example #11
0
        public static GizmoInfo[] GetGizmoInfo()
        {
            var annotations = AnnotationUtility.GetAnnotations();

            return(annotations.Select(x => new GizmoInfo(x)).ToArray());
        }