コード例 #1
0
ファイル: MethodDrawer.cs プロジェクト: MCV-Univalle/Rivit
        /// <summary>
        /// Invokes the Method, messages the user about it and updates results member if method has a return value.
        /// </summary>
        /// <param name="pingIfUnityObject"> True if should "ping" the return value, if the method has one, and it's of type UnityEngine.Object  or UnityEngine.Object[], and not null or empty. </param>
        /// <param name="displayDialogIfNotUnityObject"> True if should display a popup dialog to the user about the results, if method has a return type, and it's not of type UnityEngine.Object or UnityEngine.Object[]. </param>
        /// <param name="copyToClipboardIfNotPingedOrDialogShown"> True if should copy the method return value to clipboard, if it has one, and if value was not pinged and popup was not displayed. </param>
        ///  <param name="pingIfUnityObject"> True if should select the return value(s), if the method has one, and it's of type UnityEngine.Object  or UnityEngine.Object[], and not null or empty. </param>
        private void Invoke(bool pingIfUnityObject, bool displayDialogIfNotUnityObject, bool copyToClipboardIfNotPingedOrDialogShown, bool selectIfUnityObject)
        {
            Inspector.RefreshView();             // make sure repaint gets called immediately

            string error;
            bool   suppressMessages = pingIfUnityObject || displayDialogIfNotUnityObject || copyToClipboardIfNotPingedOrDialogShown || selectIfUnityObject;

            Invoke(out error, suppressMessages);

            if (!hasReturnValue)
            {
                                #if DEV_MODE && PI_ASSERTATIONS
                Debug.Assert(!suppressMessages);
                                #endif
                return;
            }

            if (pingIfUnityObject)
            {
                var list = new List <Object>(0);
                if (UnityObjectExtensions.TryExtractObjectReferences(results, ref list))
                {
                    DrawGUI.Ping(list.ToArray());
                }
            }

            if (selectIfUnityObject)
            {
                var list = new List <Object>(0);
                if (UnityObjectExtensions.TryExtractObjectReferences(results, ref list))
                {
                    Inspector.Select(list.ToArray());
                }
            }

            if (displayDialogIfNotUnityObject && !isCoroutine)
            {
                TryDisplayDialogForResult();
            }
            else if (copyToClipboardIfNotPingedOrDialogShown)
            {
                Clipboard.Copy(result);
            }

            if (Event.current != null)
            {
                ExitGUIUtility.ExitGUI();                 // avoid ArgumentException: Getting control 1's position in a group with only 1 controls when doing repaint
            }
        }
コード例 #2
0
ファイル: MethodDrawer.cs プロジェクト: MCV-Univalle/Rivit
        private bool TryPingResult()
        {
            if (!hasReturnValue)
            {
                return(false);
            }

            if (!hasResult)
            {
                Invoke();
            }

            var list = new List <Object>(0);

            if (UnityObjectExtensions.TryExtractObjectReferences(results, ref list))
            {
                DrawGUI.Ping(list.ToArray());
            }
            return(true);
        }