コード例 #1
0
ファイル: EditorEx.cs プロジェクト: helpking/UnityPlugins
        /// <summary>
        /// 打包日志 - 错误.
        /// </summary>
        /// <param name="iEditor">当前编辑器</param>
        /// <param name="iFormat">格式.</param>
        /// <param name="iArgs">参数.</param>
        public static void BuildErrorLog(this UnityEditor.Editor iEditor, string iFormat, params object[] iArgs)
        {
            var className = iEditor.GetType().Name;
            var log       = string.Format(iFormat, iArgs);

            Loger.BuildErrorLog($"{className} {log}");
        }
コード例 #2
0
 public static void Raise_Editor_finishedDefaultHeaderGUI(UnityEditor.Editor editor)
 {
     if (Editor_finishedDefaultHeaderGUI != null)
     {
         Editor_finishedDefaultHeaderGUI(editor);
     }
 }
コード例 #3
0
ファイル: EditorEx.cs プロジェクト: helpking/UnityPlugins
        /// <summary>
        /// 日志输出(警告日志)
        /// </summary>
        /// <param name="iEditor">当前编辑器</param>
        /// <param name="iFormat">日志格式</param>
        /// <param name="iArgs"></param>
        public static void Warning(this UnityEditor.Editor iEditor, string iFormat, params object[] iArgs)
        {
            var className = iEditor.GetType().Name;
            var log       = string.Format(iFormat, iArgs);

            Loger.Warning($"[{className}] {log}");
        }
コード例 #4
0
        public Rect GetRect(UnityEditor.Editor editor, int id, Rect current)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return(current);
            }
            bool changed;

            return(GetRect(editor, id, current, out changed));
        }
コード例 #5
0
            /************************************************************************************************************************/

            /// <inheritdoc/>
            public override void OnEnable(int index)
            {
                base.OnEnable(index);

                var settings = AnimancerSettings.Instance;

                if (settings != null)
                {
                    _SettingsEditor = UnityEditor.Editor.CreateEditor(settings);
                }
            }
コード例 #6
0
        public UnityEditor.Editor GetEditor(T item)
        {
            if (item != this.item)
            {
                Dispose();
                editor    = UnityEditor.Editor.CreateEditor(item);
                this.item = item;
            }

            return(editor);
        }
コード例 #7
0
        public static void VariableNameEditor(this UnityEditor.Editor editor, VariableDeclarationModel variableDeclaration)
        {
            var newName = EditorGUILayout.DelayedTextField("Name", variableDeclaration.Title);

            if (newName == variableDeclaration.Title)
            {
                return;
            }

            variableDeclaration.SetNameFromUserName(newName);
        }
コード例 #8
0
        /// <summary>
        /// To be called in the OnDisable of CustomInspectors.
        /// </summary>
        /// <param name="defaultEditor">The defaultEditor created in the OnEnable method.</param>
        public static void DestroyDefaultEditor(UnityEditor.Editor defaultEditor)
        {
            // When OnDisable is called, the default editor we created should be destroyed to avoid memory leakage.
            // Also, make sure to call any required methods like OnDisable
            MethodInfo disableMethod = defaultEditor.GetType().GetMethod("OnDisable", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);

            if (disableMethod != null)
            {
                disableMethod.Invoke(defaultEditor, null);
            }

            Object.DestroyImmediate(defaultEditor);
        }
コード例 #9
0
        public override void OnFooterGUI(FuzzyOptionNode node, Rect position)
        {
            if (editorTarget != value)
            {
                editorTarget = value;
                UEditor.CreateCachedEditor(editorTarget, null, ref editor);
            }

            if (editor != null)
            {
                editor.DrawPreview(position);
            }
        }
コード例 #10
0
        private Rect GetRect(UnityEditor.Editor editor, int id, Rect current, out bool changed)
        {
            if (!animIDs.ContainsKey(id))
            {
                animIDs.Add(id, current);
                changed = false;
                return(current);
            }
            var animId = animIDs[id];

            if (animId != current)
            {
                const float t = 0.1f;
                if (Mathf.Abs(animId.y - current.y) > 0.5)
                {
                    current.y = Mathf.Lerp(animId.y, current.y, t);
                }
                if (Mathf.Abs(animId.height - current.height) > 0.5)
                {
                    current.height = Mathf.Lerp(animId.height, current.height, t);
                }
                if (Mathf.Abs(animId.x - current.x) > 0.5)
                {
                    current.x = Mathf.Lerp(animId.x, current.x, t);
                }
                if (Mathf.Abs(animId.width - current.width) > 0.5)
                {
                    current.width = Mathf.Lerp(animId.width, current.width, t);
                }
                animIDs[id] = current;
                changed     = true;
                editor.Repaint();
            }
            else
            {
                changed = false;
            }
            return(current);
        }
コード例 #11
0
        static AssetList GetInspectorAssets(UnityEditor.Editor inspector)
        {
            AssetList result = new AssetList();

            if (inspector == null)
            {
                return(result);
            }

            foreach (UnityEngine.Object obj in inspector.targets)
            {
                string assetPath = AssetsPath.GetFullPath(obj);

                if (string.IsNullOrEmpty(assetPath))
                {
                    continue;
                }

                result.Add(new Asset(assetPath));
            }

            return(result);
        }
コード例 #12
0
 // IsPreset is an internal API - lets reuse the usable part of this function
 // 93 is a "magic number" and does not represent a combination of other flags here
 internal static bool IsPresetEditor(UnityEditor.Editor editor)
 {
     return((int)((editor.target as Component).gameObject.hideFlags) == 93);
 }
コード例 #13
0
 internal ListsEditor(UnityEditor.Editor editor, bool showList = false)
 {
     MainEditor = editor;
     ShowList   = showList;
 }
コード例 #14
0
 public static void NameEditor(this UnityEditor.Editor editor, ScriptableObject obj)
 {
     obj.name = EditorGUILayout.DelayedTextField("Name", obj.name);
 }
 public override void OnDeactivate()
 {
     m_CachedEditor    = null;
     m_SettingsWrapper = null;
 }
コード例 #16
0
 internal void SetActiveInspector(UnityEditor.Editor inspector)
 {
     mActiveInspector = inspector;
 }
コード例 #17
0
 protected override void CustomOnGUI()
 {
     UnityEditor.Editor editor = null;
     UnityEditor.Editor.CreateCachedEditor(target, null, ref editor);
     editor.DrawDefaultInspector();
 }
コード例 #18
0
ファイル: EditorEx.cs プロジェクト: helpking/UnityPlugins
 /// <summary>
 /// 打包日志(结束Scope).
 /// </summary>
 /// <param name="iEditor">当前编辑器</param>
 public static void BuildEnd(this UnityEditor.Editor iEditor)
 {
     Loger.BuildEnd();
 }
コード例 #19
0
        /**
         *  CreateCachedEditor didn't exist until 5.0, so recreate it's contents if necessary or pass it on.
         */
        internal static void CreateCachedEditor <T>(UnityEngine.Object[] targetObjects, ref UnityEditor.Editor previousEditor) where T : UnityEditor.Editor
        {
            #if UNITY_4_7
            if (previousEditor != null && pbUtil.IsEqual(previousEditor.targets, targetObjects))
            {
                return;
            }

            if (previousEditor != null)
            {
                UnityEngine.Object.DestroyImmediate(previousEditor);
            }

            previousEditor = Editor.CreateEditor(targetObjects, typeof(T));
            #else
            UnityEditor.Editor.CreateCachedEditor(targetObjects, typeof(T), ref previousEditor);
            #endif
        }
コード例 #20
0
 public void OnEnable(UnityEditor.Editor value)
 {
     editor = value;
 }