void Awake()
 {
     if (helper == null)
     {
         DontDestroyOnLoad(gameObject);
         helper = this;
     } else if (helper != this)
     {
         Destroy(gameObject);
     }
 }
示例#2
0
    void Awake()
    {
        guiManager = GameObject.FindGameObjectWithTag("GUI").GetComponent<GUIManager>();
        guiHelper = GameObject.FindGameObjectWithTag("GUI").GetComponent<GUIHelper>();
        camController = GameObject.Find("Main Camera").GetComponent<CameraFollow>();
        pauseItems = GameObject.FindGameObjectsWithTag("PauseItem");
        endgameItems = GameObject.FindGameObjectsWithTag("ResultItem");

        if (!goal)
            goal = GameObject.FindGameObjectWithTag("Goal");

        foreach (GameObject item in pauseItems)
        {
            item.SetActive(false);
        }

        foreach (GameObject item in endgameItems)
        {
            item.SetActive(false);
        }
    }
示例#3
0
    public void DisplayPlayers()
    {
        if (guiHelper == null)
        {
            guiHelper = GetComponent<GUIHelper>();
           // guiHelper.UpdateGUIElementsSize();
        }

        SetUserName();

        //Player 1
        if (username1 == MultiplayerManager.Instance.PlayerName)
        {
            guiHelper.ChangeTexture("PlayerOneFrame", "UI/frame-ninja-player-host-avatar");
        }
        else
        {
            guiHelper.ChangeTexture("PlayerOneFrame", "UI/frame-ninja-player-guest-avatar");
        }

        //Player 2
        if (username2 != waitingMsg)
        {
            if (username2 == MultiplayerManager.Instance.PlayerName)
            {
                guiHelper.ChangeTexture("PlayerTwoFrame", "UI/frame-astro-player-host-avatar");
            }
            else
            {
                guiHelper.ChangeTexture("PlayerTwoFrame", "UI/frame-astro-player-guest-avatar");
            }
        }
        else
        {
            guiHelper.ChangeTexture("PlayerTwoFrame", "UI/frame-player-waiting-avatar2"); //Wait for other player to join
        }
    }
        protected void saveImage(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
        {
            string tempPath = System.IO.Path.GetTempPath();
            System.Drawing.Image img = new GUIHelper().byteArrayToImage(e.GetContents());

            if (Session["fileContentType_"] == null)
            {
                Session.Add(("fileContentType_"), e.ContentType);
            }
            Session["fileContentType_"] = e.ContentType;

            if (Session["fileContents_"] == null)
            {
                Session.Add("fileContents_", e.GetContents());
            }
            Session["fileContents_"] = e.GetContents();

            string relativePath = Page.AppRelativeVirtualPath;
            relativePath = relativePath.Replace("~", "");
            e.PostedUrl = String.Format("/HRM" + relativePath + "?preview=1");
        }
示例#5
0
 /// <summary>
 /// 返回UI相机
 /// </summary>
 /// <returns></returns>
 public static Camera GetUICamera()
 {
     return(GUIHelper.GetUICamera());
 }
示例#6
0
 /// <summary>
 /// 返回UI相机节点
 /// </summary>
 /// <returns></returns>
 public static GameObject GetUICameraObj()
 {
     return(GUIHelper.GetUICameraObj());
 }
示例#7
0
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            var property  = this.Property;
            var attribute = this.Attribute;

            var toggleProperty = property.Children.Get(attribute.ToggleMemberName);

            var context = property.Context.Get <ToggleGroupConfig>(this, "ToggleGroupConfig", (ToggleGroupConfig)null);

            if (context.Value == null)
            {
                context.Value           = new ToggleGroupConfig();
                context.Value.IsVisible = property.Context.GetPersistent <bool>(this, "IsVisible", false);
                if (toggleProperty == null)
                {
                    context.Value.ErrorMessage = "No property or field named " + attribute.ToggleMemberName + " found. Make sure the property is part of the inspector and the group.";
                }
                else
                {
                    context.Value.TitleHelper = new StringMemberHelper(property, attribute.ToggleGroupTitle, ref context.Value.ErrorMessage);
                }
            }

            if (context.Value.ErrorMessage != null)
            {
                SirenixEditorGUI.ErrorMessageBox(context.Value.ErrorMessage);
            }
            else
            {
                PropertyContext <string> openGroup = null;

                if (attribute.CollapseOthersOnExpand)
                {
                    if (property.Parent == null)
                    {
                        openGroup = property.Context.Get <string>(this, "OpenGroup", (string)null);
                    }
                    else
                    {
                        var parent = (property.Parent.ValueEntry == null || property.Parent.Info.HasSingleBackingMember) ? property.Parent : property.Parent.Parent;
                        openGroup = parent.Context.GetGlobal <string>("OpenFoldoutToggleGroup", (string)null);
                    }

                    if (openGroup.Value != null && openGroup.Value != property.Path)
                    {
                        context.Value.IsVisible.Value = false;
                    }
                }

                bool isEnabled = (bool)toggleProperty.ValueEntry.WeakSmartValue;

                string title = context.Value.TitleHelper.GetString(property) ?? attribute.GroupName;

                bool prev          = context.Value.IsVisible.Value;
                bool visibleBuffer = context.Value.IsVisible.Value;
                if (SirenixEditorGUI.BeginToggleGroup(UniqueDrawerKey.Create(property, this), ref isEnabled, ref visibleBuffer, title))
                {
                    for (int i = 0; i < property.Children.Count; i++)
                    {
                        var child = property.Children[i];
                        if (child != toggleProperty)
                        {
                            child.Draw(child.Label);
                        }
                    }
                }
                else
                {
                    // OnValueChanged is not fired if property is not drawn.
                    GUIHelper.BeginDrawToNothing();
                    toggleProperty.Draw(toggleProperty.Label);
                    GUIHelper.EndDrawToNothing();
                }
                SirenixEditorGUI.EndToggleGroup();

                context.Value.IsVisible.Value = visibleBuffer;
                if (openGroup != null && prev != context.Value.IsVisible.Value && context.Value.IsVisible.Value)
                {
                    openGroup.Value = property.Path;
                }

                toggleProperty.ValueEntry.WeakSmartValue = isEnabled;

                // Why is this here? Commenting this out for now
                //toggleProperty.ValueEntry.ApplyChanges();
            }
        }
        public static void OpenSirenixPreferences()
        {
            var window = GetWindow <SirenixPreferencesWindow>();

            window.position = GUIHelper.GetEditorWindowRect().AlignCenter(900, 600);
        }
示例#9
0
        /// <summary>
        /// Ends drawing a property tree, and handles management of undo, as well as marking scenes and drawn assets dirty.
        /// </summary>
        /// <param name="tree">The tree.</param>
        public static void EndDrawPropertyTree(PropertyTree tree)
        {
            tree.InvokeDelayedActions();

            if (tree.UnitySerializedObject != null)
            {
                if (mPropertyFieldGetter != null)
                {
                    var    obj = tree.UnitySerializedObject;
                    IntPtr ptr = mPropertyFieldGetter(ref obj);

                    if (ptr == IntPtr.Zero)
                    {
                        // SerializedObject has been disposed, likely due to a scene change invoked from GUI code.
                        // BAIL THE F**K OUT! :D Crashes will happen.
                        return;
                    }
                }

                if (tree.WillUndo)
                {
                    tree.UnitySerializedObject.ApplyModifiedProperties();
                }
                else
                {
                    tree.UnitySerializedObject.ApplyModifiedPropertiesWithoutUndo();
                }
            }

            bool appliedOdinChanges = false;

            if (tree.ApplyChanges())
            {
                appliedOdinChanges = true;
                GUIHelper.RequestRepaint();

                if (tree.TargetType.ImplementsOrInherits(typeof(UnityEngine.Object)))
                {
                    var targets = tree.WeakTargets;

                    for (int i = 0; i < targets.Count; i++)
                    {
                        var target = (UnityEngine.Object)targets[i];

                        if (AssetDatabase.Contains(target))
                        {
                            EditorUtility.SetDirty(target);
                        }
                        else if (Application.isPlaying == false)
                        {
#if UNITY_5_3_OR_NEWER
                            if (tree.TargetType.ImplementsOrInherits(typeof(Component)))
                            {
                                Component component = (Component)target;
                                EditorUtility.SetDirty(target);
                                UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(component.gameObject.scene);
                            }
                            else
                            {
                                // We can't find out where this thing is from
                                // It is probably a "temporary" UnityObject created from a script somewhere
                                // Just to be safe, mark it as dirty, and mark all scenes as dirty

                                EditorUtility.SetDirty(target);
                                UnityEditor.SceneManagement.EditorSceneManager.MarkAllScenesDirty();
                            }
#else
                            EditorApplication.MarkSceneDirty();
#endif
                        }
                    }
                }
            }

            // This is very important, as applying changes may cause more actions to be delayed
            tree.InvokeDelayedActions();

            if (appliedOdinChanges)
            {
                tree.InvokeOnValidate();
            }

            drawnInspectorDepthCount--;

#if ODIN_TRIAL_VERSION
            if (drawnInspectorDepthCount == 0)
            {
                float height = OdinTrialVersionInfo.IsExpired ? 22 : 17;
                var   rect   = GUILayoutUtility.GetRect(16, height, GUILayoutOptions.ExpandWidth().Height(height));

                var bgRect = rect;
                bgRect.xMin -= 20;
                bgRect.xMax += 20;
                bgRect.y    += 2;
                SirenixEditorGUI.DrawBorders(bgRect, 0, 0, 1, 0, SirenixGUIStyles.LightBorderColor);

                rect.y += 2;
                if (OdinTrialVersionInfo.IsExpired)
                {
                    EditorGUI.DrawRect(bgRect, Color.black);
                    GUIHelper.PushContentColor(Color.red);

                    GUI.Label(rect.AddY(3), "Odin Inspector Trial expired!", SirenixGUIStyles.Label);
                    GUIHelper.PopContentColor();
                    var btnRect = rect.AlignRight(EditorStyles.miniButton.CalcSize(new GUIContent("Purchase Odin Inspector")).x);
                    btnRect.yMin += 2;
                    btnRect.yMax -= 2;
                    GUIHelper.PushColor(Color.green);
                    if (GUI.Button(btnRect, "Purchase Odin Inspector", EditorStyles.miniButton))
                    {
                        UnityEditorInternal.AssetStore.Open("content/89041");
                    }
                    GUIHelper.PopColor();
                }
                else
                {
                    GUI.Label(rect, "Odin Inspector Trial Version", SirenixGUIStyles.LeftAlignedGreyMiniLabel);
                    GUI.Label(rect, "Expires " + OdinTrialVersionInfo.ExpirationDate.ToShortDateString(), EditorStyles.centeredGreyMiniLabel);
                    GUI.Label(rect, OdinTrialVersionInfo.ExpirationDate.Subtract(System.DateTime.Now).TotalHours.ToString("F2") + " hours remaining.", SirenixGUIStyles.RightAlignedGreyMiniLabel);
                }
            }
#endif
        }
        // Token: 0x06000A26 RID: 2598 RVA: 0x00031018 File Offset: 0x0002F218
        public void Draw(bool drawCodeExample)
        {
            if (TrickOverViewPreview.exampleGroupStyle == null)
            {
                TrickOverViewPreview.exampleGroupStyle = new GUIStyle(GUIStyle.none)
                {
                    padding = new RectOffset(1, 1, 10, 0)
                };
            }
            if (TrickOverViewPreview.previewStyle == null)
            {
                TrickOverViewPreview.previewStyle = new GUIStyle(GUIStyle.none)
                {
                    padding = new RectOffset(0, 0, 0, 0)
                };
            }

            GUILayout.BeginVertical(TrickOverViewPreview.exampleGroupStyle, new GUILayoutOption[0]);
            GUILayout.Label("Preview:", SirenixGUIStyles.BoldTitle, new GUILayoutOption[0]);
            GUILayout.BeginVertical(TrickOverViewPreview.previewStyle, GUILayoutOptions.ExpandWidth(true));
            Rect rect = GUIHelper.GetCurrentLayoutRect().Expand(4f, 0f);

            SirenixEditorGUI.DrawSolidRect(rect, EditorGUIUtility.isProSkin ? TrickOverViewPreview.previewBackgroundColorDark : TrickOverViewPreview.previewBackgroundColorLight, true);
            SirenixEditorGUI.DrawBorders(rect, 1, true);
            GUILayout.Space(8f);

            m_DrawCallbaclAction.Invoke(rect);
            this.tree = (this.tree ?? PropertyTree.Create(m_Example));
            this.tree.Draw(false);

            GUILayout.Space(8f);
            GUILayout.EndVertical();
            if (drawCodeExample && m_Example.GetTrickOverViewInfo().Code != null)
            {
                GUILayout.Space(12f);
                GUILayout.Label("Code", SirenixGUIStyles.BoldTitle, new GUILayoutOption[0]);
                Rect rect2 = SirenixEditorGUI.BeginToolbarBox(new GUILayoutOption[0]);
                SirenixEditorGUI.DrawSolidRect(rect2.HorizontalPadding(1f), SyntaxHighlighter.BackgroundColor, true);
                SirenixEditorGUI.BeginToolbarBoxHeader(22f);
                if (SirenixEditorGUI.ToolbarButton(this.showRaw ? "Highlighted" : "Raw", false))
                {
                    this.showRaw = !this.showRaw;
                }
                GUILayout.FlexibleSpace();
                EditorGUILayoutExtension.LinkFileLabelField("点击此处定位到脚本目录", this.m_Example.GetTrickOverViewInfo().CodePath);
                GUILayout.FlexibleSpace();
                if (SirenixEditorGUI.ToolbarButton("Copy", false))
                {
                    Clipboard.Copy <string>(this.m_Example.GetTrickOverViewInfo().Code);
                }
                SirenixEditorGUI.EndToolbarBoxHeader();
                if (TrickOverViewPreview.codeTextStyle == null)
                {
                    TrickOverViewPreview.codeTextStyle = new GUIStyle(SirenixGUIStyles.MultiLineLabel);
                    TrickOverViewPreview.codeTextStyle.normal.textColor  = SyntaxHighlighter.TextColor;
                    TrickOverViewPreview.codeTextStyle.active.textColor  = SyntaxHighlighter.TextColor;
                    TrickOverViewPreview.codeTextStyle.focused.textColor = SyntaxHighlighter.TextColor;
                    TrickOverViewPreview.codeTextStyle.wordWrap          = false;
                }
                GUIContent content = GUIHelper.TempContent(this.showRaw ? this.m_Example.GetTrickOverViewInfo().Code.TrimEnd(new char[]
                {
                    '\n',
                    '\r'
                }) : this.highlightedCode);
                Vector2 vector = TrickOverViewPreview.codeTextStyle.CalcSize(content);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(-3f);
                GUILayout.BeginVertical(new GUILayoutOption[0]);
                GUIHelper.PushEventType((Event.current.type == EventType.ScrollWheel) ? EventType.Used : Event.current.type);
                this.scrollPosition = GUILayout.BeginScrollView(this.scrollPosition, true, false, GUI.skin.horizontalScrollbar, GUIStyle.none, new GUILayoutOption[]
                {
                    GUILayout.MinHeight(vector.y + 20f)
                });
                Rect rect3 = GUILayoutUtility.GetRect(vector.x + 50f, vector.y).AddXMin(4f).AddY(2f);
                if (this.showRaw)
                {
                    EditorGUI.SelectableLabel(rect3, this.m_Example.GetTrickOverViewInfo().Code, TrickOverViewPreview.codeTextStyle);
                    GUILayout.Space(-14f);
                }
                else
                {
                    GUI.Label(rect3, content, TrickOverViewPreview.codeTextStyle);
                }
                GUILayout.EndScrollView();
                GUIHelper.PopEventType();
                GUILayout.EndVertical();
                GUILayout.Space(-3f);
                GUILayout.EndHorizontal();
                GUILayout.Space(-3f);
                SirenixEditorGUI.EndToolbarBox();
            }
            GUILayout.EndVertical();
        }
示例#11
0
 public static void ShowWindow()
 {
     Window          = GetWindow <CaomaoBuildWindow>(WindowTitle);
     Window.position = GUIHelper.GetEditorWindowRect().AlignCenter(800, 600);
 }
示例#12
0
    private static void OpenWindow()
    {
        var window = GetWindow <OdinToolkit>();

        window.position = GUIHelper.GetEditorWindowRect().AlignCenter(1000, 500);
    }
示例#13
0
 public virtual Texture GetProfileIcon()
 {
     return(GUIHelper.GetAssetThumbnail(null, typeof(ScriptableObject), false));
 }
示例#14
0
 private void Start()
 {
     mainCamera = GUIHelper.GetMainCamera();
 }
 private void RepaintConstantly()
 {
     GUIHelper.RequestRepaint();
 }
示例#16
0
        internal static void PopulateGenericMenu <T>(IPropertyValueEntry <T> entry, GenericMenu genericMenu)
        {
            Color color;

            if (entry.TypeOfValue == typeof(Color))
            {
                color = (Color)(object)entry.SmartValue;
            }
            else
            {
                color = (Color32)(object)entry.SmartValue;
            }

            Color colorInClipboard;
            bool  hasColorInClipboard = ColorExtensions.TryParseString(EditorGUIUtility.systemCopyBuffer, out colorInClipboard);

            if (genericMenu.GetItemCount() > 0)
            {
                genericMenu.AddSeparator("");
            }

            genericMenu.AddItem(new GUIContent("Copy RGBA"), false, () =>
            {
                EditorGUIUtility.systemCopyBuffer = entry.SmartValue.ToString();
            });
            genericMenu.AddItem(new GUIContent("Copy HEX"), false, () =>
            {
                EditorGUIUtility.systemCopyBuffer = "#" + ColorUtility.ToHtmlStringRGBA(color);
            });
            genericMenu.AddItem(new GUIContent("Copy Color Code Declaration"), false, () =>
            {
                EditorGUIUtility.systemCopyBuffer = ColorExtensions.ToCSharpColor(color);
            });

            if (hasColorInClipboard)
            {
                genericMenu.ReplaceOrAdd("Paste", false, () =>
                {
                    entry.Property.Tree.DelayActionUntilRepaint(() =>
                    {
                        SetEntryValue(entry, colorInClipboard);
                    });

                    GUIHelper.RequestRepaint();
                });
            }
            else if (Clipboard.CanPaste(typeof(Color)) || Clipboard.CanPaste(typeof(Color32)))
            {
                genericMenu.ReplaceOrAdd("Paste", false, () =>
                {
                    entry.Property.Tree.DelayActionUntilRepaint(() =>
                    {
                        SetEntryValue(entry, Clipboard.Paste());
                    });

                    GUIHelper.RequestRepaint();
                });
            }
            else
            {
                genericMenu.AddDisabledItem(new GUIContent("Paste"));
            }
        }
示例#17
0
 public bool MiniButton(GUIContent content, MiniButtonStyle style, Layout option)
 {
     return(MiniButton(content, GUIHelper.GetStyle(style), option));
 }
示例#18
0
 public SnapshotVisualizer(Dictionary <long, List <MarketSnapshot> > database)
 {
     InitializeComponent();
     Database = database;
     GUIHelper.UpdateEventsListBox(EventsBox, Database);
 }
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyGroupLayout(InspectorProperty property, HorizontalGroupAttribute attribute, GUIContent label)
        {
            var context = property.Context.Get(this, "Context", (Context)null);

            if (context.Value == null)
            {
                context.Value = new Context();
                if (attribute.Title != null)
                {
                    context.Value.TitleHelper = new StringMemberHelper(property.ParentType, attribute.Title);
                }

                context.Value.Widths      = new float[property.Children.Count];
                context.Value.MinWidths   = new float[property.Children.Count];
                context.Value.MaxWidths   = new float[property.Children.Count];
                context.Value.LabelWidths = new float[property.Children.Count];
                context.Value.Margins     = new Vector2[property.Children.Count];
                context.Value.Paddings    = new Vector2[property.Children.Count];

                float percentageAllocated = 0;
                for (int i = 0; i < property.Children.Count; i++)
                {
                    var child = property.Children[i];
                    var attr  = child.Children.Recurse()
                                .Append(child)
                                .SelectMany(a => a.Info.GetAttributes <HorizontalGroupAttribute>())
                                .FirstOrDefault(x => x.GroupID == attribute.GroupID);

                    if (attr == null)
                    {
                        context.Value.Widths[i] = -1;
                    }
                    else
                    {
                        context.Value.Widths[i]      = attr.Width;
                        context.Value.MinWidths[i]   = attr.MinWidth;
                        context.Value.MaxWidths[i]   = attr.MaxWidth;
                        context.Value.LabelWidths[i] = attr.LabelWidth;

                        if (attr.Width > 0 && attr.Width < 1)
                        {
                            context.Value.ContainsPercentageWidth++;
                            percentageAllocated += attr.Width;

                            // If we allocate 100% there is no way to resize the window down.
                            // In those cases, we convert the attribute to adjust itself automatically and Unity will ensure that
                            // that it reaches the 100% for us.
                            if (percentageAllocated >= 0.97)
                            {
                                percentageAllocated    -= attr.Width;
                                context.Value.Widths[i] = 0;
                                attr.Width = 0;
                            }
                        }

                        if (attr.MinWidth > 0 && attr.MinWidth <= 1)
                        {
                            context.Value.ContainsPercentageWidth++;

                            percentageAllocated += attr.MinWidth;
                            // Same thing for MinWidth.
                            if (percentageAllocated >= 0.97)
                            {
                                percentageAllocated       -= attr.MinWidth;
                                context.Value.MinWidths[i] = 0;
                                attr.MinWidth = 0;
                            }
                        }

                        context.Value.Margins[i]  = new Vector2(attr.MarginLeft, attr.MarginRight);
                        context.Value.Paddings[i] = new Vector2(attr.PaddingLeft, attr.PaddingRight);
                    }
                }
            }

            if (context.Value.TitleHelper != null)
            {
                if (context.Value.TitleHelper.ErrorMessage != null)
                {
                    SirenixEditorGUI.ErrorMessageBox(context.Value.TitleHelper.ErrorMessage);
                }
                else
                {
                    SirenixEditorGUI.Title(context.Value.TitleHelper.GetString(property), null, TextAlignment.Left, false);
                }
            }

            SirenixEditorGUI.BeginIndentedHorizontal(GUILayoutOptions.ExpandWidth(false));
            {
                if (Event.current.type == EventType.Repaint)
                {
                    var newWidth = GUIHelper.GetCurrentLayoutRect().width;

                    if (context.Value.TotalWidth != newWidth)
                    {
                        GUIHelper.RequestRepaint();
                    }

                    context.Value.TotalWidth = newWidth;
                }

                for (int i = 0; i < property.Children.Count; i++)
                {
                    float   width, minWidth, maxWidth;
                    Vector2 padding, margin;

                    if (context.Value.ContainsPercentageWidth > 1 && context.Value.TotalWidth == 0)
                    {
                        width    = 20; // Start small and expand next frame. Instead of starting to big and slowly getting smaller.
                        minWidth = 0;
                        maxWidth = 0;
                        padding  = new Vector2();
                        margin   = new Vector2();
                    }
                    else
                    {
                        width    = context.Value.Widths[i];
                        minWidth = context.Value.MinWidths[i];
                        maxWidth = context.Value.MaxWidths[i];
                        margin   = context.Value.Margins[i];
                        padding  = context.Value.Paddings[i];

                        if (padding.x > 0 && padding.x <= 1)
                        {
                            padding.x = padding.x * context.Value.TotalWidth;
                        }
                        if (padding.y > 0 && padding.y <= 1)
                        {
                            padding.y = padding.y * context.Value.TotalWidth;
                        }
                        if (margin.x > 0 && margin.x <= 1)
                        {
                            margin.x = margin.x * context.Value.TotalWidth;
                        }
                        if (margin.y > 0 && margin.y <= 1)
                        {
                            margin.y = margin.y * context.Value.TotalWidth;
                        }


                        if (width <= 1)
                        {
                            width = width * context.Value.TotalWidth;
                        }

                        width -= padding.x + padding.y;

                        if (minWidth > 0)
                        {
                            if (minWidth <= 1)
                            {
                                minWidth = minWidth * context.Value.TotalWidth;
                            }
                            minWidth -= padding.x + padding.y;
                        }

                        if (maxWidth > 0)
                        {
                            if (maxWidth <= 1)
                            {
                                maxWidth = maxWidth * context.Value.TotalWidth;
                            }
                            maxWidth -= padding.x + padding.y;
                        }
                    }

                    GUILayoutOptions.GUILayoutOptionsInstance options = null;

                    if (minWidth > 0)
                    {
                        options = GUILayoutOptions.MinWidth(minWidth);
                    }
                    if (maxWidth > 0)
                    {
                        options = options == null?GUILayoutOptions.MaxWidth(maxWidth) : options.MaxWidth(maxWidth);
                    }
                    if (options == null)
                    {
                        options = GUILayoutOptions.Width(width < 0 ? 0 : width);
                    }

                    var prevFieldWidth = EditorGUIUtility.fieldWidth;
                    EditorGUIUtility.fieldWidth = 40;
                    GUILayout.Space(margin.x + padding.x);
                    GUILayout.BeginVertical(options);
                    GUILayout.Space(0);
                    if (attribute.LabelWidth > 0)
                    {
                        GUIHelper.PushLabelWidth(attribute.LabelWidth);
                    }
                    InspectorUtilities.DrawProperty(property.Children[i], property.Children[i].Label);
                    if (attribute.LabelWidth > 0)
                    {
                        GUIHelper.PopLabelWidth();
                    }
                    GUILayout.Space(0);
                    GUILayout.EndVertical();
                    EditorGUIUtility.fieldWidth = prevFieldWidth;
                    GUILayout.Space(margin.y + padding.y);
                }
            }
            SirenixEditorGUI.EndIndentedHorizontal();
        }
示例#20
0
 private static void Open()
 {
     _window = GetWindow <FaceEditorWindow>();
     _window.titleContent = new GUIContent("相貌编辑器");
     _window.position     = GUIHelper.GetEditorWindowRect().AlignCenter(800, 500);
 }
示例#21
0
        /// <summary>
        /// Prepares a property tree for drawing, and handles management of undo, as well as marking scenes and drawn assets dirty.
        /// </summary>
        /// <param name="tree">The tree to be drawn.</param>
        /// <param name="withUndo">Whether to register undo commands for the changes made to the tree. This can only be set to true if the tree has a <see cref="SerializedObject"/> to represent.</param>
        /// <exception cref="System.ArgumentNullException">tree is null</exception>
        public static void BeginDrawPropertyTree(PropertyTree tree, bool withUndo)
        {
            if (frameCounter.Update().IsNewFrame)
            {
                drawnInspectorDepthCount = 0;
            }
            drawnInspectorDepthCount++;

            if (tree == null)
            {
                throw new ArgumentNullException("tree");
            }

            for (int i = 0; i < tree.WeakTargets.Count; i++)
            {
                if (tree.WeakTargets[i] == null)
                {
                    GUILayout.Label("An inspected object has been destroyed; please refresh the inspector.");
                    return;
                }
            }

            if (tree.UnitySerializedObject != null)
            {
                tree.UnitySerializedObject.Update();
            }

            tree.UpdateTree();

            tree.WillUndo = false;

            if (withUndo)
            {
                if (tree.TargetType.ImplementsOrInherits(typeof(UnityEngine.Object)) == false)
                {
                    Debug.LogError("Automatic inspector undo only works when you're inspecting a type derived from UnityEngine.Object, and you are inspecting '" + tree.TargetType.GetNiceName() + "'.");
                }
                else
                {
                    tree.WillUndo = true;
                }
            }

            if (tree.WillUndo)
            {
                for (int i = 0; i < tree.WeakTargets.Count; i++)
                {
                    Undo.RecordObject((UnityEngine.Object)tree.WeakTargets[i], "Sirenix Inspector value change");
                }
            }

            if (tree.DrawMonoScriptObjectField)
            {
                var scriptProp = tree.UnitySerializedObject.FindProperty("m_Script");

                if (scriptProp != null)
                {
                    GUIHelper.PushGUIEnabled(false);
                    EditorGUILayout.PropertyField(scriptProp);
                    GUIHelper.PopGUIEnabled();
                }
            }
        }
示例#22
0
        /// <summary>
        /// 打开窗口
        /// </summary>
        public static void Open()
        {
            var win = GetWindow <ILRuntimeEditorWin>("ILRuntime", true);

            win.position = GUIHelper.GetEditorWindowRect().AlignCenter(800, 600);
        }
示例#23
0
        /// <summary>
        /// Draws a property in the inspector using a given label.
        /// </summary>
        public static void DrawProperty(InspectorProperty property, GUIContent label)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }

            bool popGUIEnabled = false;

            try
            {
                property.PushDraw();

                if ((property.RecursiveDrawDepth + InlineEditorAttributeDrawer.CurrentInlineEditorDrawDepth) > GeneralDrawerConfig.Instance.MaxRecursiveDrawDepth)
                {
                    SirenixEditorGUI.ErrorMessageBox("The property '" + property.NiceName + "' has exceeded the maximum recursive draw depth limit of " + GeneralDrawerConfig.Instance.MaxRecursiveDrawDepth + ".");
                    return;
                }

                if (property.ValueEntry != null && !property.SupportsPrefabModifications && property.Tree.HasPrefabs && !GUIHelper.IsDrawingDictionaryKey && (property.Info.PropertyType == PropertyType.ReferenceType || property.Info.PropertyType == PropertyType.ValueType))
                {
                    if ((property.Parent == null || property.Parent.SupportsPrefabModifications) && GeneralDrawerConfig.Instance.ShowPrefabModificationsDisabledMessage)
                    {
                        SirenixEditorGUI.InfoMessageBox("The property '" + property.NiceName + "' does not support being modified on prefab instances. (You can disable this message the general drawer config.)");
                    }

                    GUIHelper.PushGUIEnabled(false);
                    popGUIEnabled = true;
                }

                OdinDrawer[] drawers = DrawerLocator.GetDrawersForProperty(property);

                GUIHelper.BeginLayoutMeasuring();
                {
                    try
                    {
                        if (drawers.Length > 0)
                        {
                            bool setIsBoldState = property.ValueEntry != null && Event.current.type == EventType.Repaint;
                            if (setIsBoldState)
                            {
                                var boldState = property.ValueEntry.ValueChangedFromPrefab;

                                if (GUIHelper.IsDrawingDictionaryKey)
                                {
                                    // Always propagate changed state down through dictionary keys
                                    boldState |= GUIHelper.IsBoldLabel;
                                }

                                GUIHelper.PushIsBoldLabel(boldState);
                            }
                            drawers[0].DrawProperty(property, label);
                            if (setIsBoldState)
                            {
                                GUIHelper.PopIsBoldLabel();
                            }
                        }
                        else
                        {
                            if (property.Info.PropertyType == PropertyType.Method)
                            {
                                EditorGUILayout.LabelField(property.NiceName, "No drawers could be found for the method property '" + property.Name + "' with signature '" + property.Info.MemberInfo.GetNiceName() + "'.");
                            }
                            else if (property.Info.PropertyType == PropertyType.Group)
                            {
                                var attr = property.Info.GetAttribute <PropertyGroupAttribute>();

                                if (attr != null)
                                {
                                    EditorGUILayout.LabelField(property.NiceName, "No drawers could be found for the property group '" + property.Name + "' with property group attribute type '" + attr.GetType().GetNiceName() + "'.");
                                }
                                else
                                {
                                    EditorGUILayout.LabelField(property.NiceName, "No drawers could be found for the property group '" + property.Name + "'.");
                                }
                            }
                            //else if (property.Info.GetAttribute<HideInInspector>() == null)
                            //{
                            //    EditorGUILayout.LabelField(property.NiceName, "No drawers could be found for the value property '" + property.Name + "' of type '" + property.ValueEntry.TypeOfValue.GetNiceName() + "'.");
                            //}
                        }
                    }
                    catch (Exception ex)
                    {
                        if (ex is ExitGUIException || ex.InnerException is ExitGUIException)
                        {
                            throw ex;
                        }
                        else
                        {
                            var msg =
                                "This error occurred while being drawn by Odin. \n" +
                                "Odin Property Path: " + property.Path + "\n" +
                                "Odin Drawer Chain: " + string.Join(", ", drawers.Select(n => n.GetType().GetNiceName()).ToArray()) + ".";

                            Debug.LogException(new OdinPropertyException(msg, ex));
                        }
                    }
                }
                if (Event.current.type != EventType.Layout)
                {
                    property.LastDrawnValueRect = GUIHelper.EndLayoutMeasuring();
                }
            }
            finally
            {
                property.PopDraw();

                if (popGUIEnabled)
                {
                    GUIHelper.PopGUIEnabled();
                }
            }
        }
示例#24
0
        /// <summary>
        /// 打开窗口
        /// </summary>
        public static void Open()
        {
            var win = GetWindow <IOSProjectInitEditorWin>("iOS 项目配置");

            win.position = GUIHelper.GetEditorWindowRect().AlignCenter(800, 600);
        }
示例#25
0
 public override string ToolbarSearch(string value, Layout option)
 {
     return(GUIHelper.ToolbarSearchField_GL(null, new object[] { value, option.ToGLOptions() }) as string);
 }
示例#26
0
 public static Transform GetUIRootTransform()
 {
     return(GUIHelper.GetUIRootObj().transform);
 }
示例#27
0
 /// <summary>
 /// 返回UI画布的根节点
 /// </summary>
 /// <returns></returns>
 public static GameObject GetUIRootObj()
 {
     return(GUIHelper.GetUIRootObj());
 }
示例#28
0
 /// <summary>
 /// 获取主相机节点
 /// </summary>
 /// <returns></returns>
 public static GameObject GetMainGameObj()
 {
     return(GUIHelper.GetMainGameObj());
 }
示例#29
0
 /// <summary>
 /// 返回UI画布
 /// </summary>
 /// <returns></returns>
 public static Canvas GetUIRoot()
 {
     return(GUIHelper.GetUIRoot());
 }
示例#30
0
 public static Camera GetEffectCamera()
 {
     return(GUIHelper.GetEffectCamera());
 }
        public IEnumerator DelayShowCanvas()
        {
            yield return(new WaitForSeconds(1f));

            GUIHelper.NextGUI(null, GUIHelper.GetCurrentGUI());
        }
示例#32
0
        public override void OnInspectorGUI()
        {
            _target = (UMAHackable)target;
            _target.Init();
            bool changed = false;

            _applyStandardUMABoneFiltersProp = serializedObject.FindProperty("_applyStandardUMABoneFilters");

            //Add the standard Hackable fields

            _target.alternatePrefab = EditorGUILayout.ObjectField(new GUIContent("Alternate prefab", "An alternative prefab to use if the character becomes a ragdoll as a result of hacking!"), (Object)_target.alternatePrefab, typeof(GameObject), false);

            _target.infillMaterial = (Material)EditorGUILayout.ObjectField(new GUIContent("Infill Material", "A material to use to fill the gaps in a mesh, might be a bloody stump kind of thing"), (Object)_target.infillMaterial, typeof(Material), false);

            if (_target.infillMaterial != null)
            {
                _target.infillMode = (InfillMode)EditorGUILayout.EnumPopup(new GUIContent("Infill Mode", "'Sloppy is more relaiable and less processor intensive, but your 'infill' texture may be distorted. 'Meticulous' will attempt to fill the top of the sliced mesh perfectly but might fail to do so"), _target.infillMode);
            }

            //TODO Add 'components to remove on Hack' if necessary
            //TODO Add 'components to add on Hack' if required

            EditorGUILayout.Space();

            //lets use our indented block for this
            GUIHelper.BeginVerticalPadded(3, new Color(0.75f, 0.875f, 1f, 0.3f));

            EditorGUILayout.HelpBox("Select which bones are severable. Use the 'Standard UMA Filters' button to remove 'Adjust' bones etc:", MessageType.Info);
            EditorGUI.indentLevel++;

            _availableTransforms = new List <UMATransform>(_target.umaSeverables);
            _selectedTransforms  = new List <UMATransform>(_target.selectedUmaSeverables);

            GUILayout.BeginHorizontal();

            EditorGUI.BeginChangeCheck();
            _applyStandardUMABoneFiltersProp.boolValue = GUILayout.Toggle(_applyStandardUMABoneFiltersProp.boolValue, new GUIContent("Standard UMA Filters", "Filter out standard UMA Bones like 'Global', 'Position' and the 'Adjust' bones from this list"), "Button");
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                _target.UpdateSeverablesFromActiveRecipe((_applyStandardUMABoneFiltersProp.boolValue ? _standardUMABoneFilters : null));
                changed = true;
            }
            if (GUILayout.Button("Select All"))
            {
                for (int i = 0; i < _availableTransforms.Count; i++)
                {
                    if (!IsUMATransformInList(_availableTransforms[i], _selectedTransforms))
                    {
                        _selectedTransforms.Add(_availableTransforms[i]);
                    }
                }
                changed = true;
            }
            if (GUILayout.Button("Deselect All"))
            {
                _selectedTransforms.Clear();
                changed = true;
            }
            GUILayout.EndHorizontal();

            //Output the list of avalable bones (filtered)
            for (int i = 0; i < _availableTransforms.Count; i++)
            {
                var wasSelected = IsUMATransformInList(_availableTransforms[i], _selectedTransforms);
                var isSelected  = EditorGUILayout.Toggle(_availableTransforms[i].name, wasSelected);
                //UMATransform doesn't have a System.IEquatable<UMATransform> so we have to use UMATransformComparer
                if (isSelected != wasSelected)
                {
                    if (isSelected)
                    {
                        _selectedTransforms.Add(_availableTransforms[i]);
                    }
                    else if (!isSelected && wasSelected)
                    {
                        for (int si = 0; si < _selectedTransforms.Count; si++)
                        {
                            if (_selectedTransforms[si].hash == _availableTransforms[i].hash)
                            {
                                _selectedTransforms.RemoveAt(si);
                                break;
                            }
                        }
                    }
                    changed = true;
                }
            }

            if (changed)
            {
                _target.ClearSelectedSeverables();

                for (int i = 0; i < _selectedTransforms.Count; i++)
                {
                    _target.AddUMATransformToSeverables(_selectedTransforms[i]);
                }

                //do we want to try and update the associated transforms here too (i.e. if the user has used bone builder the actual severable transforms could be updated here too)
                //I think so...
                _target.ConvertUMASeverablesToSeverables();
                serializedObject.Update();
            }

            EditorGUI.indentLevel--;
            GUIHelper.EndVerticalPadded(3);

            //base.OnInspectorGUI();
        }
示例#33
0
 /// <summary>
 /// 销毁渲染出来的临时UIBlur RenderTexture
 /// </summary>
 public static void DestroyUIBlur()
 {
     GUIHelper.GetEffectCameraObj().GetComponent <ImageEffectUIBlur>().FinalTexture = null;
 }
示例#34
0
        private static void OpenWindow()
        {
            var window = GetWindow <LautaroWindow> ();

            window.position = GUIHelper.GetEditorWindowRect().AlignCenter(800, 600);
        }