Beispiel #1
0
        /// <summary>
        /// Not yet documented.
        /// </summary>
        public override void OnInspectorGUI()
        {
            EnsureInitialized();

            if (this.Tree == null)
            {
                base.OnInspectorGUI();
                return;
            }
            else if (this.Tree.RootPropertyCount == 0)
            {
                var assemblyTypeFlag = AssemblyUtilities.GetAssemblyTypeFlag(this.target.GetType().Assembly);

                if (assemblyTypeFlag == AssemblyTypeFlags.UnityTypes || assemblyTypeFlag == AssemblyTypeFlags.UnityEditorTypes)
                {
                    this.MockUnityGenericInspector();
                    return;
                }
            }

#if PREFAB_DEBUG
            this.PrefabModificationsDebug();
#endif

            if (Event.current.type == EventType.Layout)
            {
                this.tree.DrawMonoScriptObjectField = !ForceHideMonoScriptInEditor &&
                                                      this.tree.UnitySerializedObject != null &&
                                                      this.tree.TargetType != null &&
                                                      GeneralDrawerConfig.Instance.ShowMonoScriptInEditor &&
                                                      !this.tree.TargetType.IsDefined(typeof(HideMonoScriptAttribute), true);
            }

            this.tree.Draw(true);

            NetworkBehaviour networkBehaviour = this.target as NetworkBehaviour;

            if (networkBehaviour != null)
            {
                EditorGUILayout.LabelField(networkChannelLabel, GUIHelper.TempContent(networkBehaviour.GetNetworkChannel().ToString()));
                EditorGUILayout.LabelField(networkSendIntervalLabel, GUIHelper.TempContent(networkBehaviour.GetNetworkSendInterval().ToString()));
            }

            this.RepaintIfRequested();
            GUIHelper.CurrentWindow.wantsMouseMove = true;

            if (Event.current.mousePosition != this.prevMousePosition)
            {
                this.Repaint();
                this.prevMousePosition = Event.current.mousePosition;
            }
        }
Beispiel #2
0
        public override void OnInspectorGUI()
        {
            if (!this.m_Initialized)
            {
                base.serializedObject.Update();
                SerializedProperty property = base.serializedObject.FindProperty("m_Script");
                if (property == null)
                {
                    return;
                }
                MonoScript objectReferenceValue = property.objectReferenceValue as MonoScript;
                this.Init(objectReferenceValue);
            }
            EditorGUI.BeginChangeCheck();
            base.serializedObject.Update();
            SerializedProperty iterator = base.serializedObject.GetIterator();

            for (bool flag = true; iterator.NextVisible(flag); flag = false)
            {
                bool flag2 = this.m_SyncVarNames.Contains(iterator.name);
                if (iterator.propertyType == SerializedPropertyType.ObjectReference)
                {
                    EditorGUILayout.PropertyField(iterator, true, new GUILayoutOption[0]);
                }
                else
                {
                    EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
                    EditorGUILayout.PropertyField(iterator, true, new GUILayoutOption[0]);
                    if (flag2)
                    {
                        GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(52f) };
                        GUILayout.Label("SyncVar", EditorStyles.miniLabel, options);
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
            base.serializedObject.ApplyModifiedProperties();
            EditorGUI.EndChangeCheck();
            int index = 0;

            foreach (System.Reflection.FieldInfo info in base.serializedObject.targetObject.GetType().GetFields())
            {
                if ((info.FieldType.BaseType != null) && info.FieldType.BaseType.Name.Contains("SyncList"))
                {
                    this.m_ShowSyncLists[index] = EditorGUILayout.Foldout(this.m_ShowSyncLists[index], "SyncList " + info.Name + "  [" + info.FieldType.Name + "]");
                    if (this.m_ShowSyncLists[index])
                    {
                        EditorGUI.indentLevel++;
                        IEnumerable enumerable = info.GetValue(base.serializedObject.targetObject) as IEnumerable;
                        if (enumerable != null)
                        {
                            int         num3       = 0;
                            IEnumerator enumerator = enumerable.GetEnumerator();
                            while (enumerator.MoveNext())
                            {
                                if (enumerator.Current != null)
                                {
                                    EditorGUILayout.LabelField("Item:" + num3, enumerator.Current.ToString(), new GUILayoutOption[0]);
                                }
                                num3++;
                            }
                        }
                        EditorGUI.indentLevel--;
                    }
                    index++;
                }
            }
            if (this.m_HasOnSerialize)
            {
                NetworkBehaviour target = base.target as NetworkBehaviour;
                if (target != null)
                {
                    EditorGUILayout.LabelField(this.m_NetworkChannelLabel, new GUIContent(target.GetNetworkChannel().ToString()), new GUILayoutOption[0]);
                    EditorGUILayout.LabelField(this.m_NetworkSendIntervalLabel, new GUIContent(target.GetNetworkSendInterval().ToString()), new GUILayoutOption[0]);
                }
            }
        }
        public override void OnInspectorGUI()
        {
            if (!this.m_Initialized)
            {
                this.serializedObject.Update();
                SerializedProperty property = this.serializedObject.FindProperty("m_Script");
                if (property == null)
                {
                    return;
                }
                this.Init(property.objectReferenceValue as MonoScript);
            }
            EditorGUI.BeginChangeCheck();
            this.serializedObject.Update();
            SerializedProperty iterator = this.serializedObject.GetIterator();

            for (bool enterChildren = true; iterator.NextVisible(enterChildren); enterChildren = false)
            {
                bool flag = this.m_SyncVarNames.Contains(iterator.name);
                if (iterator.propertyType == SerializedPropertyType.ObjectReference)
                {
                    EditorGUILayout.PropertyField(iterator, true, new GUILayoutOption[0]);
                }
                else
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PropertyField(iterator, true, new GUILayoutOption[0]);
                    if (flag)
                    {
                        GUILayout.Label("SyncVar", EditorStyles.toolbarTextField, new GUILayoutOption[1]
                        {
                            GUILayout.Width(52f)
                        });
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
            this.serializedObject.ApplyModifiedProperties();
            EditorGUI.EndChangeCheck();
            int index = 0;

            foreach (System.Reflection.FieldInfo field in this.serializedObject.targetObject.GetType().GetFields())
            {
                if (field.FieldType.BaseType != null && field.FieldType.BaseType.Name.Contains("SyncList"))
                {
                    this.m_ShowSyncLists[index] = (EditorGUILayout.Foldout((this.m_ShowSyncLists[index] ? 1 : 0) != 0, "SyncList " + field.Name + "  [" + field.FieldType.Name + "]") ? 1 : 0) != 0;
                    if (this.m_ShowSyncLists[index])
                    {
                        ++EditorGUI.indentLevel;
                        IEnumerable enumerable = field.GetValue((object)this.serializedObject.targetObject) as IEnumerable;
                        if (enumerable != null)
                        {
                            int         num        = 0;
                            IEnumerator enumerator = enumerable.GetEnumerator();
                            while (enumerator.MoveNext())
                            {
                                if (enumerator.Current != null)
                                {
                                    EditorGUILayout.LabelField("Item:" + (object)num, enumerator.Current.ToString(), new GUILayoutOption[0]);
                                }
                                ++num;
                            }
                        }
                        --EditorGUI.indentLevel;
                    }
                    ++index;
                }
            }
            if (!this.m_HasOnSerialize)
            {
                return;
            }
            NetworkBehaviour target = this.target as NetworkBehaviour;

            if (!((UnityEngine.Object)target != (UnityEngine.Object)null))
            {
                return;
            }
            EditorGUILayout.LabelField(this.m_NetworkChannelLabel, new GUIContent(target.GetNetworkChannel().ToString()), new GUILayoutOption[0]);
            EditorGUILayout.LabelField(this.m_NetworkSendIntervalLabel, new GUIContent(target.GetNetworkSendInterval().ToString()), new GUILayoutOption[0]);
        }
Beispiel #4
0
        private void DrawOdinInspector()
        {
            EnsureInitialized();

            if (this.Tree == null)
            {
                base.OnInspectorGUI();
                return;
            }
            else if (this.Tree.RootPropertyCount == 0)
            {
                var assemblyTypeFlag = AssemblyUtilities.GetAssemblyTypeFlag(this.target.GetType().Assembly);

                if (assemblyTypeFlag == AssemblyTypeFlags.UnityTypes || assemblyTypeFlag == AssemblyTypeFlags.UnityEditorTypes)
                {
                    this.MockUnityGenericInspector();
                    return;
                }
            }

#if PREFAB_DEBUG
            this.PrefabModificationsDebug();
#endif

            if (Event.current.type == EventType.Layout)
            {
                this.tree.DrawMonoScriptObjectField = !ForceHideMonoScriptInEditor &&
                                                      this.tree.UnitySerializedObject != null &&
                                                      this.tree.TargetType != null &&
                                                      GeneralDrawerConfig.Instance.ShowMonoScriptInEditor &&
                                                      !this.tree.TargetType.IsDefined(typeof(HideMonoScriptAttribute), true);
            }
#if UNITY_EDITOR
            UnityEngine.Profiling.Profiler.BeginSample("DrawOdinInspector-DrawTree");
#endif
            this.DrawTree();

#if UNITY_EDITOR
            UnityEngine.Profiling.Profiler.EndSample();
#endif

            NetworkBehaviour networkBehaviour = this.target as NetworkBehaviour;

            if (networkBehaviour != null)
            {
                EditorGUILayout.LabelField(networkChannelLabel, GUIHelper.TempContent(networkBehaviour.GetNetworkChannel().ToString()));
                EditorGUILayout.LabelField(networkSendIntervalLabel, GUIHelper.TempContent(networkBehaviour.GetNetworkSendInterval().ToString()));
            }

            this.RepaintIfRequested();
            GUIHelper.CurrentWindow.wantsMouseMove = true;

            if (GUIHelper.CurrentWindow == EditorWindow.focusedWindow)
            {
                //if ((Event.current.mousePosition - this.prevMousePosition).sqrMagnitude > 2)
                //{
                //    this.Repaint();
                //    this.prevMousePosition = Event.current.mousePosition;
                //}
            }
        }