コード例 #1
0
    void OnGUIAvatar(VRCSDK2.VRC_AvatarDescriptor avatar)
    {
        if (!displayActive.ContainsKey(avatar))
        {
            displayActive.Add(avatar, true);
        }
        displayActive[avatar] = EditorGUILayout.InspectorTitlebar(displayActive[avatar], avatar.gameObject);

        if (displayActive[avatar])
        {
            GUI.enabled = (GUIErrors.Count == 0 && checkedForIssues) || (APIUser.CurrentUser.developerType.HasValue && APIUser.CurrentUser.developerType.Value == APIUser.DeveloperType.Internal);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Build & Publish"))
            {
                VRC_SdkBuilder.shouldBuildUnityPackage = VRC.AccountEditorWindow.FutureProofPublishEnabled;
                VRC_SdkBuilder.ExportAndUploadAvatarBlueprint(avatar.gameObject);
            }
            EditorGUILayout.EndHorizontal();
            GUI.enabled = true;

            OnGUIShowIssues(avatar);
        }
    }
コード例 #2
0
    void OnGUIAvatar(VRCSDK2.VRC_AvatarDescriptor avatar)
    {
        EditorGUILayout.InspectorTitlebar(avatar.gameObject.activeInHierarchy, avatar.gameObject);

        GUI.enabled = (GUIErrors.Count == 0 && checkedForIssues) || APIUser.CurrentUser.developerType == APIUser.DeveloperType.Internal;
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Build & Publish"))
        {
            if (APIUser.CurrentUser.canPublishAvatars)
            {
                VRC_SdkBuilder.shouldBuildUnityPackage = VRC.AccountEditorWindow.FutureProofPublishEnabled;
                VRC_SdkBuilder.ExportAndUploadAvatarBlueprint(avatar.gameObject);
            }
            else
            {
                ShowContentPublishPermissionsDialog();
            }
        }
        EditorGUILayout.EndHorizontal();
        GUI.enabled = true;

        OnGUIShowIssues(avatar);
    }
コード例 #3
0
    public void OnGUI()
    {
        GameObject target = Selection.activeGameObject;

        if (target == null)
        {
            return;
        }

        EditorGUILayout.InspectorTitlebar(true, target);

        m_scrollPos = EditorGUILayout.BeginScrollView(m_scrollPos);

        Component[] components = target.GetComponents <Component>();
        foreach (Component component in components)
        {
            DebugInspectorLayout.ObjectField(component.GetType().Name, component, AssetPreview.GetMiniThumbnail(component));

            EditorGUILayout.Separator();
        }

        EditorGUILayout.EndScrollView();
    }
コード例 #4
0
    void DrawSettingsEditor(Object settings, System.Action onSettingsUpdated, ref bool hide, ref Editor editor)
    {
        if (settings != null)
        {
            hide = EditorGUILayout.InspectorTitlebar(hide, settings); // Makes the settings sections more visible in the editor.
            using (var check = new EditorGUI.ChangeCheckScope())
            {
                if (hide == true)
                {
                    CreateCachedEditor(settings, null, ref editor);
                    editor.OnInspectorGUI();

                    if (check.changed)
                    {
                        if (onSettingsUpdated != null)
                        {
                            onSettingsUpdated();
                        }
                    }
                }
            }
        }
    }
コード例 #5
0
    private void DrawSettingsEditor(Object settings, System.Action onSettingsUpdated, ref bool foldout, ref Editor editor)
    {
        if (settings == null)
        {
            return;
        }

        foldout = EditorGUILayout.InspectorTitlebar(foldout, settings);
        using (var check = new EditorGUI.ChangeCheckScope())
        {
            if (!foldout)
            {
                return;
            }
            CreateCachedEditor(settings, null, ref editor);
            editor.OnInspectorGUI();

            if (check.changed)
            {
                onSettingsUpdated?.Invoke();
            }
        }
    }
コード例 #6
0
    void DrawSettingsEditor(Object settings, System.Action onSettingsUpdated, ref bool foldout, ref Editor editor) //Passing in a System.Action allows method to be called. ref keyword allows the reference to the specific value from planet to be parsed and updated
    {
        if (settings != null)
        {
            foldout = EditorGUILayout.InspectorTitlebar(foldout, settings); //Adds a title to the GUI element in the inspector. Everything to do with foldout allows the foldout arrow on the top-left of the gui to work
            using (var check = new EditorGUI.ChangeCheckScope())
            {
                if (foldout)
                {
                    CreateCachedEditor(settings, null, ref editor); //Only creates a new editor when it has to
                    editor.OnInspectorGUI();

                    if (check.changed)
                    {
                        if (onSettingsUpdated != null)
                        {
                            onSettingsUpdated();
                        }
                    }
                }
            }
        }
    }
コード例 #7
0
    void DrawSettingsEditor(Object settings, System.Action onSettingsUpdated, ref bool foldout, ref Editor editor)
    {
        if (settings != null)
        {
            foldout = EditorGUILayout.InspectorTitlebar(foldout, settings);
            using (var check = new EditorGUI.ChangeCheckScope())
            {
                if (foldout == true)
                {
                    CreateCachedEditor(settings, null, ref editor);
                    editor.OnInspectorGUI();

                    if (check.changed)
                    {
                        if (onSettingsUpdated != null)
                        {
                            onSettingsUpdated();
                        }
                    }
                }
            }
        }
    }
コード例 #8
0
        public void OnGUI()
        {
            this.Update();

            var color = GUI.color;

            color.a   = this.progress;
            GUI.color = color;

            if (this.editors != null && this.editors.Count > 0)
            {
                this.scrollPosition = EditorGUILayout.BeginScrollView(this.scrollPosition, false, false);

                for (int i = 0; i < this.editors.Count; ++i)
                {
                    var editor = this.editors[i];
                    this.editorsFoldOut[i] = EditorGUILayout.InspectorTitlebar(this.editorsFoldOut[i], editor.target);
                    if (this.editorsFoldOut[i] == true && editor != null && editor.target != null)
                    {
                        editor.OnInspectorGUI();
                    }
                }

                EditorGUILayout.EndScrollView();
            }
            else
            {
                var style = new GUIStyle(EditorStyles.whiteLargeLabel);
                style.alignment        = TextAnchor.MiddleCenter;
                style.normal.textColor = Color.gray;

                var rect = this.position;
                rect.x = 0f;
                rect.y = 0f;
                GUI.Label(rect, "No Object Selected", style);
            }
        }
コード例 #9
0
        public static bool TextUnityObject <T>(string str,        //文本 Object(Null ->noShowAction )showAction
                                               ref T sc, bool isShow, Action showAction,
                                               Action noShowAction, int jianGe)
            where T : UnityEngine.Object
        {
            T    tmpT = sc;
            bool tmp  = isShow;

            try
            {
                Heng(() =>
                {
                    Text(str, jianGe);
                    tmpT = (T)EditorGUILayout.ObjectField(tmpT, typeof(T), true);
                });
                if (null != tmpT)
                {
                    AddSpace(5);
                    tmp = EditorGUILayout.InspectorTitlebar(tmp, tmpT, true);
                    if (null != showAction && tmp)
                    {
                        showAction();
                    }
                    if (null != noShowAction && !tmp)
                    {
                        noShowAction();
                    }
                }
            }
            catch
            {
                // ignored
            }
            sc = tmpT;
            return(tmp);
        }
コード例 #10
0
    void DrawSettingsEditor(Object settings, System.Action onSettingsUpdated, ref bool foldout, ref Editor editor)
    {
        if (settings != null)
        {
            foldout = EditorGUILayout.InspectorTitlebar(foldout, settings);

            using (var updateCheck = new EditorGUI.ChangeCheckScope())
            {
                // true means that it is always open. Basically looks nicer in inspector
                // values aren't serialized here, so we can't store settings.

                if (foldout)
                {
                    CreateCachedEditor(settings, null, ref editor);
                    editor.OnInspectorGUI();

                    if (updateCheck.changed)
                    {
                        onSettingsUpdated?.Invoke();
                    }
                }
            }
        }
    }
コード例 #11
0
    private void DrawSettingsEditor(Object settings, System.Action onSettingsUpdated, ref bool foldOut, ref Editor editor)//pass foldOut by reference to change the original in here, editor passed by reference to not have to remake it every time
    {
        if (settings != null)
        {
            foldOut = EditorGUILayout.InspectorTitlebar(foldOut, settings);//the true means that it is always folded out, non collapsable apart from the planet settings
            using (var check = new EditorGUI.ChangeCheckScope())
            {
                if (foldOut)
                {
                    CreateCachedEditor(settings, null, ref editor);//null for default editor type
                    //Editor editor = CreateEditor(settings);
                    editor.OnInspectorGUI();

                    if (check.changed)
                    {
                        if (onSettingsUpdated != null)
                        {
                            onSettingsUpdated();
                        }
                    }
                }
            }
        }
    }
コード例 #12
0
ファイル: PlanetEditor.cs プロジェクト: MalCaor/BTS-test
    void DrawSettingsEditor(Object settings, System.Action onSettingsUpdate, ref bool foldout, ref Editor editor)
    {
        if (settings != null)
        {
            // Inspetortitbar is a separator, to separate the settings from the rest of the inspector, foldout is the var if show or not
            foldout = EditorGUILayout.InspectorTitlebar(foldout, settings);
            using (var check = new EditorGUI.ChangeCheckScope())
            {
                if (foldout)
                {
                    CreateCachedEditor(settings, null, ref editor);
                    editor.OnInspectorGUI();

                    if (check.changed)
                    {
                        if (onSettingsUpdate != null)
                        {
                            onSettingsUpdate();
                        }
                    }
                }
            }
        }
    }
コード例 #13
0
    /// <summary>
    /// コンポーネントリストを表示
    /// </summary>
    void drawEditors()
    {
        int count = 0;
        var isHideSomeComponent = false;         // 一つ以上のコンポーネントが非表示

        foreach (var editor in EditorTracker.activeEditors)
        {
            if (editor == null ||
                editor.target == null ||
                editor.target.GetType() == typeof(AssetImporter) ||
                editor.target is GameObject)
            {
                continue;
            }

            if (Event.current.type == EventType.Repaint)
            {
                typeof(Editor).GetProperty("isInspectorDirty", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(editor, false);
            }

            var foldout         = activeEditorTable[editor].isFoldout;
            var isShowComponent = activeEditorTable[editor].isShowCompontnt;
            var showProperties  = activeEditorTable[editor].showProperties;

            if (!!isShowComponent)
            {
                if (!hasLargeHeader(editor))
                {
                    activeEditorTable[editor].isFoldout = EditorGUILayout.InspectorTitlebar(activeEditorTable[editor].isFoldout, editor);
                }
                else
                {
                    editor.DrawHeader();
                }

                bool isEnabled = (bool)editor.GetType().GetMethod("IsEnabled", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(editor, null);

                using (var diableScope = new EditorGUI.DisabledGroupScope(!isEnabled)) {
                    EditorGUIUtility.labelWidth = Screen.width * 0.4f;                     // 0.4は調整値
                    if (!!activeEditorTable[editor].isFoldout)
                    {
                        if (string.IsNullOrEmpty(searchText))
                        {
                            drawFullInspector(editor);
                        }
                        else
                        {
                            var componentSerializedObject = editor.serializedObject;
                            componentSerializedObject.Update();
                            drawProperties(showProperties);
                            componentSerializedObject.ApplyModifiedProperties();
                        }
                    }
                }

                ++count;
            }
            else
            {
                isHideSomeComponent = true;
            }
        }

        if (!!isHideSomeComponent)
        {
            drawSeparator();
            EditorGUILayout.HelpBox("Several components are hidden.", MessageType.Info);
        }
    }
コード例 #14
0
    void OnGUI()
    {
        EditorGUILayout.BeginVertical(GUI.skin.box);//縦
        {
            if (GUILayout.Button("再生/ポーズ", GUILayout.Width(200), GUILayout.Height(20)))
            {
                Debug.Log("再生ボタン");

                EditorApplication.ExecuteMenuItem("Edit/Play");                //ゲーム再生
            }

            timeSlider = EditorGUILayout.IntSlider("TIME(FRAME):", timeSlider, 0, maxFrame);

            //まず音楽再生するところ。
            EditorGUILayout.BeginHorizontal(GUI.skin.box);            //横
            {
                soundObject = EditorGUILayout.ObjectField("Audio", soundObject, typeof(GameObject), true) as GameObject;
                if (soundObject != null && soundObject.GetComponent <AudioSource>() != null)
                {
                    audioSource = soundObject.GetComponent <AudioSource>();
                    inspectorTitlebarForSound = EditorGUILayout.InspectorTitlebar(inspectorTitlebarForSound, soundObject);
                    if (inspectorTitlebarForSound)
                    {
                        EditorGUILayout.LabelField("オーディオクリップの長さは" + audioSource.clip.length.ToString() + "秒です。");
                        maxFrame = (int)(audioSource.clip.length * 30.0f);
                    }
                }
                else
                {
                    EditorGUILayout.LabelField("オーディオソースコンポーネントを所持したオブジェクトを入れてください。");
                }
            } EditorGUILayout.EndHorizontal();

            //その他のオブジェクト?
            objectsScrollPos = EditorGUILayout.BeginScrollView(objectsScrollPos, GUI.skin.box);
            {
                for (int i = 0; i < maxObjectNum; i++)
                {
                    EditorGUILayout.BeginVertical(GUI.skin.box);                    //縦
                    {
                        gameObjects[i] = EditorGUILayout.ObjectField("GAME OBJECT " + i.ToString(), gameObjects[i], typeof(GameObject), true) as GameObject;
                        if (gameObjects[i] != null)
                        {
                            inspectorTitlebars[i] = EditorGUILayout.InspectorTitlebar(inspectorTitlebars[i], gameObjects[i]);
                            if (inspectorTitlebars[i])
                            {
                                //じゃあとりあえず、自動でオブジェクトの種類を振り分け、その他だったら強制的にデフォルトのCSを追加するって方針でいきます。
                                if (gameObjects[i].GetComponent <Text>())
                                {
                                    TextObjectButton(i);
                                }
                                else
                                {
                                    EditorGUILayout.LabelField("The object type could not be recognized. It is classified into OTHER.");
                                }
                            }
                        }
                        EditorGUILayout.EndVertical();
                    }
                }
            }
            EditorGUILayout.EndScrollView();
        }
        EditorGUILayout.EndVertical();
    }
コード例 #15
0
        void DrawDingObject()
        {
            if (!mDingObject || !mDing)
            {
                mDingObject = Selection.activeGameObject;
            }
            if (!mDingObject)
            {
                EditorGUILayout.BeginVertical("flow overlay box", GUILayout.Width(350));
                GUILayout.Label("<size=25><b>NOTHINE SELECTED.</b></size>");
                EditorGUILayout.EndVertical();
                return;
            }
            EditorGUILayout.BeginVertical("flow overlay box", GUILayout.Width(350));
            string t = mDingObject.name;
            int    s = QuickGUI.TitleBar(t, 15,
                                         new string[] { mDing ? "<25>true:\u2764" : "<25>\u2764", mDingObject.activeSelf ? "<25>true:\u2714" : "<25>\u2714" });

            if (s == 1)
            {
                mDing = !mDing;
                if (!mDing && Selection.activeGameObject)
                {
                    mDingObject = Selection.activeGameObject;
                }
            }
            else if (s == 2)
            {
                mDingObject.gameObject.SetActive(!mDingObject.activeSelf);
            }
            if (s >= 0)
            {
                EditorGUIUtility.PingObject(mDingObject);
            }
            dingScroll = EditorGUILayout.BeginScrollView(dingScroll);
            Component[] cps = mDingObject.GetComponents <Component>();

            for (int i = 0; i < cps.Length; i++)
            {
                if (!cps[i] || cps[i] is Transform)
                {
                    continue;
                }
                //System.Type ctp = cps[i].GetType();
                int  id = cps[i].GetInstanceID();
                bool v  = popDingCmps.Contains(id);
                bool v2 = EditorGUILayout.InspectorTitlebar(v, cps[i]);
                if (v2 ^ v)
                {
                    if (!v2)
                    {
                        popDingCmps.Remove(id);
                        popDingEditors.Remove(id);
                    }
                    else
                    {
                        popDingCmps.Add(id);
                    }
                }
                if (v2)
                {
                    UnityEditor.Editor edi;// sr.GetValue<Editor>(cmps[i].GetType().Name);
                    if (!popDingEditors.TryGetValue(id, out edi) || !edi)
                    {
                        edi = UnityEditor.Editor.CreateEditor(cps[i]);
                        popDingEditors[id] = edi;
                    }
                    if (edi)
                    {
                        edi.OnInspectorGUI();
                    }
                }
            }
            GUILayout.Space(10);
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();
        }
コード例 #16
0
        // State GUI
        private void DrawState(StateInfo state)
        {
            if (state == null)
            {
                return;
            }

            stateAsset = EditorUtil.GetAssetFromName(state.name);

            if (stateAsset == null)
            {
                stateAsset = EditorUtil.GetAssetFromName("State");
            }

            EditorGUILayout.Space();

            GUIStyle skin = new GUIStyle(GUI.skin.window)
            {
                padding = new RectOffset(2, 0, 0, 0),
                margin  = new RectOffset(0, 0, 0, 0),
            };

            //Draw all catergories in order for hiearchial type display
            if (stateAsset != null)
            {
                EditorGUILayout.InspectorTitlebar(true, stateAsset, false);
            }

            List <string> names = new List <string> ();

            //Toggle for convenience
            EditorGUI.indentLevel++;
            {
                for (int i = 0; i < state.fields.Count; i++)
                {
                    StateFieldInfo field = state.fields[i];
                    string         name  = field.info.DeclaringType.Name;

                    // Draw based on what the declaring type is
                    if (!names.Contains(name))
                    {
                        bool isScriptName = i == 0;

                        if (!isScriptName)
                        {
                            EditorGUILayout.Space();
                        }

                        if (isScriptName)
                        {
                            EditorGUILayout.BeginHorizontal();
                            {
                                EditorGUILayout.LabelField(name, EditorStyles.boldLabel);
                                EditorGUILayout.ObjectField(stateAsset, typeof(MonoScript), false);
                            }
                            EditorGUILayout.EndHorizontal();
                        }
                        else
                        {
                            EditorGUILayout.LabelField(name, EditorStyles.boldLabel);
                        }

                        names.Add(name);
                    }

                    DrawField(state.fields[i]);
                }

                EditorGUILayout.Space();
            }
            EditorGUI.indentLevel--;

            EditorUtility.SetDirty(Target);
        }
コード例 #17
0
        void OnGUIAvatar(CVRAvatar avatar)
        {
            GameObject avatarObject = avatar.gameObject;

            GUI.enabled = true;
            EditorGUILayout.InspectorTitlebar(avatarObject.activeInHierarchy, avatarObject);
            int errors = 0;
            int overallPolygonsCount       = 0;
            int overallSkinnedMeshRenderer = 0;
            int overallUniqueMaterials     = 0;
            int overallMissingScripts      = 0;

            foreach (MeshFilter filter in avatar.gameObject.GetComponentsInChildren <MeshFilter>())
            {
                if (filter.sharedMesh != null)
                {
                    overallPolygonsCount = overallPolygonsCount + filter.sharedMesh.triangles.Length / 3;
                }
            }
            foreach (SkinnedMeshRenderer renderer in avatar.gameObject.GetComponentsInChildren <SkinnedMeshRenderer>())
            {
                overallSkinnedMeshRenderer++;
                if (renderer.sharedMaterials != null)
                {
                    overallUniqueMaterials = overallUniqueMaterials + renderer.sharedMaterials.Length;
                }
            }
            overallMissingScripts = CCK_Tools.CleanMissingScripts(CCK_Tools.SearchType.Selection, false, avatarObject);
            if (overallMissingScripts > 0)
            {
                errors++;
            }

            //Errors
            if (overallMissingScripts > 0)
            {
                EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_ERROR_AVATAR_MISSING_SCRIPTS"), MessageType.Error);
            }
            var animator = avatar.GetComponent <Animator>();

            if (animator == null)
            {
                errors++;
                EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_ERROR_ANIMATOR"), MessageType.Error);
            }
            if (animator != null && animator.avatar == null)
            {
                //errors++;
                EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_WARNING_GENERIC"), MessageType.Warning);
            }

            //Warnings
            if (overallPolygonsCount > 100000)
            {
                EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_WARNING_POLYGONS").Replace("{X}", overallPolygonsCount.ToString()), MessageType.Warning);
            }
            if (overallSkinnedMeshRenderer > 10)
            {
                EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_WARNING_SKINNED_MESH_RENDERERS").Replace("{X}", overallSkinnedMeshRenderer.ToString()), MessageType.Warning);
            }
            if (overallUniqueMaterials > 20)
            {
                EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_WARNING_MATERIALS").Replace("{X}", overallUniqueMaterials.ToString()), MessageType.Warning);
            }
            if (avatar.viewPosition == Vector3.zero)
            {
                EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_WARNING_VIEWPOINT"), MessageType.Warning);
            }
            if (animator != null && animator.avatar != null && !animator.avatar.isHuman)
            {
                EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_WARNING_NON_HUMANOID"), MessageType.Warning);
            }

            var avatarMeshes = getAllAssetMeshesInAvatar(avatarObject);

            if (CheckForLegacyBlendShapeNormals(avatarMeshes))
            {
                EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_WARNING_LEGACY_BLENDSHAPES"), MessageType.Warning);
                if (GUILayout.Button(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_FIX_IMPORT_SETTINGS")))
                {
                    FixLegacyBlendShapeNormals(avatarMeshes);
                }
            }

            //Info
            if (overallPolygonsCount >= 50000 && overallPolygonsCount <= 100000)
            {
                EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_INFO_POLYGONS").Replace("{X}", overallPolygonsCount.ToString()), MessageType.Info);
            }
            if (overallSkinnedMeshRenderer >= 5 && overallSkinnedMeshRenderer <= 10)
            {
                EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_INFO_SKINNED_MESH_RENDERERS").Replace("{X}", overallSkinnedMeshRenderer.ToString()), MessageType.Info);
            }
            if (overallUniqueMaterials >= 10 && overallUniqueMaterials <= 20)
            {
                EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_INFO_MATERIALS").Replace("{X}", overallUniqueMaterials.ToString()), MessageType.Info);
            }
            if (avatar.viewPosition.y <= 0.5f)
            {
                EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_INFO_SMALL"), MessageType.Info);
            }
            if (avatar.viewPosition.y > 3f)
            {
                EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_INFO_HUGE"), MessageType.Info);
            }

            if (errors <= 0)
            {
                if (GUILayout.Button(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_UPLOAD_BUTTON")))
                {
                    CCK_BuildUtility.BuildAndUploadAvatar(avatarObject);
                }
            }
            if (overallMissingScripts > 0)
            {
                if (GUILayout.Button(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_UTIL_REMOVE_MISSING_SCRIPTS_BUTTON")))
                {
                    CCK_Tools.CleanMissingScripts(CCK_Tools.SearchType.Selection, true, avatarObject);
                }
            }
        }
コード例 #18
0
    void OnGUISceneCheck(VRCSDK2.VRC_SceneDescriptor scene)
    {
        CheckUploadChanges(scene);

        EditorGUILayout.InspectorTitlebar(true, scene.gameObject);

        if (VRC.Core.APIUser.CurrentUser != null && VRC.Core.APIUser.CurrentUser.hasScriptingAccess && !CustomDLLMaker.DoesScriptDirExist())
        {
            CustomDLLMaker.CreateDirectories();
        }

        Vector3 g = Physics.gravity;

        if (g.x != 0.0f || g.z != 0.0f)
        {
            OnGUIWarning(scene, "Gravity vector is not straight down. Though we support different gravity, player orientation is always 'upwards' so things don't always behave as you intend.");
        }
        if (g.y > 0)
        {
            OnGUIWarning(scene, "Gravity vector is not straight down, inverted or zero gravity will make walking extremely difficult.");
        }
        if (g.y == 0)
        {
            OnGUIWarning(scene, "Zero gravity will make walking extremely difficult, though we support different gravity, player orientation is always 'upwards' so this may not have the effect you're looking for.");
        }

        scene.useAssignedLayers = true;
        if (scene.useAssignedLayers)
        {
            if (!UpdateLayers.AreLayersSetup())
            {
                OnGUIWarning(scene, "Layers are not setup properly. Please press the button above.");
            }

            if (UpdateLayers.AreLayersSetup() && !UpdateLayers.IsCollisionLayerMatrixSetup())
            {
                OnGUIWarning(scene, "Physics Collision Layer Matrix is not setup correctly. Please press the button above.");
            }
        }

        // warn those without scripting access if they choose to script locally
        if (VRC.Core.APIUser.CurrentUser != null && !VRC.Core.APIUser.CurrentUser.hasScriptingAccess && CustomDLLMaker.DoesScriptDirExist())
        {
            OnGUIWarning(scene, "Your account does not have permissions to upload custom scripts. You can test locally but need to contact VRChat to publish your world with scripts.");
        }

        foreach (VRCSDK2.VRC_DataStorage ds in GameObject.FindObjectsOfType <VRCSDK2.VRC_DataStorage>())
        {
            VRCSDK2.VRC_ObjectSync os = ds.GetComponent <VRCSDK2.VRC_ObjectSync>();
            if (os != null && os.SynchronizePhysics)
            {
                OnGUIWarning(scene, ds.name + " has a VRC_DataStorage and VRC_ObjectSync, with SynchronizePhysics enabled.");
            }
        }

        // auto create VRCScript dir for those with access
        if (VRC.Core.APIUser.CurrentUser != null && VRC.Core.APIUser.CurrentUser.hasScriptingAccess && !CustomDLLMaker.DoesScriptDirExist())
        {
            CustomDLLMaker.CreateDirectories();
        }
    }
コード例 #19
0
 public override bool InspectorTitlebar(bool foldout, UnityObject target)
 {
     return(EditorGUILayout.InspectorTitlebar(foldout, target));
 }
コード例 #20
0
 public static bool Title(bool isExpanded, Editor editor)
 {
     return(EditorGUILayout.InspectorTitlebar(isExpanded, editor));
 }
コード例 #21
0
    void OnGUI()
    {
        if (window == null)
        {
            window = GetWindow(typeof(SceneFinder)); PreOpenScenes();
        }

        GUILayout.BeginHorizontal(GUI.skin.FindStyle("Toolbar"));
        GUI.SetNextControlName("SearchField");
        objectLookup = GUILayout.TextField(objectLookup, GUI.skin.FindStyle("ToolbarSeachTextField"), GUILayout.Width(window.position.width - (string.IsNullOrEmpty(objectLookup) ? 21f : 37f)));

        //search clear button
        if (!string.IsNullOrEmpty(objectLookup))
        {
            if (GUILayout.Button("", GUI.skin.FindStyle("ToolbarSeachCancelButton")))
            {
                Unfocus();
            }
        }

        GUIStyle style = new GUIStyle();

        if (GUILayout.Button("", EditorStyles.toolbarDropDown, GUILayout.Width(15f)))
        {
            // create custom dropdown menu on button click
            GenericMenu menu = new GenericMenu();
            menu.AddItem(new GUIContent("Objects And Components"), filter == SceneSearchFilter.ObjectsAndComponents, OnSearchFilterChanged, SceneSearchFilter.ObjectsAndComponents);
            menu.AddItem(new GUIContent("Objects Only"), filter == SceneSearchFilter.ObjectsOnly, OnSearchFilterChanged, SceneSearchFilter.ObjectsOnly);
            menu.AddItem(new GUIContent("Components Only"), filter == SceneSearchFilter.ComponentsOnly, OnSearchFilterChanged, SceneSearchFilter.ComponentsOnly);
            menu.AddItem(new GUIContent("By Tag Name"), filter == SceneSearchFilter.ByTag, OnSearchFilterChanged, SceneSearchFilter.ByTag);
            menu.AddItem(new GUIContent("By Layer Name"), filter == SceneSearchFilter.ByLayer, OnSearchFilterChanged, SceneSearchFilter.ByLayer);
            menu.AddSeparator("");
            menu.AddItem(new GUIContent("Search All Scenes"), searchAllScenes, OnSearchFilterChanged, !searchAllScenes);
            menu.AddItem(new GUIContent("Open Search History"), false, OnSearchHistoryOpened, null);
            menu.AddSeparator("");
            menu.AddItem(new GUIContent("Unload All Opened Scenes", "Unloads any scenes opened by this tool"), false, UnloadAllScenes, null);

            menu.ShowAsContext();
        }
        GUILayout.EndHorizontal();
        if (searchResults.Count > 0)
        {
            GUILayout.Label(searchResults.Count + ((searchResults.Count == 1) ? " Result Found" : " Results Found"), EditorStyles.boldLabel);
        }
        GUILayout.Label("Active Scene: " + GetSceneName(EditorSceneManager.GetActiveScene().name), EditorStyles.boldLabel);
        scrollPos = GUILayout.BeginScrollView(scrollPos);

        //generate search results (find objects/components)
        if (!string.IsNullOrEmpty(objectLookup))
        {
            if (searchResults.Count > 0)
            {
                searchResults.Clear();
                searchResults = new List <GameObject>();
            }

            List <GameObject> sceneObjs = new List <GameObject>();

            if (searchAllScenes)
            {
                var      scenesGUIDs = AssetDatabase.FindAssets("t:Scene");
                string[] scenesPaths = scenesGUIDs.Select(AssetDatabase.GUIDToAssetPath).ToArray();
                for (int i = 0; i < scenesPaths.Length; i++)
                {
                    sceneObjs.AddRange(EditorSceneManager.GetSceneByPath(scenesPaths[i]).GetRootGameObjects());
                }
            }
            else
            {
                sceneObjs.AddRange(EditorSceneManager.GetActiveScene().GetRootGameObjects());
            }

            for (int i = 0; i < sceneObjs.Count; i++)
            {
                //BY OBJECT OR COMPONENT
                if (filter == SceneSearchFilter.ObjectsAndComponents)
                {
                    if (sceneObjs[i].name.ToLower().Contains(objectLookup.ToLower()) && !searchResults.Contains(sceneObjs[i]))
                    {
                        searchResults.Add(sceneObjs[i]);
                    }

                    Component[] objComponents = sceneObjs[i].GetComponents <Component>();
                    foreach (Component component in objComponents)
                    {
                        if (component.GetType().Name.ToLower().Contains(objectLookup.ToLower()) && !searchResults.Contains(sceneObjs[i]))
                        {
                            searchResults.Add(sceneObjs[i]); break;
                        }
                    }

                    //RECCURSIVE SEARCH (CHILD OBJECTS)
                    SearchChildObjects(sceneObjs[i].transform);
                }

                //BY OBJECT NAME
                else if (filter == SceneSearchFilter.ObjectsOnly)
                {
                    if (sceneObjs[i].name.ToLower().Contains(objectLookup.ToLower()))
                    {
                        searchResults.Add(sceneObjs[i]);
                    }
                }

                //BY OBJECT COMPONENT
                else if (filter == SceneSearchFilter.ComponentsOnly)
                {
                    Component[] objComponents = sceneObjs[i].GetComponents <Component>();
                    foreach (Component component in objComponents)
                    {
                        if (component.GetType().Name.ToLower().Contains(objectLookup.ToLower()))
                        {
                            searchResults.Add(sceneObjs[i]); break;
                        }
                    }
                }

                //BY OBJECT TAG
                else if (filter == SceneSearchFilter.ByTag)
                {
                    if (sceneObjs[i].tag.ToLower().Contains(objectLookup.ToLower()))
                    {
                        searchResults.Add(sceneObjs[i]);
                    }
                }

                //BY OBJECT LAYER
                else if (filter == SceneSearchFilter.ByLayer)
                {
                    if (LayerMask.LayerToName(sceneObjs[i].layer).ToLower().Contains(objectLookup.ToLower()))
                    {
                        searchResults.Add(sceneObjs[i]);
                    }
                }

                //RECCURSIVE SEARCH (CHILD OBJECTS)
                SearchChildObjects(sceneObjs[i].transform);
            }

            //DISPLAY SEARCH RESULTS (FILTER-BASED)
            for (int i = 0; i < searchResults.Count; i++)
            {
                //GUILayout.Label(searchResults[i].name);
                if (fold.Count - 1 < i)
                {
                    fold.Add(false);
                }
                fold[i] = EditorGUILayout.InspectorTitlebar(fold[i], searchResults[i]);

                if (fold[i])
                {
                    GameObject obj            = searchResults[i];
                    int        componentIndex = 1;

                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Tag", GUILayout.Width(30f));
                    obj.tag = EditorGUILayout.TagField("", obj.tag, GUILayout.Width(window.position.width / 2.5f));
                    GUILayout.Label("Layer", GUILayout.Width(40f));
                    obj.layer = EditorGUILayout.LayerField("", obj.layer, GUILayout.Width(window.position.width / 2.75f));
                    GUILayout.EndHorizontal();
                    EditorGUILayout.Space();

                    string scenePath = obj.scene.path;
                    GUILayout.Label("Scene: " + GetSceneName(obj.scene.name));
                    if (!string.IsNullOrEmpty(scenePath))
                    {
                        GUILayout.Label("(" + obj.scene.path + ")");
                    }
                    if (obj.scene != EditorSceneManager.GetActiveScene())
                    {
                        EditorGUILayout.HelpBox("This object is in another scene", MessageType.Info);
                    }

                    EditorGUILayout.Space();
                    GUILayout.Label("Components:");

                    //list all components on the object, BOLD the ones that match search
                    foreach (Behaviour component in obj.GetComponents <Behaviour>())
                    {
                        string    componentName = component.GetType().Name;
                        Texture2D componentIcon = (Texture2D)EditorGUIUtility.ObjectContent(null, component.GetType()).image;
                        if (componentIcon == null)
                        {
                            componentIcon = GetDefaultScriptIcon();
                        }
                        style           = EditorStyles.toggle;
                        style.fontStyle = componentName.ToLower().Contains(objectLookup.ToLower()) ? FontStyle.Bold : FontStyle.Normal;
                        GUILayout.BeginHorizontal();
                        GUILayout.Label(componentIcon, GUILayout.Width(20f), GUILayout.Height(20f));
                        component.enabled = GUILayout.Toggle(component.enabled, componentName, style);
                        GUILayout.EndHorizontal();

                        GUILayout.Label("Component index: " + componentIndex++);
                        List <string> hierarchy = new List <string>();
                        GetObjectHierarchy(obj.transform, ref hierarchy);
                        GUILayout.Label("Hierarchy Order:");
                        for (int e = 0; e < hierarchy.Count; e++)
                        {
                            GUILayout.Label(AddSpace(e * 2) + "↳ " + hierarchy[e]);
                        }
                        GUILayout.Label("Child Index: " + obj.transform.GetSiblingIndex());
                        EditorGUILayout.Space();
                    }

                    if (GUILayout.Button("Find Object"))
                    {
                        EditorGUIUtility.PingObject(obj);
                    }
                    if (obj.scene != EditorSceneManager.GetActiveScene())
                    {
                        if (GUILayout.Button("Load Scene (" + obj.scene.name + ")"))
                        {
                            fold[i] = false; SwitchScenes(obj);
                        }
                    }

                    //if (obj.scene != EditorSceneManager.GetActiveScene()) { if (GUILayout.Button("Load Scene (" + obj.scene.name + ")")) { sceneObjName = obj.name; EditorSceneManager.activeSceneChangedInEditMode += EditorSceneManager_activeSceneChanged; fold[i] = false; window.autoRepaintOnSceneChange = true; UnloadAllScenes(null); SceneSwitcher.SwitchScenes(obj.scene.path); } }
                }
            }
            EditorGUILayout.Space();
        }

        GUILayout.EndScrollView();

        // Add to search history
        if (!string.IsNullOrEmpty(objectLookup) && GUI.GetNameOfFocusedControl() != "SearchField" && lastSearchInstance.ToLower() != objectLookup.ToLower())
        {
            SceneSearchHistory.AddToHistory(this, new SceneSearchHistory.SearchHistory(objectLookup, filter, searchAllScenes, searchResults.Count));
            lastSearchInstance = objectLookup;
            GUI.SetNextControlName("SearchField");
            GUI.FocusControl(null);
        }
    }
コード例 #22
0
 public static bool Title(bool isExpanded, UnyObj obj)
 {
     return(EditorGUILayout.InspectorTitlebar(isExpanded, obj));
 }
コード例 #23
0
    void OnGUI()
    {
        EditorGUILayout.LabelField("Unityエディタ拡張");

        EditorGUILayout.PrefixLabel("PrefixLabel : EditorGUILayout");

        EditorGUILayout.LabelField("LabelField", "EditorGUILayoutはEditor拡張用に調整されてる");

        EditorGUILayout.SelectableLabel("SelectableLabel : 選択してコピペできる。\n変更はできない");

        toggle = EditorGUILayout.Toggle("Toggle", toggle);

        toggleLeft = EditorGUILayout.ToggleLeft("ToggleLeft", toggleLeft);

        foldout = EditorGUILayout.Foldout(foldout, "Foldout");
        if (foldout)
        {
            EditorGUILayout.LabelField("kakikukeko");
        }

        textField = EditorGUILayout.TextField("TextField", textField);

        textArea = EditorGUILayout.TextArea(textArea);

        password = EditorGUILayout.PasswordField("PasswordField", password);

        intField = EditorGUILayout.IntField("IntField", intField);

        intSlider = EditorGUILayout.IntSlider("IntSlider", intSlider, 0, 100);

        floatField = EditorGUILayout.FloatField("FloatField", floatField);

        slider = EditorGUILayout.Slider("Slider", slider, 0.0f, 100.0f);

        EditorGUILayout.MinMaxSlider(new GUIContent("MinMaxSlider"), ref minMaxSliderMinValue, ref minMaxSliderMaxValue, 0.0f, 100.0f);
        EditorGUILayout.LabelField("MinValue = ", minMaxSliderMinValue.ToString());
        EditorGUILayout.LabelField("MaxValue = ", minMaxSliderMaxValue.ToString());

        popup = EditorGUILayout.Popup("Popup", popup, new string[] { "Index 0", "Index 1", "Index 2" });
        EditorGUILayout.LabelField("Popup = ", popup.ToString());

        intPopup = EditorGUILayout.IntPopup("IntPopup", intPopup, new string[] { "Index 0", "Index 1", "Index 2" }, new int[] { 0, 3, 99 });
        EditorGUILayout.LabelField("IntPopup = ", intPopup.ToString());

        enumPopup = (EnumPopup)EditorGUILayout.EnumPopup("EnumPopup", (System.Enum)enumPopup);

        maskField = EditorGUILayout.MaskField("MaskField", maskField, new string[] { "Mask 1", "Mask 2", "Mask 3" });

        enumMaskField = (EnumPopup)EditorGUILayout.EnumMaskField("EnumMaskField", (System.Enum)enumMaskField);

        layer = EditorGUILayout.LayerField("LayerField", layer);

        tag = EditorGUILayout.TagField("TagField", tag);

        vector2Field = EditorGUILayout.Vector2Field("Vector2Field", vector2Field);

        vector3Field = EditorGUILayout.Vector3Field("Vector3Field", vector3Field);

        vector4Field = EditorGUILayout.Vector3Field("Vector4Field", vector4Field);

        rectField = EditorGUILayout.RectField("RectField", rectField);

        colorField = EditorGUILayout.ColorField("ColorField", colorField);

        boundsField = EditorGUILayout.BoundsField("BoundsField", boundsField);

        curveField = EditorGUILayout.CurveField("CurveField", curveField);

        objectField = EditorGUILayout.ObjectField("ObjectField", objectField, typeof(Object), true);

        if (objectField != null)
        {
            inspectorTitlebar = EditorGUILayout.InspectorTitlebar(inspectorTitlebar, objectField);

            if (inspectorTitlebar)
            {
                EditorGUILayout.LabelField("aiueo");
            }
        }

        EditorGUILayout.LabelField("ここからSpace");
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("ここまでSpace");

        EditorGUILayout.HelpBox("HELP", MessageType.Warning);
    }
コード例 #24
0
    void OnGUISceneCheck(VRCSDK2.VRC_SceneDescriptor scene)
    {
        CheckUploadChanges(scene);

        EditorGUILayout.InspectorTitlebar(true, scene.gameObject);

        if (VRC.Core.APIUser.CurrentUser != null && VRC.Core.APIUser.CurrentUser.hasScriptingAccess && !CustomDLLMaker.DoesScriptDirExist())
        {
            CustomDLLMaker.CreateDirectories();
        }

        Vector3 g = Physics.gravity;

        if (g.x != 0.0f || g.z != 0.0f)
        {
            OnGUIWarning(scene, "Gravity vector is not straight down. Though we support different gravity, player orientation is always 'upwards' so things don't always behave as you intend.");
        }
        if (g.y > 0)
        {
            OnGUIWarning(scene, "Gravity vector is not straight down, inverted or zero gravity will make walking extremely difficult.");
        }
        if (g.y == 0)
        {
            OnGUIWarning(scene, "Zero gravity will make walking extremely difficult, though we support different gravity, player orientation is always 'upwards' so this may not have the effect you're looking for.");
        }

        #if PLAYMAKER
        if (VRCSDK2.VRC_PlaymakerHelper.ValidatePlaymaker() == false)
        {
            OnGUIError(scene, VRCSDK2.VRC_PlaymakerHelper.GetErrors());
        }
        #endif

        if (!UpdateLayers.AreLayersSetup())
        {
            OnGUIError(scene, "Layers are not yet configured for VRChat. Please press the 'Setup Layers for VRChat' button above to apply layer settings and enable Test/Publish.");
        }

        if (UpdateLayers.AreLayersSetup() && !UpdateLayers.IsCollisionLayerMatrixSetup())
        {
            OnGUIError(scene, "Physics Collision Layer Matrix is not yet configured for VRChat. Please press the 'Setup Collision Layer Matrix for VRChat' button above to apply collision settings and enable Test/Publish.");
        }

        // warn those without scripting access if they choose to script locally
        if (VRC.Core.APIUser.CurrentUser != null && !VRC.Core.APIUser.CurrentUser.hasScriptingAccess && CustomDLLMaker.DoesScriptDirExist())
        {
            OnGUIWarning(scene, "Your account does not have permissions to upload custom scripts. You can test locally but need to contact VRChat to publish your world with scripts.");
        }

        foreach (VRCSDK2.VRC_DataStorage ds in GameObject.FindObjectsOfType <VRCSDK2.VRC_DataStorage>())
        {
            VRCSDK2.VRC_ObjectSync os = ds.GetComponent <VRCSDK2.VRC_ObjectSync>();
            if (os != null && os.SynchronizePhysics)
            {
                OnGUIWarning(scene, ds.name + " has a VRC_DataStorage and VRC_ObjectSync, with SynchronizePhysics enabled.");
            }
        }

        // auto create VRCScript dir for those with access
        if (VRC.Core.APIUser.CurrentUser != null && VRC.Core.APIUser.CurrentUser.hasScriptingAccess && !CustomDLLMaker.DoesScriptDirExist())
        {
            CustomDLLMaker.CreateDirectories();
        }

        if (scene.UpdateTimeInMS < (int)(1000f / 90f * 3f))
        {
            OnGUIWarning(scene, "Room has a very fast update rate; experience may suffer with many users.");
        }
    }
コード例 #25
0
        void OnGUISpawnable(CVRSpawnable s)
        {
            GameObject spawnableObject = s.gameObject;

            GUI.enabled = true;
            EditorGUILayout.InspectorTitlebar(spawnableObject.activeInHierarchy, spawnableObject);
            int errors = 0;
            int overallPolygonsCount       = 0;
            int overallSkinnedMeshRenderer = 0;
            int overallUniqueMaterials     = 0;
            int overallMissingScripts      = 0;

            foreach (MeshFilter filter in s.gameObject.GetComponentsInChildren <MeshFilter>())
            {
                if (filter.sharedMesh != null)
                {
                    overallPolygonsCount = overallPolygonsCount + filter.sharedMesh.triangles.Length / 3;
                }
            }
            foreach (SkinnedMeshRenderer renderer in s.gameObject.GetComponentsInChildren <SkinnedMeshRenderer>())
            {
                overallSkinnedMeshRenderer++;
                if (renderer.sharedMaterials != null)
                {
                    overallUniqueMaterials = overallUniqueMaterials + renderer.sharedMaterials.Length;
                }
            }
            overallMissingScripts = CCK_Tools.CleanMissingScripts(CCK_Tools.SearchType.Selection, false, spawnableObject);
            if (overallMissingScripts > 0)
            {
                errors++;
            }

            //Errors
            if (overallMissingScripts > 0)
            {
                EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_PROPS_ERROR_MISSING_SCRIPT"), MessageType.Error);
            }

            //Warnings
            if (overallPolygonsCount > 100000)
            {
                EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_PROPS_WARNING_POLYGONS").Replace("{X}", overallPolygonsCount.ToString()), MessageType.Warning);
            }
            if (overallSkinnedMeshRenderer > 10)
            {
                EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_PROPS_WARNING_SKINNED_MESH_RENDERERS").Replace("{X}", overallSkinnedMeshRenderer.ToString()), MessageType.Warning);
            }
            if (overallUniqueMaterials > 20)
            {
                EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_PROPS_WARNING_MATERIALS").Replace("{X}", overallUniqueMaterials.ToString()), MessageType.Warning);
            }

            var spawnableMeshes = getAllAssetMeshesInAvatar(spawnableObject);

            if (CheckForLegacyBlendShapeNormals(spawnableMeshes))
            {
                EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_PROPS_WARNING_LEGACY_BLENDSHAPES"), MessageType.Warning);
                if (GUILayout.Button(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_FIX_IMPORT_SETTINGS")))
                {
                    FixLegacyBlendShapeNormals(spawnableMeshes);
                }
            }

            //Info
            if (overallPolygonsCount >= 50000 && overallPolygonsCount <= 100000)
            {
                EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_PROPS_INFO_POLYGONS").Replace("{X}", overallPolygonsCount.ToString()), MessageType.Info);
            }
            if (overallSkinnedMeshRenderer >= 5 && overallSkinnedMeshRenderer <= 10)
            {
                EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_PROPS_INFO_SKINNED_MESH_RENDERERS").Replace("{X}", overallSkinnedMeshRenderer.ToString()), MessageType.Info);
            }
            if (overallUniqueMaterials >= 10 && overallUniqueMaterials <= 20)
            {
                EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_PROPS_INFO_MATERIALS").Replace("{X}", overallUniqueMaterials.ToString()), MessageType.Info);
            }

            if (errors <= 0 && overallMissingScripts <= 0)
            {
                if (GUILayout.Button(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_PROPS_UPLOAD_BUTTON")))
                {
                    CCK_BuildUtility.BuildAndUploadSpawnable(spawnableObject);
                }
            }
            if (overallMissingScripts > 0)
            {
                if (GUILayout.Button(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_UTIL_REMOVE_MISSING_SCRIPTS_BUTTON")))
                {
                    CCK_Tools.CleanMissingScripts(CCK_Tools.SearchType.Selection, true, spawnableObject);
                }
            }
        }
コード例 #26
0
    public override void OnInspectorGUI()
    {
        EditorGUI.indentLevel++;
        base.OnInspectorGUI();
        EditorGUI.indentLevel--;

        serializedObject.UpdateIfRequiredOrScript();

        EditorGUI.indentLevel++;
        EditorGUILayout.Separator();
        EditorUtils.Header("Effect Modules");
        EditorGUI.indentLevel--;

        //EditorGUILayout.PropertyField(serializedObject.FindProperty("effectModules"), true);

        modulesProp = serializedObject.FindProperty("effectModules");

        // Make sure the editor array is the same size than the module list
        if (moduleEditors == null || moduleEditors.Length != modulesProp.arraySize)
        {
            Array.Resize(ref moduleEditors, modulesProp.arraySize);
        }

        // Get the module list and draw the editor for each one
        int i = 0;

        while (i < modulesProp.arraySize)
        {
            SerializedProperty moduleProp = modulesProp.GetArrayElementAtIndex(i);
            EffectModule       moduleObj  = (EffectModule)moduleProp.objectReferenceValue;

            // If the module is null, add the index so we remove the module later
            if (moduleObj == null)
            {
                modulesProp.DeleteArrayElementAtIndex(i);
                continue;
            }

            CreateCachedEditor(moduleObj, null, ref moduleEditors[i]);

            EditorGUILayout.Separator();
            moduleProp.isExpanded = EditorGUILayout.InspectorTitlebar(moduleProp.isExpanded, moduleObj, true);
            if (moduleProp.isExpanded)
            {
                EditorGUI.indentLevel++;
                moduleEditors[i].OnInspectorGUI();
                EditorGUI.indentLevel--;
            }

            i++;
        }

        // Draw buttons
        EditorGUILayout.Separator();
        EditorGUILayout.Separator();

        EditorGUI.indentLevel++;

        if (GUILayout.Button(NeepEffect.addModuleText))
        {
            OpenModulesMenu();
        }

        /*
         * if (GUILayout.Button("Clear Modules"))
         * {
         *  effect.ClearModules();
         *  AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(effect));
         * }
         */

        EditorGUI.indentLevel--;

        serializedObject.ApplyModifiedProperties();
    }
コード例 #27
0
ファイル: EditorPopup.cs プロジェクト: calapout/LudumDare47
        protected override void OnGUI()
        {
            base.OnGUI();

            if (!Validate())
            {
                return;
            }

            if (e.type == EventType.KeyDown &&
                e.modifiers == EventModifiers.None &&
                e.keyCode == KeyCode.Escape)
            {
                Close();
                return;
            }

            var position = this.position;

            position.x = position.y = 0;
            var height          = 0f;
            var calculateHeight = isPopup;
            var applyHeight     = calculateHeight && e.type == EventType.Repaint;

            var editable = editor.targets.None(t => t.HasHideFlag(HideFlags.NotEditable));

            EditorGUI.BeginChangeCheck();

            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

            var largeHeader = editor.targets.Any(t => !(t is Component));

            EditorGUIUtility.wideMode = position.width >= 330;

            EditorGUIUtility.hierarchyMode = false;

            GUILayout.BeginHorizontal();

            EditorGUI.BeginDisabledGroup(!editable);

            if (largeHeader)
            {
                GUILayout.BeginVertical();
                GUILayout.Space(0);                 // Fix to stick to top
                editor.DrawHeader();
                GUILayout.EndVertical();
            }
            else
            {
                GUILayout.BeginVertical(Styles.smallHeader);
                GUILayout.Space(EditorGUIUtility.isProSkin && !LudiqGUIUtility.isFlatSkin ? -3 : -4);
                GUILayout.BeginHorizontal();
                GUILayout.Space(-12);
                EditorGUILayout.InspectorTitlebar(true, editor.targets, false);
                GUILayout.EndHorizontal();

                if (LudiqGUIUtility.isFlatSkin)
                {
                    GUILayout.Space(-5);
                }

                GUILayout.EndVertical();
            }

            GUILayout.BeginVertical(Styles.smallHeaderExtra, GUILayout.ExpandHeight(true));

            if (largeHeader)
            {
                GUILayout.Space(6);
            }
            else
            {
                if (LudiqGUIUtility.isFlatSkin)
                {
                    GUILayout.Space(5);
                }
                else
                {
                    if (EditorGUIUtility.isProSkin)
                    {
                        var topBorderRect = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.Width(16), GUILayout.Height(1));
                        topBorderRect.y += 1;
                        EditorGUI.DrawRect(topBorderRect, Color.Lerp(ColorPalette.unityBackgroundLighter, ColorPalette.unityForegroundDim, 0.25f));
                        GUILayout.Space(2);
                    }
                    else
                    {
                        GUILayout.Space(2);
                    }
                }
            }

            EditorGUI.EndDisabledGroup();

            var wantsPin = GUILayout.Toggle(isPinned, GUIContent.none, PeekStyles.pinButton);

            EditorGUI.BeginDisabledGroup(!editable);

            if (isPinned != wantsPin)
            {
                if (wantsPin)
                {
                    Pin();
                }
                else
                {
                    Close();
                }

                GUIUtility.ExitGUI();
            }

            GUILayout.EndVertical();

            if (largeHeader)
            {
                GUILayout.Space(2);
            }

            GUILayout.EndHorizontal();

            if (editor.targets.Length == 1 && editor.targets[0] is GameObject go)
            {
                GUILayout.Space(-1);

                GUILayout.BeginHorizontal(Styles.prefabTools);

                if (PrefabUtility.IsPartOfAnyPrefab(go))
                {
                    GUILayout.Label("Unpack", GUILayout.ExpandWidth(false));

                    if (GUILayout.Button("Root", EditorStyles.miniButtonLeft, GUILayout.ExpandWidth(true)))
                    {
                        PrefabUtility.UnpackPrefabInstance(go, PrefabUnpackMode.OutermostRoot, InteractionMode.UserAction);
                    }

                    if (GUILayout.Button("Completely", EditorStyles.miniButtonRight, GUILayout.ExpandWidth(true)))
                    {
                        PrefabUtility.UnpackPrefabInstance(go, PrefabUnpackMode.Completely, InteractionMode.UserAction);
                    }

                    GUILayout.Space(2);
                    GUILayout.Label("Create", GUILayout.ExpandWidth(false));

                    if (GUILayout.Button("Prefab", EditorStyles.miniButtonLeft, GUILayout.ExpandWidth(true)))
                    {
                        GameObjectOperations.CreateOriginalPrefab(go);
                    }

                    if (GUILayout.Button("Variant", EditorStyles.miniButtonRight, GUILayout.ExpandWidth(true)))
                    {
                        GameObjectOperations.CreatePrefabVariant(go);
                    }
                }
                else
                {
                    GUILayout.Space(LudiqGUIUtility.isFlatSkin ? 4 : 9);
                    GUILayout.Label("Prefab", GUILayout.ExpandWidth(false));

                    if (GUILayout.Button("Create Prefab", EditorStyles.miniButton))
                    {
                        GameObjectOperations.CreatePrefab(go);
                    }
                }

                GUILayout.Space(14);

                GUILayout.EndHorizontal();

                if (LudiqGUIUtility.isFlatSkin)
                {
                    GUILayout.Space(-1);
                }
            }

            if (calculateHeight)
            {
                height += GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.Height(0)).yMin;
            }

            EditorGUI.EndDisabledGroup();

            scroll = EditorGUILayout.BeginScrollView(scroll);

            if (!largeHeader)
            {
                GUILayout.Space(3);
            }

            GUILayout.BeginVertical(Styles.inspectorBackground);
            EditorGUIUtility.hierarchyMode = true;
            EditorGUI.BeginDisabledGroup(!editable);
            editor.OnInspectorGUI();
            EditorGUI.EndDisabledGroup();
            GUILayout.EndVertical();

            if (isPinned)
            {
                GUILayout.FlexibleSpace();
            }

            if (HasPreview())
            {
                var previewArea = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.Height(120));
                editor.DrawPreview(previewArea);
            }
            else
            {
                GUILayout.Space(2);
            }

            if (calculateHeight)
            {
                height += GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.Height(0)).yMin;
            }

            GUILayout.EndVertical();

            GUILayout.EndScrollView();

            if (applyHeight)
            {
                autoHeight = height;
            }

            if (EditorGUI.EndChangeCheck())
            {
            }

            if (e.type == EventType.KeyDown &&
                e.keyCode == KeyCode.Space)
            {
                if (isPopup)
                {
                    Pin();
                }
                else
                {
                    Close();
                }

                e.Use();
                return;
            }

            if (e.type == EventType.Repaint)
            {
                LudiqGUI.DrawEmptyRect(new Rect(Vector2.zero, this.position.size), ColorPalette.unityBackgroundVeryDark);
            }

            if (editor.RequiresConstantRepaint())
            {
                Repaint();
            }
        }
コード例 #28
0
    //7
    //GUISkin myGUISkin;


    void OnGUI()
    {
        //SECTION5---------------
        // 直接サイズを指定する場合は、
        // GUILayout.Width/Heightを使う。
        buttonSize = EditorGUILayout.Vector2Field("ButtonSize", buttonSize);
        if (GUILayout.Button("サイズ指定ボタン", GUILayout.Width(buttonSize.x), GUILayout.Height(buttonSize.y)))
        {
            Debug.Log("サイズ指定ボタン");
        }

        // 自動的にサイズ変更される範囲を指定する場合は
        // GUILayout.MinWidth/MaxWidth/MinHeight/MaxHeightを使う。
        buttonMinSize = EditorGUILayout.Vector2Field("ButtonMinSize", buttonMinSize);
        buttonMaxSize = EditorGUILayout.Vector2Field("ButtonMaxSize", buttonMaxSize);
        if (GUILayout.Button("最小最大指定ボタン",
                             GUILayout.MinWidth(buttonMinSize.x), GUILayout.MinHeight(buttonMinSize.y),
                             GUILayout.MaxWidth(buttonMaxSize.x), GUILayout.MaxHeight(buttonMaxSize.y)))
        {
            Debug.Log("最小最大指定ボタン");
        }

        // 有効範囲内全体に広げるかどうかは
        // GUILayout.ExpandWidth/ExpandHeightで指定する。
        expandWidth  = EditorGUILayout.Toggle("ExpandWidth", expandWidth);
        expandHeight = EditorGUILayout.Toggle("ExpandHeight", expandHeight);
        if (GUILayout.Button("Expandボタン", GUILayout.ExpandWidth(expandWidth), GUILayout.ExpandHeight(expandHeight)))
        {
            Debug.Log("Expandボタン");
        }

        //end-SECTION5-----------------------

        //section6
        //動的できんかな
        rightSize = EditorGUILayout.IntSlider("Size", rightSize, 1, 20, GUILayout.ExpandWidth(false));

        GUI.skin       = Resources.Load <GUISkin>("Assets/Editor/MyGUISkin");
        rightScrollPos = EditorGUILayout.BeginScrollView(rightScrollPos, GUI.skin.box);
        {
            // スクロール範囲
            for (int y = 0; y < rightSize; y++)
            {
                EditorGUILayout.BeginHorizontal(GUI.skin.box);
                {
                    /*
                     * // ここの範囲は横並び
                     * EditorGUILayout.PrefixLabel("Index " + y);
                     *
                     * // 下に行くほどボタン数増やす
                     * for (int i = 0; i < y + 1; i++)
                     * {
                     *      // ボタン(横幅100px)
                     *      if (GUILayout.Button("Button" + i, GUILayout.Width(100)))
                     *      {
                     *              Debug.Log("Button" + i + "押したよ");
                     *      }
                     * }
                     */
                    objectFieldArray[y] = EditorGUILayout.ObjectField("LAYER " + y, objectFieldArray[y], typeof(Object), true);

                    if (objectFieldArray[y] != null)
                    {
                        inspectorTitlebar = EditorGUILayout.InspectorTitlebar(inspectorTitlebar, objectFieldArray[y]);
                        if (inspectorTitlebar)
                        {
                            EditorGUILayout.LabelField("チラッチラッ");
                        }
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            // こんな感じで横幅固定しなくても、範囲からはみ出すときにスクロールバー出してくれる。
        }
        EditorGUILayout.EndScrollView();

        //



        EditorGUILayout.LabelField("ようこそ! Unityエディタ拡張の沼へ!");         // やっぱり残しておこう。

        EditorGUILayout.LabelField("LabelField", "EditorGUILayoutはEditor拡張用に調整されてる系");

        EditorGUILayout.SelectableLabel("SelectableLabel : 選択してコピペできる。変更はできない");

        EditorGUILayout.BeginHorizontal(GUI.skin.box);
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            {
                toggle = EditorGUILayout.Toggle("Toggle", toggle);

                toggleLeft = EditorGUILayout.ToggleLeft("ToggleLeft", toggleLeft);

                foldout = EditorGUILayout.Foldout(foldout, "Foldout");
                if (foldout)
                {
                    EditorGUILayout.LabelField("チラッ");
                }
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical(GUI.skin.box);
            {
                textField = EditorGUILayout.TextField("TextField", textField);

                textArea = EditorGUILayout.TextArea(textArea);
            }
            EditorGUILayout.EndVertical();
        }
        EditorGUILayout.EndHorizontal();

        intField = EditorGUILayout.IntField("IntField", intField);

        intSlider = EditorGUILayout.IntSlider("IntSlider", intSlider, 0, 100);

        floatField = EditorGUILayout.FloatField("FloatField", floatField);

        slider = EditorGUILayout.Slider("Slider", slider, 0.0f, 100.0f);

        EditorGUILayout.MinMaxSlider(new GUIContent("MinMaxSlider"), ref minMaxSliderMinValue, ref minMaxSliderMaxValue, 0.0f, 100.0f);
        EditorGUILayout.LabelField("MinValue = ", minMaxSliderMinValue.ToString());
        EditorGUILayout.LabelField("MaxValue = ", minMaxSliderMaxValue.ToString());

        layer = EditorGUILayout.LayerField("LayerField", layer);

        tag = EditorGUILayout.TagField("TagField", tag);

        vector3Field = EditorGUILayout.Vector3Field("Vector3Field", vector3Field);

        rectField = EditorGUILayout.RectField("RectField", rectField);

        colorField = EditorGUILayout.ColorField("ColorField", colorField);

        boundsField = EditorGUILayout.BoundsField("BoundsField", boundsField);        //center,extends,3D範囲、Boundsは構造体らしい。

        curveField = EditorGUILayout.CurveField("CurveField", curveField);

        /*
         * objectField = EditorGUILayout.ObjectField("ObjectField", objectField, typeof(Object), true);
         *
         * if (objectField != null)
         * {
         *      inspectorTitlebar = EditorGUILayout.InspectorTitlebar(inspectorTitlebar, objectField);
         *      if (inspectorTitlebar)
         *      {
         *              EditorGUILayout.LabelField("チラッチラッ");
         *      }
         * }
         */

        EditorGUILayout.LabelField("ここからSpace");
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("ここまでSpace");

        EditorGUILayout.HelpBox("Heeeeeelllllp!!!!!", MessageType.Warning);
    }
コード例 #29
0
    void OnGUI()                                     //不定期で通る
    {
        EditorGUILayout.BeginVertical(GUI.skin.box); //縦
        {
            if (GUILayout.Button("再生/ポーズ", GUILayout.Width(200), GUILayout.Height(20)))
            {
                Debug.Log("再生ボタン");
                EditorApplication.ExecuteMenuItem("Edit/Play");                //ゲーム再生
            }

            timeSlider = EditorGUILayout.IntSlider("TIME(FRAME):", timeSlider, 0, maxFrame);

            //まず音楽再生するところ。
            EditorGUILayout.BeginHorizontal(GUI.skin.box);            //横
            {
                soundObject = EditorGUILayout.ObjectField("Audio", soundObject, typeof(GameObject), true) as GameObject;
                if (soundObject != null && soundObject.GetComponent <AudioSource>() != null)
                {
                    audioSource = soundObject.GetComponent <AudioSource>();
                    maxFrame    = (int)(audioSource.clip.length * 30.0f);
                    inspectorTitlebarForSound = EditorGUILayout.InspectorTitlebar(inspectorTitlebarForSound, soundObject);
                    if (inspectorTitlebarForSound)
                    {
                        EditorGUILayout.LabelField("オーディオクリップの長さは" + audioSource.clip.length.ToString() + "秒です。");
                    }
                    //ラブカのサウンドオブジェクトを更新
                    rabuka.GetComponent <Rabuka>().soundObject = soundObject;
                }
                else
                {
                    EditorGUILayout.LabelField("オーディオソースコンポーネントを所持したオブジェクトを入れてください。");
                }
            } EditorGUILayout.EndHorizontal();

            //その他のオブジェクトのところ
            //選択中のオブジェクトをボタンで入れる
            selectedGameObject = EditorGUILayout.ObjectField("SELECTED OBJECT ", selectedGameObject, typeof(GameObject), true) as GameObject;
            //オブジェクト追加ボタン
            if (GUILayout.Button("選択中のオブジェクトを追加", GUILayout.Width(200), GUILayout.Height(30)))
            {
                if (selectedGameObject)//ぬるなら入らない。
                {
                    rabuka.GetComponent <Rabuka>().objectList.Add(selectedGameObject);
                    tmpObject = new GameObject("TargetObject:" + (rabuka.GetComponent <Rabuka>().objectList.Count - 1).ToString());
                    tmpObject.transform.SetParent(rabuka.transform);                    //ラブ下につけます。
                }
            }

            objectsScrollPos = EditorGUILayout.BeginScrollView(objectsScrollPos, GUI.skin.box);
            {
                for (int i = 0; i < rabuka.GetComponent <Rabuka>().objectList.Count; i++) //インデックスつける?
                {
                    EditorGUILayout.BeginVertical(GUI.skin.box);                          //縦
                    {
                        if (rabuka.GetComponent <Rabuka>().objectList[i] != null)         //多分必要ないがエラー対策
                        {
                            //----オブジェクトがどんな種類でも共通の処理-----ターゲットが変わるのは流石に不味くないか。
                            EditorGUILayout.LabelField("OBJECT NUMBER: " + i.ToString());
                            //じゃあとりあえず、自動でオブジェクトの種類を振り分け、その他だったら強制的にデフォルトのCSを追加するって方針でいきます。
                            if (rabuka.GetComponent <Rabuka>().objectList[i].GetComponent <Text>())                          //テキストオブジェクトと判定。
                            {
                                EditorGUILayout.LabelField("TYPE TEXT: " + rabuka.GetComponent <Rabuka>().objectList[i].GetFullPath());
                                TextCheckPointDisplay(rabuka.GetComponent <Rabuka>().objectList[i], i);
                            }
                            else if (rabuka.GetComponent <Rabuka>().objectList[i].GetComponent <Camera>())
                            {
                                if (!rabuka.GetComponent <Rabuka>().objectList[i].GetComponent <PostEffect>())//ポストエフェクトの準備(まあ要らないけど)
                                {
                                    rabuka.GetComponent <Rabuka>().objectList[i].AddComponent <PostEffect>();
                                    Material cameraMaterial = AssetDatabase.LoadAssetAtPath <Material>("Assets/RABUKAEDITOR/Scripts/Camera/CameraMaterial.mat");
                                    rabuka.GetComponent <Rabuka>().objectList[i].GetComponent <PostEffect>()._material        = cameraMaterial;
                                    rabuka.GetComponent <Rabuka>().objectList[i].GetComponent <PostEffect>()._material.shader = AssetDatabase.LoadAssetAtPath <Shader>("Assets/RabukaEditor/Scripts/Camera/posteffect.shader");
                                }
                                EditorGUILayout.LabelField("TYPE CAMERA: " + rabuka.GetComponent <Rabuka>().objectList[i].GetFullPath());
                                CameraCheckPointDisplay(rabuka.GetComponent <Rabuka>().objectList[i], i);
                            }
                            else
                            {
                                EditorGUILayout.LabelField("The object type could not be recognized. It is classified into OTHER.");
                            }
                        }
                    }
                    EditorGUILayout.EndVertical();
                }
            }
            EditorGUILayout.EndScrollView();
        }
        EditorGUILayout.EndVertical();
    }
コード例 #30
0
    void OnGUI()
    {
        if (target == null || target.GetComponent <Animator>() == null || layerStateList == null)
        {
            EditorGUILayout.HelpBox("Select target GameObject", MessageType.Info);
            return;
        }

        EditorGUILayout.InspectorTitlebar(false, target);

        EditorGUILayout.Space();

        scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUI.skin.box);

        var animator        = target.GetComponent <Animator>();
        var controller      = GetTargetAnimatorController();
        int transitionCount = 0;

        foreach (var layerInfo in layerStateList)
        {
            var layer = System.Array.Find <AnimatorControllerLayer>(
                controller.layers,
                p => p.name == layerInfo.Key
                );

            foreach (var state in layerInfo.Value)
            {
                var transition = GetTransition(state.state.name, layer);

                if (animator == null || transition == null)
                {
                    continue;
                }

                transitionCount++;

                if (transition.duration > 0 || transition.offset > 0 || transition.exitTime < 0.995f)
                {
                    EditorGUILayout.BeginHorizontal("box");

                    EditorGUILayout.LabelField(state.state.name, EditorStyles.boldLabel);

                    if (GUILayout.Button("Display"))
                    {
                        Selection.activeObject = transition;
                        FocusInspectorWindow();
                    }

                    if (GUILayout.Button("Apply"))
                    {
                        transition.exitTime = 0.9999999f;
                        transition.duration = 0;
                        transition.offset   = 0;

                        Selection.activeObject = transition;
                        FocusInspectorWindow();
                    }

                    EditorGUILayout.EndHorizontal();
                }
            }
        }

        if (transitionCount > 0)
        {
            EditorGUILayout.LabelField("Apply all animations.");
            EditorGUILayout.LabelField("Number of transitions: " + transitionCount);
        }

        GUILayout.EndScrollView();
    }