private void drawLeftCenterGUI()
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            GUILayout.Toggle(false, "Configs", EditorStyles.toolbarButton);
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(5);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Asset Version", GUILayout.MaxWidth(100));
            GUI.color = Color.gray;
            GUILayout.TextField(mainBuilder.GameVersion.ToString());
            GUI.color = Color.white;
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("App   Version", GUILayout.MaxWidth(100));
            GUI.color = Color.gray;
            GUILayout.TextField(mainBuilder.ApkVersion.ToString());
            GUI.color = Color.white;
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("SDK Config", GUILayout.Width(100)))
            {
                BuildUtil.DisableCacheServer();
                Debug.Log("编辑打开!!!!");
            }
            GUI.backgroundColor = Color.red;
            sdkConfigIndex      = EditorGUILayout.Popup(sdkConfigIndex, mainBuilder.NameSDKs, GUILayout.MaxWidth(160));
            GUI.backgroundColor = Color.white;
            GUILayout.EndHorizontal();

            GUILayout.Space(10);

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Development Build", mainBuilder.IsBuildDev ? EditorStyles.boldLabel : EditorStyles.label, GUILayout.MaxWidth(160));
            mainBuilder.IsBuildDev = EditorGUILayout.Toggle(mainBuilder.IsBuildDev, GUILayout.MaxWidth(30));
            GUILayout.EndHorizontal();
            if (!this.mainBuilder.IsBuildDev)
            {
                this.mainBuilder.IsAutoConnectProfile = false;
                this.mainBuilder.IsScriptDebug        = false;
            }

            EditorGUI.BeginDisabledGroup(!this.mainBuilder.IsBuildDev);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Script Debugging", this.mainBuilder.IsScriptDebug ? EditorStyles.boldLabel : EditorStyles.label, GUILayout.MaxWidth(160));
            this.mainBuilder.IsScriptDebug = EditorGUILayout.Toggle(this.mainBuilder.IsScriptDebug, GUILayout.MaxWidth(30));
            GUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Autoconnect Profile", this.mainBuilder.IsAutoConnectProfile ? EditorStyles.boldLabel : EditorStyles.label, GUILayout.MaxWidth(160));
            this.mainBuilder.IsAutoConnectProfile = EditorGUILayout.Toggle(this.mainBuilder.IsAutoConnectProfile, GUILayout.MaxWidth(30));
            GUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();

            //            EditorGUILayout.BeginHorizontal();
            //            EditorGUILayout.LabelField("Config Table", GUILayout.MaxWidth(160));
            //            this.mainBuilder.IsDebug = EditorGUILayout.Toggle(this.mainBuilder.IsDebug, GUILayout.MaxWidth(30));
            //            GUILayout.EndHorizontal();
            //
            //            EditorGUILayout.BeginHorizontal();
            //            EditorGUILayout.LabelField("Lua Script", GUILayout.MaxWidth(160));
            //            this.mainBuilder.IsDebug = EditorGUILayout.Toggle(this.mainBuilder.IsDebug, GUILayout.MaxWidth(30));
            //            GUILayout.EndHorizontal();

            GUILayout.Space(10);
            GUI.backgroundColor = Color.yellow;
            if (GUILayout.Button("Debug Build"))
            {
                mainBuilder.OnClickDebugBuild(true);
            }
            GUI.backgroundColor = Color.white;

            GUILayout.Space(10);
            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Buildings", GUILayout.Width(100));
            buildingIndex = EditorGUILayout.Popup(buildingIndex, styles.BuildContents);
            GUILayout.EndHorizontal();
            if (GUILayout.Button("Build"))
            {
                int packageBuildins = styles.BuildPackageOpts[buildingIndex];
                if ((packageBuildins & (int)PackageBuildings.BuildApp) != 0)
                {
                    string rootPath = Path.GetFullPath(Path.Combine(Application.dataPath, "../"));
                    string filePath = EditorUtility.SaveFilePanel("Tip", rootPath, PlayerSettings.productName,
                                                                  BuilderPreference.AppExtension.Substring(1));
                    if (!string.IsNullOrEmpty(filePath))
                    {
                        mainBuilder.ApkSavePath = filePath;
                        mainBuilder.OnClickBuild(styles.BuildingOpts[buildingIndex], packageBuildins);
                    }
                }
                else
                {
                    mainBuilder.OnClickBuild(styles.BuildingOpts[buildingIndex], packageBuildins);
                }
            }

            GUILayout.Space(10);
            //GUILayout.Label("", "IN Title");
            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Auto Build", GUILayout.Width(100));
            autoBuildIndex = EditorGUILayout.Popup(autoBuildIndex, styles.OnekeyBuilds);

            GUILayout.EndHorizontal();
            GUI.backgroundColor = Color.green;
            if (GUILayout.Button("Go"))
            {
                string rootPath = Path.GetFullPath(Path.Combine(Application.dataPath, "../"));
                string filePath = EditorUtility.SaveFilePanel("Tip", rootPath, PlayerSettings.productName, BuilderPreference.AppExtension.Substring(1));
                if (!string.IsNullOrEmpty(filePath))
                {
                    mainBuilder.OnClickAutoBuild(filePath, styles.AutoBuilds[autoBuildIndex]);
                }
            }
            GUI.backgroundColor = Color.white;

            GUILayout.Space(5);
            GUILayout.Label("", "IN Title");
            GUILayout.Space(-5);

            GUILayout.BeginVertical(GUILayout.MaxHeight(this.Position.height * 0.5f));
            drawBundleRulePropertys();
            GUILayout.EndVertical();
        }
        private void OnDrawLayer(Rect rect, int index, bool isActive, bool isFocused)
        {
            var lineHeight  = EditorGUIUtility.singleLineHeight;
            var lineSpacing = EditorGUIUtility.standardVerticalSpacing;
            var lineOffset  = lineHeight + lineSpacing;
            var y           = rect.y + lineSpacing;
            var layer       = _layers[index];

            var obj           = layer.OutlineSettings;
            var merge         = layer.MergeLayerObjects;
            var enabled       = layer.Enabled;
            var name          = layer.NameTag;
            var color         = layer.OutlineColor;
            var width         = layer.OutlineWidth;
            var renderMode    = layer.OutlineRenderMode;
            var blurIntensity = layer.OutlineIntensity;
            var alphaCutoff   = layer.OutlineAlphaCutoff;

            EditorGUI.BeginChangeCheck();

            // Header
            {
                var rc     = new Rect(rect.x, y, rect.width, lineHeight);
                var bgRect = new Rect(rect.x - 2, y - 2, rect.width + 3, lineHeight + 3);

                // Header background
                EditorGUI.DrawRect(rc, Color.gray);
                EditorGUI.DrawRect(new Rect(bgRect.x, bgRect.y, bgRect.width, 1), Color.gray);
                EditorGUI.DrawRect(new Rect(bgRect.x, bgRect.yMax, bgRect.width, 1), Color.gray);
                EditorGUI.DrawRect(new Rect(bgRect.x, bgRect.y, 1, bgRect.height), Color.gray);
                EditorGUI.DrawRect(new Rect(bgRect.xMax, bgRect.y, 1, bgRect.height), Color.gray);

                obj     = (OutlineSettings)EditorGUI.ObjectField(rc, " ", obj, typeof(OutlineSettings), true);
                enabled = EditorGUI.ToggleLeft(rc, "Layer #" + index.ToString(), enabled, EditorStyles.boldLabel);
                y      += lineOffset;
            }

            // Layer properties
            {
                name = EditorGUI.TextField(new Rect(rect.x, y, rect.width, lineHeight), "Name", name);
                y   += lineOffset;

                merge = EditorGUI.Toggle(new Rect(rect.x, y, rect.width, lineHeight), "Merge Layer Objects", merge);
                y    += lineOffset;
            }

            // Outline settings
            {
                EditorGUI.BeginDisabledGroup(obj != null);

                color = EditorGUI.ColorField(new Rect(rect.x, y, rect.width, lineHeight), OutlineEditorUtility.ColorContent, color, true, true, true);
                y    += lineOffset;

                width = EditorGUI.IntSlider(new Rect(rect.x, y, rect.width, lineHeight), OutlineEditorUtility.WidthContent, width, OutlineResources.MinWidth, OutlineResources.MaxWidth);
                y    += lineOffset;

                renderMode = (OutlineRenderFlags)EditorGUI.EnumFlagsField(new Rect(rect.x, y, rect.width, lineHeight), OutlineEditorUtility.RenderFlagsContent, renderMode);
                y         += lineOffset;

                if ((renderMode & OutlineRenderFlags.Blurred) != 0)
                {
                    blurIntensity = EditorGUI.Slider(new Rect(rect.x, y, rect.width, lineHeight), OutlineEditorUtility.BlurIntensityContent, blurIntensity, OutlineResources.MinIntensity, OutlineResources.MaxIntensity);
                    y            += lineOffset;
                }

                if ((renderMode & OutlineRenderFlags.EnableAlphaTesting) != 0)
                {
                    alphaCutoff = EditorGUI.Slider(new Rect(rect.x, y, rect.width, lineHeight), OutlineEditorUtility.AlphaCutoffContent, alphaCutoff, OutlineResources.MinAlphaCutoff, OutlineResources.MaxAlphaCutoff);
                }

                EditorGUI.EndDisabledGroup();
            }

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(_layers, "Layers changed");
                EditorUtility.SetDirty(_layers);

                layer.OutlineSettings    = obj;
                layer.Enabled            = enabled;
                layer.NameTag            = name;
                layer.MergeLayerObjects  = merge;
                layer.OutlineWidth       = width;
                layer.OutlineColor       = color;
                layer.OutlineRenderMode  = renderMode;
                layer.OutlineIntensity   = blurIntensity;
                layer.OutlineAlphaCutoff = alphaCutoff;
            }
        }
        public override void OnInspectorGUI()
        {
            // Restore mesh part for undo logic after undo of "Add Parts Renderer".
            // Triggers regeneration and assignment of the mesh filter's mesh.
            if (component.GetComponent <MeshFilter>() && component.GetComponent <MeshFilter>().sharedMesh == null)
            {
                component.OnDisable();
                component.OnEnable();
            }

            var componentRenderers = component.partsRenderers;
            int totalParts;

            using (new SpineInspectorUtility.LabelWidthScope()) {
                bool componentEnabled = component.enabled;
                bool checkBox         = EditorGUILayout.Toggle("Enable Separator", componentEnabled);
                if (checkBox != componentEnabled)
                {
                    component.enabled = checkBox;
                }
                if (component.SkeletonRenderer.disableRenderingOnOverride && !component.enabled)
                {
                    EditorGUILayout.HelpBox("By default, SkeletonRenderer's MeshRenderer is disabled while the SkeletonRenderSeparator takes over rendering. It is re-enabled when SkeletonRenderSeparator is disabled.", MessageType.Info);
                }

                EditorGUILayout.PropertyField(copyPropertyBlock_);
                EditorGUILayout.PropertyField(copyMeshRendererFlags_);
            }

            // SkeletonRenderer Box
            using (new SpineInspectorUtility.BoxScope(false)) {
                // Fancy SkeletonRenderer foldout reference field
                {
                    EditorGUI.indentLevel++;
                    EditorGUI.BeginChangeCheck();
                    var foldoutSkeletonRendererRect = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight);
                    EditorGUI.PropertyField(foldoutSkeletonRendererRect, skeletonRenderer_);
                    if (EditorGUI.EndChangeCheck())
                    {
                        serializedObject.ApplyModifiedProperties();
                    }
                    if (component.SkeletonRenderer != null)
                    {
                        skeletonRendererExpanded = EditorGUI.Foldout(foldoutSkeletonRendererRect, skeletonRendererExpanded, "");
                    }
                    EditorGUI.indentLevel--;
                }

                int separatorCount = 0;
                EditorGUI.BeginChangeCheck();
                if (component.SkeletonRenderer != null)
                {
                    // Separators from SkeletonRenderer
                    {
                        bool skeletonRendererMismatch = skeletonRendererSerializedObject != null && skeletonRendererSerializedObject.targetObject != component.SkeletonRenderer;
                        if (separatorNamesProp == null || skeletonRendererMismatch)
                        {
                            if (component.SkeletonRenderer != null)
                            {
                                skeletonRendererSerializedObject = new SerializedObject(component.SkeletonRenderer);
                                separatorNamesProp            = skeletonRendererSerializedObject.FindProperty("separatorSlotNames");
                                separatorNamesProp.isExpanded = true;
                            }
                        }

                        if (separatorNamesProp != null)
                        {
                            if (skeletonRendererExpanded)
                            {
                                EditorGUI.indentLevel++;
                                SkeletonRendererInspector.SeparatorsField(separatorNamesProp);
                                EditorGUI.indentLevel--;
                            }
                            separatorCount = this.SkeletonRendererSeparatorCount;
                        }
                    }

                    if (SkeletonRendererSeparatorCount == 0)
                    {
                        EditorGUILayout.HelpBox("Separators are empty. Change the size to 1 and choose a slot if you want the render to be separated.", MessageType.Info);
                    }
                }

                if (EditorGUI.EndChangeCheck())
                {
                    skeletonRendererSerializedObject.ApplyModifiedProperties();

                    if (!Application.isPlaying)
                    {
                        slotsReapplyRequired = true;
                    }
                }


                totalParts = separatorCount + 1;
                var counterStyle = skeletonRendererExpanded ? EditorStyles.label : EditorStyles.miniLabel;
                EditorGUILayout.LabelField(string.Format("{0}: separates into {1}.", SpineInspectorUtility.Pluralize(separatorCount, "separator", "separators"), SpineInspectorUtility.Pluralize(totalParts, "part", "parts")), counterStyle);
            }

            // Parts renderers
            using (new SpineInspectorUtility.BoxScope(false)) {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(this.partsRenderers_, true);
                EditorGUI.indentLevel--;

                // Null items warning
                bool nullItemsFound = componentRenderers.Contains(null);
                if (nullItemsFound)
                {
                    EditorGUILayout.HelpBox("Some items in the parts renderers list are null and may cause problems.\n\nYou can right-click on that element and choose 'Delete Array Element' to remove it.", MessageType.Warning);
                }

                // (Button) Match Separators count
                if (separatorNamesProp != null)
                {
                    int currentRenderers = 0;
                    foreach (var r in componentRenderers)
                    {
                        if (r != null)
                        {
                            currentRenderers++;
                        }
                    }
                    int extraRenderersNeeded = totalParts - currentRenderers;

                    if (component.enabled && component.SkeletonRenderer != null && extraRenderersNeeded > 0)
                    {
                        EditorGUILayout.HelpBox(string.Format("Insufficient parts renderers. Some parts will not be rendered."), MessageType.Warning);
                        string addMissingLabel = string.Format("Add the missing renderer{1} ({0}) ", extraRenderersNeeded, SpineInspectorUtility.PluralThenS(extraRenderersNeeded));
                        if (GUILayout.Button(addMissingLabel, GUILayout.Height(40f)))
                        {
                            AddPartsRenderer(extraRenderersNeeded);
                            DetectOrphanedPartsRenderers(component);
                            partsRendererInitRequired = true;
                        }
                    }
                }

                if (partsRenderers_.isExpanded != partsRenderersExpanded)
                {
                    partsRenderersExpanded = partsRenderers_.isExpanded;
                }
                if (partsRenderers_.isExpanded)
                {
                    using (new EditorGUILayout.HorizontalScope()) {
                        // (Button) Destroy Renderers button
                        if (componentRenderers.Count > 0)
                        {
                            if (GUILayout.Button("Clear Parts Renderers"))
                            {
                                // Do you really want to destroy all?
                                Undo.RegisterCompleteObjectUndo(component, "Clear Parts Renderers");
                                if (EditorUtility.DisplayDialog("Destroy Renderers", "Do you really want to destroy all the Parts Renderer GameObjects in the list?", "Destroy", "Cancel"))
                                {
                                    foreach (var r in componentRenderers)
                                    {
                                        if (r != null)
                                        {
                                            Undo.DestroyObjectImmediate(r.gameObject);
                                        }
                                    }
                                    componentRenderers.Clear();
                                    // Do you also want to destroy orphans? (You monster.)
                                    DetectOrphanedPartsRenderers(component);
                                }
                            }
                        }

                        // (Button) Add Part Renderer button
                        if (GUILayout.Button("Add Parts Renderer"))
                        {
                            AddPartsRenderer(1);
                            partsRendererInitRequired = true;
                        }
                    }
                }
            }

            serializedObject.ApplyModifiedProperties();

            if (partsRendererInitRequired)
            {
                Undo.RegisterCompleteObjectUndo(component.GetComponent <MeshRenderer>(), "Add Parts Renderers");
                component.OnEnable();
                partsRendererInitRequired = false;
            }

            if (slotsReapplyRequired && UnityEngine.Event.current.type == EventType.Repaint)
            {
                component.SkeletonRenderer.ReapplySeparatorSlotNames();
                component.SkeletonRenderer.LateUpdate();
                SceneView.RepaintAll();
                slotsReapplyRequired = false;
            }
        }
Exemplo n.º 4
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            if (instance == null)
            {
                Awake(); return;
            }

            GUI.changed = false;

            Undo.RecordObject(instance, "PerkManager");

            EditorGUILayout.Space();

            cont = new GUIContent("Game Scene:", "Check to to indicate if the scene is not an actual game scene\nIntend if the a perk menu scene, purchased perk wont take effect ");
            instance.inGameScene = EditorGUILayout.Toggle(cont, instance.inGameScene);

            cont = new GUIContent("Carry Over:", "Check to have carry the progress made in previous level to this level, the progress made in this level will be carry over to the next level.\n\nIf this is the first level, the specified setting value is used instead");
            instance.carryOver = EditorGUILayout.Toggle(cont, instance.carryOver);

            EditorGUILayout.Space();


            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical();

            EditorGUIUtility.labelWidth += 35;
            cont = new GUIContent("Use RscManager For Cost:", "Check use the resources in RscManager for perk cost");
            instance.useRscManagerForCost = EditorGUILayout.Toggle(cont, instance.useRscManagerForCost);
            EditorGUIUtility.labelWidth  -= 35;

            cont = new GUIContent("Resource:", "The resource used  to cast perk");
            if (instance.useRscManagerForCost)
            {
                EditorGUILayout.LabelField("Resource:", "-");
            }
            else
            {
                instance.rsc = EditorGUILayout.IntField(cont, instance.rsc);
            }

            GUILayout.EndVertical();

            if (!instance.useRscManagerForCost)
            {
                Sprite icon = PerkDB.GetRscIcon();
                icon = (Sprite)EditorGUILayout.ObjectField(icon, typeof(Sprite), true, GUILayout.Width(40), GUILayout.Height(40));
                PerkDB.SetRscIcon(icon);
            }

            GUILayout.EndHorizontal();


            EditorGUILayout.Space();


            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showList = EditorGUILayout.Foldout(showList, "Show Perk List");
            EditorGUILayout.EndHorizontal();
            if (showList)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.Space();
                if (GUILayout.Button("EnableAll") && !Application.isPlaying)
                {
                    instance.unavailablePrefabIDList = new List <int>();
                }
                if (GUILayout.Button("DisableAll") && !Application.isPlaying)
                {
                    instance.unavailablePrefabIDList = PerkDB.GetPrefabIDList();
                }
                EditorGUILayout.Space();
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.Space();


                List <Perk> perkList = PerkDB.GetList();
                for (int i = 0; i < perkList.Count; i++)
                {
                    if (perkList[i].hideInInspector)
                    {
                        continue;
                    }

                    Perk perk = perkList[i];

                    GUILayout.BeginHorizontal();

                    EditorGUILayout.Space();

                    GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40));
                    TDE.DrawSprite(GUILayoutUtility.GetLastRect(), perk.icon, perk.desp, false);

                    GUILayout.BeginVertical();
                    EditorGUILayout.Space();
                    GUILayout.Label(perk.name, GUILayout.ExpandWidth(false));

                    GUILayout.BeginHorizontal();

                    float cachedL = EditorGUIUtility.labelWidth;      EditorGUIUtility.labelWidth = 80;
                    float cachedF = EditorGUIUtility.fieldWidth;      EditorGUIUtility.fieldWidth = 10;

                    EditorGUI.BeginChangeCheck();
                    bool flag = !instance.unavailablePrefabIDList.Contains(perk.prefabID) ? true : false;
                    flag = EditorGUILayout.Toggle(new GUIContent(" - enabled: ", "check to enable the perk in this level"), flag);

                    if (!Application.isPlaying && EditorGUI.EndChangeCheck())
                    {
                        if (!flag && !instance.unavailablePrefabIDList.Contains(perk.prefabID))
                        {
                            instance.unavailablePrefabIDList.Add(perk.prefabID);
                            instance.purchasedPrefabIDList.Remove(perk.prefabID);
                        }
                        else if (flag)
                        {
                            instance.unavailablePrefabIDList.Remove(perk.prefabID);
                        }
                    }

                    if (!instance.unavailablePrefabIDList.Contains(perk.prefabID))
                    {
                        EditorGUI.BeginChangeCheck();
                        flag = instance.purchasedPrefabIDList.Contains(perk.prefabID);
                        flag = EditorGUILayout.Toggle(new GUIContent(" - purchased: ", "check to set the perk as purchased right from the start"), flag);

                        if (!Application.isPlaying && EditorGUI.EndChangeCheck())
                        {
                            if (flag)
                            {
                                instance.purchasedPrefabIDList.Add(perk.prefabID);
                            }
                            else
                            {
                                instance.purchasedPrefabIDList.Remove(perk.prefabID);
                            }
                        }
                    }
                    else
                    {
                        EditorGUILayout.LabelField(" - purchased: ", "- ");
                    }

                    EditorGUIUtility.labelWidth = cachedL;    EditorGUIUtility.fieldWidth = cachedF;

                    GUILayout.EndHorizontal();

                    GUILayout.EndVertical();

                    GUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.Space();

            DefaultInspector();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
Exemplo n.º 5
0
    void GUIChangeConfig()
    {
        GUILayout.BeginVertical();
        //绘制标题
        GUILayout.Space(10);
        //是否开启添加配置信息
        ISChangeConfig = EditorGUILayout.Toggle("是否修改配置信息", ISChangeConfig);
        if (ISChangeConfig)
        {
            string SDKPluginspath = SDKPluginsPath.path;
            if (!Directory.Exists(SDKPluginspath))
            {
                this.ShowNotification(new GUIContent("暂无配置信息文件夹,以自动创建")); Directory.CreateDirectory(SDKPluginspath); return;
            }
            if (Directory.GetDirectories(SDKPluginspath).Length == 0)
            {
                this.ShowNotification(new GUIContent("暂无配置信息,请添加配置2")); return;
            }

            string[] SDKNames = Directory.GetDirectories(SDKPluginspath);
            GUILayout.Space(10);
            if (IsCanShowBtn)
            {
                for (int i = 0; i < SDKNames.Length; i++)
                {
                    if (GUILayout.Button(SDKNames[i], GUILayout.Width(20), GUILayout.ExpandWidth(true)))
                    {
                        IsCanShowBtn = false;
                        if (BuildToFolder == null)
                        {
                            ShowNotification(new GUIContent("请选择打包的路径")); return;
                        }
                        string           PluginsName = new DirectoryInfo(SDKNames[i]).Name; //找到plugins文件夹的名字
                        SavedPliginsPath PliginsPath = new SavedPliginsPath(PluginsName);
                        string           txt         = File.ReadAllText(PliginsPath.JsonPath, Encoding.UTF8);
                        ChangeProject = JsonUtility.FromJson <Project>(txt);
                    }
                }
            }
            else
            {
                if (ChangeProject != null)
                {
                    GUILayout.Label(ChangeProject.Name);
                    ChangeProject.ProjectName       = EditorGUILayout.TextField("软件名:", ChangeProject.ProjectName);
                    ChangeProject.IconName          = EditorGUILayout.TextField("Icon路径:", ChangeProject.IconName);
                    ChangeProject.PackageName       = EditorGUILayout.TextField("包名:", ChangeProject.PackageName);
                    ChangeProject.Version           = EditorGUILayout.TextField("版本:", ChangeProject.Version);
                    ChangeProject.BundleVersionCode = EditorGUILayout.TextField("bundleVersionCode:", ChangeProject.BundleVersionCode);

                    if (GUILayout.Button("保存配置信息", GUILayout.Height(20), GUILayout.Width(200)))
                    {
                        SavedPliginsPath path = new SavedPliginsPath(ChangeProject.Name);
                        if (File.Exists(path.JsonPath))
                        {
                            File.Delete(path.JsonPath);
                        }
                        AssetDatabase.Refresh();
                        AssetDatabase.SaveAssets();

                        string       str = ChangeProject.SaveToString();
                        StreamWriter sw  = new StreamWriter(path.JsonPath);
                        sw.WriteLine(str);
                        sw.Close();
                        AssetDatabase.Refresh();
                        AssetDatabase.SaveAssets();

                        string TitleTxt = UtilTHIS.ProjectToString(ChangeProject);
                        EditorUtility.DisplayDialog("配置信息更改完毕", TitleTxt, "确认");
                        ChangeProject  = null;
                        ISChangeConfig = false;
                    }
                }
            }
        }
        else
        {
            IsCanShowBtn = true;
        }
        GUILayout.EndVertical();
    }
Exemplo n.º 6
0
    static void OnHierarchyGUI(int instanceID, Rect selectionRect)
    {
        //get the gameObject reference using its instance ID
        GameObject go = (GameObject)EditorUtility.InstanceIDToObject(instanceID);

        //get rect m8
        Rect rect = new Rect(selectionRect);

        rect.x = rect.width;

        if (go == null)
        {
            return;
        }

        //Toggle
        if (EditorPrefs.GetInt(go.GetInstanceID() + "toggle", 0) == 1)
        {
            go.SetActive(GUI.Toggle(rect, go.activeInHierarchy, ""));
        }

        //UI marker
        if (EditorPrefs.GetInt(go.GetInstanceID() + "UI", 0) == 1)
        {
            rect.x                  = rect.width - 15;
            rect.width              = 15;
            rect.height             = rect.height - 2;
            style.normal.background = UITexture;
            GUI.Label(rect, "", style);
        }

        //Game Manager marker
        if (CheckInEditor(go, "G"))
        {
            rect.x                  = rect.width - 15;
            rect.width              = 15;
            rect.height             = rect.height - 2;
            style.normal.background = gameManagerTexture;
            GUI.Label(rect, "", style);
        }

        //Canvas marker
        if (CheckInEditor(go, "Can"))
        {
            rect.x                  = rect.width - 15;
            rect.width              = 15;
            rect.height             = rect.height - 2;
            style.normal.background = canvasTexture;
            GUI.Label(rect, "", style);
        }

        //Camera marker
        if (CheckInEditor(go, "Cam"))
        {
            rect.x                  = rect.width - 15;
            rect.width              = 15;
            rect.height             = rect.height - 2;
            style.normal.background = cameraTexture;
            GUI.Label(rect, "", style);
        }

        //Player marker
        if (CheckInEditor(go, "P"))
        {
            rect.x                  = rect.width - 15;
            rect.width              = 15;
            rect.height             = rect.height - 2;
            style.normal.background = playerTexture;
            GUI.Label(rect, "", style);
        }

        //Segment marker
        if (CheckInEditor(go, "S"))
        {
            rect.x                  = rect.width - 15;
            rect.width              = 15;
            rect.height             = rect.height - 2;
            style.normal.background = segmentTexture;
            GUI.Label(rect, "", style);
        }

        //Level Manager marker
        if (CheckInEditor(go, "L"))
        {
            rect.x                  = rect.width - 15;
            rect.width              = 15;
            rect.height             = rect.height - 2;
            style.normal.background = levelManagerTexture;
            GUI.Label(rect, "", style);
        }
    }
Exemplo n.º 7
0
    protected void EditMenuItem(CtxMenu.Item item, UIAtlas atlas)
    {
        if (item == null)
        {
            return;
        }

        GUILayoutOption[] itemSpriteOpt    = { GUILayout.Height(16f), GUILayout.Width(140f) };
        GUILayoutOption[] itemSpriteDelOpt = { GUILayout.Height(16f), GUILayout.Width(60f) };

        Color normalColor, disabledColor;

        Rect box = EditorGUILayout.BeginVertical();

        GUILayout.Space(4f);
        GUI.Box(box, "");

        EditorGUILayout.BeginHorizontal();
        item.isSelected = EditorGUILayout.Toggle(item.isSelected, GUILayout.Width(12f));

        EditorGUIUtility.labelWidth = 64f;
        CtxMenu.ItemStyle itemStyle = (CtxMenu.ItemStyle)EditorGUILayout.EnumFlagsField("Style", item.style,
                                                                                        GUILayout.Width(188f));

        if (item.style != itemStyle)
        {
            RegisterUndo();

            bool wasSubmenu = item.isSubmenu;

            item.style = itemStyle;

            if (item.isSubmenu && !wasSubmenu)
            {
                item.id = -1;
            }
        }

        if (item.isCheckable)
        {
            EditorGUIUtility.labelWidth = 44f;
            int mutexGroup = EditorGUILayout.IntField("Mutex", item.mutexGroup, GUILayout.Width(88f));
            if (mutexGroup != item.mutexGroup)
            {
                RegisterUndo();
                item.mutexGroup = mutexGroup;
            }
        }

        EditorGUIUtility.labelWidth = 80f;
        EditorGUILayout.EndHorizontal();

        if ((item.style & CtxMenu.ItemStyle.Separator) != (CtxMenu.ItemStyle) 0)
        {
            item.id = -1;
        }
        else
        {
            EditorGUILayout.BeginHorizontal();
            string text = EditorGUILayout.TextField("    Text", item.text, GUILayout.Width(204f));
            if (item.text != text)
            {
                RegisterUndo();
                item.text = text;
            }

            EditorGUIUtility.labelWidth = 32f;
            GUILayout.Space(12f);
            int itemId = EditorGUILayout.IntField("ID", item.id, GUILayout.Width(76f));
            if (item.id != itemId)
            {
                RegisterUndo();
                item.id = itemId;
            }
            EditorGUIUtility.labelWidth = 80f;

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("    Icon", GUILayout.Width(76f));

            string iconTitle = item.icon;
            if (string.IsNullOrEmpty(iconTitle))
            {
                iconTitle = "...";
            }

            if (GUILayout.Button(iconTitle, itemSpriteOpt))
            {
                currentItem        = item;
                NGUISettings.atlas = atlas;
                SpriteSelector.Show(OnItemIcon);
            }

            GUILayout.Space(12f);
            if (GUILayout.Button("None", itemSpriteDelOpt))
            {
                if (!string.IsNullOrEmpty(item.icon))
                {
                    RegisterUndo();
                }

                item.icon = "";
            }

            EditorGUILayout.EndHorizontal();

            if (!string.IsNullOrEmpty(item.icon))
            {
                EditorGUILayout.BeginHorizontal();
                normalColor = EditorGUILayout.ColorField("    Normal", item.spriteColor, GUILayout.Width(140f));
                if (normalColor != item.spriteColor)
                {
                    RegisterUndo();
                    item.spriteColor = normalColor;
                }
                GUILayout.Space(32f);
                disabledColor = EditorGUILayout.ColorField("Disabled", item.spriteColorDisabled, GUILayout.Width(140f));
                if (item.spriteColorDisabled != disabledColor)
                {
                    RegisterUndo();
                    item.spriteColorDisabled = disabledColor;
                }
                EditorGUILayout.EndHorizontal();
            }

            if (item.isSubmenu)
            {
                CtxMenu submenu = (CtxMenu)EditorGUILayout.ObjectField("    Submenu", item.submenu, typeof(CtxMenu), true, GUILayout.Width(317f));
                if (item.submenu != submenu)
                {
                    RegisterUndo();
                    item.submenu = submenu;

#if CTX_NO_SERIALIZATION_FIX
                    if (submenu.items == null || submenu.items.Length == 0)
                    {
                        Debug.Log("Wizzy Submenu Item Transfer Test!!!!");

                        if (item.submenuItems != null && item.submenuItems.Length > 0)
                        {
                            Debug.Log("Wizzy Submenu Item Transfer!!!!");
                            submenu.items     = item.submenuItems;
                            item.submenuItems = null;

                            EditorUtility.SetDirty(submenu);
                            EditorUtility.SetDirty(target);
                        }
                    }
#endif
                }

                if (submenu != null)
#if CTX_NO_SERIALIZATION_FIX
                { EditMenuItemList(ref item.submenuItems, submenu.atlas, false, ref item.isEditingItems); }
#else
                { EditMenuItemList(ref submenu.items, submenu.atlas, false, ref item.isEditingItems); }
#endif
            }
        }

        GUILayout.Space(4f);
        EditorGUILayout.EndVertical();
        GUILayout.Space(4f);
    }
Exemplo n.º 8
0
        internal static void OnHierarchyWindowItemOnGUI(int instanceID, Rect selectionRect)
        {
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                return;
            }

            var o = EditorUtility.InstanceIDToObject(instanceID) as GameObject;

            if (selectionRect.Contains(Event.current.mousePosition))
            {
                Transform t = (o == null) ? null : o.transform;
                SceneDragToolManager.OnHandleDragAndDrop(inSceneView: false, transformInInspector: t, selectionRect: selectionRect);
            }

            if (o == null)
            {
                return;
            }

            CSG_GUIStyleUtility.InitStyles();

            var node = o.GetComponent <CSGNode>();

            if (node == null ||
                !node.enabled || (node.hideFlags & (HideFlags.HideInHierarchy | HideFlags.HideInInspector)) != 0)
            {
                return;
            }

            CSGOperationType operationType = CSGOperationType.Additive;

            var brush = node as CSGBrush;

            if (brush != null)
            {
                operationType = brush.OperationType;
                var skin = CSG_GUIStyleUtility.Skin;
                GUI.Label(selectionRect, skin.hierarchyOperations[(int)operationType], CSG_GUIStyleUtility.rightAlignedLabel);
                return;
            }
            var operation = node as CSGOperation;

            if (operation != null)
            {
                var skin = CSG_GUIStyleUtility.Skin;
                if (!operation.PassThrough)
                {
                    operationType = operation.OperationType;
                    var operationTypeIndex = (int)operationType;
                    if (operationTypeIndex >= 0 && operationTypeIndex < skin.hierarchyOperations.Length)
                    {
                        GUI.Label(selectionRect, skin.hierarchyOperations[operationTypeIndex], CSG_GUIStyleUtility.rightAlignedLabel);
                    }
                }
                else
                {
                    GUI.Label(selectionRect, skin.hierarchyPassThrough, CSG_GUIStyleUtility.rightAlignedLabel);
                }
                return;
            }
        }
Exemplo n.º 9
0
    public void editorCreateNodes()
    {
        unsortedNodes = new List <GameObject>();

        int  gridX = 0, gridY = 0;
        int  boundX = 0, boundY = 0;
        bool foundTileOnLastPass = false;

        for (int x = scanStartX; x < scanFinishX; x++)
        {
            for (int y = scanStartY; y < scanFinishY; y++)
            {
                Vector3Int pos = new Vector3Int(x, y, 0);
                TileBase   tb  = floor.GetTile(floor.WorldToCell(pos));

                if (tb == null)
                {
                    if (foundTileOnLastPass == true)
                    {
                        gridY++;
                        if (gridX > boundX)
                        {
                            boundX = gridX;
                        }

                        if (gridY > boundY)
                        {
                            boundY = gridY;
                        }
                    }
                }
                else
                {
                    bool foundObstacle = false;
                    foreach (Tilemap t in obstacleLayers)
                    {
                        TileBase tb2 = t.GetTile(t.WorldToCell(pos));
                        if (tb2 == null)
                        {
                        }
                        else
                        {
                            foundObstacle = true;
                        }
                    }



                    if (foundObstacle == true)
                    {
                        GameObject node = (GameObject)Instantiate(nodePrefab, new Vector3(x + 0.5f + gridBase.transform.position.x, y + 0.5f + gridBase.transform.position.y, 0), Quaternion.Euler(0, 0, 0));
                        //we add the gridBase position to ensure that the nodes are ontop of the tile they relate too
                        node.GetComponent <SpriteRenderer>().color = Color.red;
                        WorldTile wt = node.GetComponent <WorldTile>();
                        wt.gridX    = gridX;
                        wt.gridY    = gridY;
                        wt.walkable = false;
                        wt.modifier = 1000;

                        foundTileOnLastPass = true;
                        unsortedNodes.Add(node);
                        node.name             = "UNWALKABLE NODE " + gridX.ToString() + " : " + gridY.ToString();
                        node.transform.parent = this.transform;
                    }
                    else
                    {
                        int weight = 10;
                        foreach (Tilemap t in weightIncreaseLayers)
                        {
                            TileBase tb2 = t.GetTile(new Vector3Int(x, y, 0));

                            if (tb2 == null)
                            {
                            }
                            else
                            {
                                weight += 150;
                            }
                        }
                        GameObject node = (GameObject)Instantiate(nodePrefab, new Vector3(x + 0.5f + gridBase.transform.position.x, y + 0.5f + gridBase.transform.position.y, 0), Quaternion.Euler(0, 0, 0));
                        WorldTile  wt   = node.GetComponent <WorldTile>();
                        wt.gridX            = gridX;
                        wt.gridY            = gridY;
                        foundTileOnLastPass = true; //say that we have found a tile so we know to increment the index counters
                        unsortedNodes.Add(node);
                        wt.modifier = weight;

                        node.name             = "NODE " + gridX.ToString() + " : " + gridY.ToString();
                        node.transform.parent = this.transform;
                    }

                    gridY++;
                    if (gridX > boundX)
                    {
                        boundX = gridX;
                    }

                    if (gridY > boundY)
                    {
                        boundY = gridY;
                    }
                }
            }

            if (foundTileOnLastPass == true)
            {
                gridX++;
                gridY = 0;
                foundTileOnLastPass = false;
            }
        }

        nodes      = new GameObject[boundX + 1, boundY + 1];
        gridBoundX = boundX + 1;
        gridBoundY = boundY + 1;
        //Debug.LogError("Grid length is " + (boundX + 1).ToString() + " :: " + (boundY + 1).ToString());

        foreach (GameObject g in unsortedNodes)
        {
            WorldTile wt = g.GetComponent <WorldTile>();
            nodes[wt.gridX, wt.gridY] = g;
        }

        foreach (GameObject g in unsortedNodes)
        {
            WorldTile        wt        = g.GetComponent <WorldTile>();
            List <WorldTile> neigbours = new List <WorldTile>();
            foreach (GameObject g2 in unsortedNodes)
            {
                if (g2 == g)
                {
                    continue;
                }

                float d = Vector2.Distance(g.transform.position, g2.transform.position);
                if (d < 1.1f)
                {
                    neigbours.Add(g2.GetComponent <WorldTile>());
                }
            }
            wt.myNeighbours = neigbours;
            EditorUtility.SetDirty(wt);
        }
        EditorUtility.SetDirty(this);
    }
Exemplo n.º 10
0
    private void CreateTexture()
    {
        string texturePath = string.Format("Assets/{0}.png", textureFilename);

        Texture2D texture = new Texture2D(textureWidth, textureHeight);

        File.WriteAllBytes(texturePath, texture.EncodeToPNG());
        AssetDatabase.Refresh();
        TextureImporter textureImporter = AssetImporter.GetAtPath(texturePath) as TextureImporter;

        if (textureImporter != null)
        {
            textureImporter.mipmapEnabled = false;
            textureImporter.isReadable    = true;
#if !UNITY_5_5P
            textureImporter.textureFormat = TextureImporterFormat.RGB24;
#endif
            textureImporter.maxTextureSize = Mathf.Max(textureWidth, textureHeight);

            OnlineMapsControlBase control = api.GetComponent <OnlineMapsControlBase>();
            if (control is OnlineMapsUIImageControl || control is OnlineMapsSpriteRendererControl)
            {
                textureImporter.spriteImportMode = SpriteImportMode.Single;
                textureImporter.npotScale        = TextureImporterNPOTScale.None;
            }

            AssetDatabase.ImportAsset(texturePath, ImportAssetOptions.ForceUpdate);
            Texture2D newTexture = AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D)) as Texture2D;
            pTexture.objectReferenceValue = newTexture;

            if (control is OnlineMapsSpriteRendererControl)
            {
                SpriteRenderer spriteRenderer = api.GetComponent <SpriteRenderer>();
                spriteRenderer.sprite = AssetDatabase.LoadAssetAtPath(texturePath, typeof(Sprite)) as Sprite;
            }
            else if (control is OnlineMapsGUITextureControl)
            {
                GUITexture gt = api.GetComponent <GUITexture>();
                gt.texture = newTexture;
            }
            else if (control is OnlineMapsUIImageControl)
            {
                Image img = api.GetComponent <Image>();
                img.sprite = AssetDatabase.LoadAssetAtPath(texturePath, typeof(Sprite)) as Sprite;
            }
            else if (control is OnlineMapsUIRawImageControl)
            {
                RawImage img = api.GetComponent <RawImage>();
                img.texture = newTexture;
            }
            else if (control is OnlineMapsTextureControl)
            {
                Renderer renderer = api.GetComponent <Renderer>();
                renderer.sharedMaterial.mainTexture = texture;
            }
            else if (control is OnlineMapsNGUITextureControl)
            {
#if NGUI
                UITexture uiTexture = api.GetComponent <UITexture>();
                uiTexture.mainTexture = newTexture;
#endif
            }
        }

        OnlineMapsUtils.DestroyImmediate(texture);

#if !UNITY_5_0P
        EditorUtility.UnloadUnusedAssets();
#else
        EditorUtility.UnloadUnusedAssetsImmediate();
#endif
    }
    private void Tab_DrawPreSetup()
    {
        FGUI_Inspector.VSpace(-2, -4);
        GUILayout.BeginVertical(FGUI_Resources.ViewBoxStyle);

        GUILayout.Space(7f);
        GUI.color = new Color(1f, 1f, 1f, 0.7f); EditorGUILayout.LabelField(Lang("Select right bones of your model"), FGUI_Resources.HeaderStyle); GUI.color = c;

        EditorGUIUtility.labelWidth = 42f;
        if (startBone == null)
        {
            TryFindStartBone();
        }
        if (endBone == null)
        {
            TryFindEndBone();
        }

        if (startBone != null && endBone != null)
        {
            if (!IsChildOf(endBone, startBone))
            {
                EditorGUILayout.HelpBox("! '" + startBone.name + "' is not child of '" + endBone.name + "' !", MessageType.Error);
            }
        }

        GUILayout.Space(12f);

        // START CHAIN BONE
        EditorGUILayout.BeginHorizontal();
        startBone = (Transform)EditorGUILayout.ObjectField(new GUIContent("Start", "Put here first bone in hierarchy depth for automatically get chain of bones to end one"), startBone, typeof(Transform), true);

        // Select bone button
        if (largestSkin)
        {
            El_DrawBoneSelectionButton(true, ref Get._gizmosEditorStartPreview, Get.GetBaseTransform());
        }

        // Go left / right in hierarchy icon
        if (startBone != null)
        {
            if (GUILayout.Button(new GUIContent("◄", "Get Parent Bone Of Current Selected"), FGUI_Resources.ButtonStyle, new GUILayoutOption[2] {
                GUILayout.Width(20), GUILayout.Height(16)
            }))
            {
                startBone = startBone.parent; EditorGUIUtility.PingObject(startBone);
            }

            if (startBone)
            {
                if (startBone.childCount > 0)
                {
                    if (GUILayout.Button(new GUIContent("►", "Get Child Bone Of Current Selected"), FGUI_Resources.ButtonStyle, new GUILayoutOption[2] {
                        GUILayout.Width(20), GUILayout.Height(16)
                    }))
                    {
                        startBone = startBone.GetChild(0); EditorGUIUtility.PingObject(startBone);
                    }
                }
            }
        }

        GUI.enabled = false; EditorGUILayout.LabelField(new GUIContent("(Pelvis + legs)", "Start bone should be pelvis bone which's children are legs"), GUILayout.Width(91)); GUI.enabled = true;

        EditorGUILayout.EndHorizontal();


        // MIDDLE SPINE CHAIN ICON
        GUILayout.Space(7f);
        if (GUILayout.Button(new GUIContent(_TexSpineWideIcon, skins.Count > 0 ? "Click to toggle meshes visibility" : ""), FGUI_Resources.HeaderStyle, GUILayout.Height(24)))
        {
            hideSkin = !hideSkin;

            // Switching mesh visibility if can
            if (hideSkin)
            {
                for (int i = 0; i < skins.Count; i++)
                {
                    skins[i].shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly;
                }
            }
            else
            {
                for (int i = 0; i < skins.Count; i++)
                {
                    skins[i].shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
                }
            }
        }
        //EditorGUILayout.LabelField(new GUIContent(_TexSpineWideIcon), FGUI_Resources.HeaderStyle, GUILayout.Height(24));
        GUILayout.Space(10f);


        // END CHAIN BONE
        EditorGUILayout.BeginHorizontal();
        endBone = (Transform)EditorGUILayout.ObjectField(new GUIContent("End", "Put here last bone in hierarchy depth for automatically get chain of bones from start one"), endBone, typeof(Transform), true);

        // Select bone button
        if (largestSkin)
        {
            El_DrawBoneSelectionButton(false, ref Get._gizmosEditorEndPreview, startBone);
        }

        // Go left / right in hierarchy icon
        if (endBone != null)
        {
            if (startBone != null)
            {
                if (endBone.childCount > 0)
                {
                    if (GUILayout.Button(new GUIContent("L"), FGUI_Resources.ButtonStyle, new GUILayoutOption[2] {
                        GUILayout.Width(20), GUILayout.Height(16)
                    }))
                    {
                        endBone = GetLastChild(startBone); EditorGUIUtility.PingObject(endBone);
                    }
                }
            }


            if (GUILayout.Button(new GUIContent("◄", "Get Parent Bone Of Current Selected"), FGUI_Resources.ButtonStyle, new GUILayoutOption[2] {
                GUILayout.Width(20), GUILayout.Height(16)
            }))
            {
                endBone = endBone.parent; EditorGUIUtility.PingObject(endBone);
            }


            if (endBone)
            {
                if (endBone.childCount > 0)
                {
                    if (GUILayout.Button(new GUIContent("►", "Get Child Bone Of Current Selected"), FGUI_Resources.ButtonStyle, new GUILayoutOption[2] {
                        GUILayout.Width(20), GUILayout.Height(16)
                    }))
                    {
                        endBone = endBone.GetChild(0); EditorGUIUtility.PingObject(endBone);
                    }
                }
            }
        }
        else
        {
            if (startBone != null)
            {
                if (GUILayout.Button(new GUIContent("L"), FGUI_Resources.ButtonStyle, new GUILayoutOption[2] {
                    GUILayout.Width(20), GUILayout.Height(16)
                }))
                {
                    endBone = GetLastChild(startBone); EditorGUIUtility.PingObject(endBone);
                }
            }
        }

        GUI.enabled = false; EditorGUILayout.LabelField(new GUIContent("(Neck/Head/Chest)", "End bone should be head/neck/chest bone of your model - depends what motion you want to achieve"), GUILayout.Width(120)); GUI.enabled = true;

        EditorGUILayout.EndHorizontal();



        GUILayout.Space(12f);

        if (startBone == null || endBone == null)
        {
            GUI.enabled = false;
        }

        if (GUILayout.Button(new GUIContent(Lang("Create Spine Chain") + " (Get Bones)")))
        {
            if (!IsChildOf(endBone, startBone))
            {
                Debug.LogError("! '" + startBone.name + "' is not child of '" + endBone.name + "' !");
            }
            else
            {
                Get.CreateSpineChain(Get._gizmosEditorStartPreview, Get._gizmosEditorEndPreview);
                EditorUtility.SetDirty(target);
            }

            if (Application.isPlaying)
            {
                Get.Init();
            }
        }

        GUI.enabled = true;

        GUILayout.Space(3f);
        EditorGUILayout.HelpBox(Lang("Lang_SpineCreateInfo"), MessageType.Info);
        //EditorGUILayout.HelpBox("After creating spine chain you will unlock rest of the parameters (You will be able to adjust it again after that)", MessageType.Info);

        GUILayout.EndVertical();
    }
Exemplo n.º 12
0
    public override void OnInspectorGUI()
    {
        DrawToolbarGUI();

        serializedObject.Update();

        bool dirty = DrawGeneralGUI();

        EditorGUILayout.BeginVertical(GUI.skin.box);
        showMarkers = Foldout(showMarkers, string.Format("2D Markers (Count: {0})", pMarkers.arraySize));
        if (showMarkers)
        {
            DrawMarkersGUI(ref dirty);
        }
        EditorGUILayout.EndVertical();

        if (pTarget.enumValueIndex == (int)OnlineMapsTarget.texture)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            showCreateTexture = Foldout(showCreateTexture, "Create texture");
            if (showCreateTexture)
            {
                DrawCreateTextureGUI(ref dirty);
            }
            EditorGUILayout.EndVertical();
        }

        EditorGUILayout.BeginVertical(GUI.skin.box);
        showAdvanced = Foldout(showAdvanced, "Advanced");
        if (showAdvanced)
        {
            DrawAdvancedGUI();
        }
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical(GUI.skin.box);
        showTroubleshooting = Foldout(showTroubleshooting, "Troubleshooting");
        if (showTroubleshooting)
        {
            DrawTroubleshootingGUI(ref dirty);
        }
        EditorGUILayout.EndVertical();

        CheckNullControl();
#if UNITY_WEBPLAYER
        CheckJSLoader();
#endif

        serializedObject.ApplyModifiedProperties();

        if (dirty)
        {
            EditorUtility.SetDirty(api);
            if (!Application.isPlaying)
            {
#if UNITY_5_3P
                EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
#endif
            }
            else
            {
                api.Redraw();
            }
        }
    }
Exemplo n.º 13
0
        public override void ActionAnimGUI(ActionAnim action, List <ActionParameter> parameters)
        {
                        #if UNITY_EDITOR
            action.method = (AnimMethod)EditorGUILayout.EnumPopup("Method:", action.method);

            if (action.method == AnimMethod.PlayCustom || action.method == AnimMethod.StopCustom)
            {
                action.parameterID = Action.ChooseParameterGUI("Object:", parameters, action.parameterID, ParameterType.GameObject);
                if (action.parameterID >= 0)
                {
                    action.constantID = 0;
                    action._anim      = null;
                }
                else
                {
                    action._anim = (Animation)EditorGUILayout.ObjectField("Object:", action._anim, typeof(Animation), true);

                    action.constantID = action.FieldToID <Animation> (action._anim, action.constantID);
                    action._anim      = action.IDToField <Animation> (action._anim, action.constantID, false);
                }

                action.clip = (AnimationClip)EditorGUILayout.ObjectField("Clip:", action.clip, typeof(AnimationClip), true);

                if (action.method == AnimMethod.PlayCustom)
                {
                    action.playMode  = (AnimPlayMode)EditorGUILayout.EnumPopup("Play mode:", action.playMode);
                    action.blendMode = (AnimationBlendMode)EditorGUILayout.EnumPopup("Blend mode:", action.blendMode);
                }

                action.fadeTime = EditorGUILayout.Slider("Transition time:", action.fadeTime, 0f, 1f);
            }
            else if (action.method == AnimMethod.BlendShape)
            {
                action.isPlayer = EditorGUILayout.Toggle("Is player?", action.isPlayer);
                if (!action.isPlayer)
                {
                    action.parameterID = Action.ChooseParameterGUI("Object:", parameters, action.parameterID, ParameterType.GameObject);
                    if (action.parameterID >= 0)
                    {
                        action.constantID  = 0;
                        action.shapeObject = null;
                    }
                    else
                    {
                        action.shapeObject = (Shapeable)EditorGUILayout.ObjectField("Object:", action.shapeObject, typeof(Shapeable), true);

                        action.constantID  = action.FieldToID <Shapeable> (action.shapeObject, action.constantID);
                        action.shapeObject = action.IDToField <Shapeable> (action.shapeObject, action.constantID, false);
                    }
                }

                action.shapeKey   = EditorGUILayout.IntField("Shape key:", action.shapeKey);
                action.shapeValue = EditorGUILayout.Slider("Shape value:", action.shapeValue, 0f, 100f);
                action.fadeTime   = EditorGUILayout.Slider("Transition time:", action.fadeTime, 0f, 2f);
            }

            action.willWait = EditorGUILayout.Toggle("Wait until finish?", action.willWait);

            if (GUI.changed)
            {
                EditorUtility.SetDirty(action);
            }
                        #endif
        }
Exemplo n.º 14
0
        public override void CharSettingsGUI()
        {
                        #if UNITY_EDITOR
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Standard 3D animations:", EditorStyles.boldLabel);

            if (AdvGame.GetReferences() && AdvGame.GetReferences().settingsManager&& AdvGame.GetReferences().settingsManager.IsTopDown())
            {
                character.spriteChild = (Transform)EditorGUILayout.ObjectField("Animation child:", character.spriteChild, typeof(Transform), true);
            }
            else
            {
                character.spriteChild = null;
            }

            character.talkingAnimation = (TalkingAnimation)EditorGUILayout.EnumPopup("Talk animation style:", character.talkingAnimation);
            character.idleAnim         = (AnimationClip)EditorGUILayout.ObjectField("Idle:", character.idleAnim, typeof(AnimationClip), false);
            character.walkAnim         = (AnimationClip)EditorGUILayout.ObjectField("Walk:", character.walkAnim, typeof(AnimationClip), false);
            character.runAnim          = (AnimationClip)EditorGUILayout.ObjectField("Run:", character.runAnim, typeof(AnimationClip), false);
            if (character.talkingAnimation == TalkingAnimation.Standard)
            {
                character.talkAnim = (AnimationClip)EditorGUILayout.ObjectField("Talk:", character.talkAnim, typeof(AnimationClip), false);
            }

            if (AdvGame.GetReferences() && AdvGame.GetReferences().speechManager)
            {
                if (AdvGame.GetReferences() && AdvGame.GetReferences().speechManager&&
                    AdvGame.GetReferences().speechManager.lipSyncMode != LipSyncMode.Off && AdvGame.GetReferences().speechManager.lipSyncMode != LipSyncMode.FaceFX)
                {
                    if (AdvGame.GetReferences().speechManager.lipSyncOutput == LipSyncOutput.PortraitAndGameObject)
                    {
                        if (character.GetShapeable())
                        {
                            character.lipSyncGroupID = ActionBlendShape.ShapeableGroupGUI("Phoneme shape group:", character.GetShapeable().shapeGroups, character.lipSyncGroupID);
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("Attach a Shapeable script to show phoneme options", MessageType.Info);
                        }
                    }
                    else if (AdvGame.GetReferences().speechManager.lipSyncOutput == LipSyncOutput.GameObjectTexture)
                    {
                        if (character.GetComponent <LipSyncTexture>() == null)
                        {
                            EditorGUILayout.HelpBox("Attach a LipSyncTexture script to allow texture lip-syncing.", MessageType.Info);
                        }
                    }
                }
            }

            character.turnLeftAnim      = (AnimationClip)EditorGUILayout.ObjectField("Turn left:", character.turnLeftAnim, typeof(AnimationClip), false);
            character.turnRightAnim     = (AnimationClip)EditorGUILayout.ObjectField("Turn right:", character.turnRightAnim, typeof(AnimationClip), false);
            character.headLookLeftAnim  = (AnimationClip)EditorGUILayout.ObjectField("Head look left:", character.headLookLeftAnim, typeof(AnimationClip), false);
            character.headLookRightAnim = (AnimationClip)EditorGUILayout.ObjectField("Head look right:", character.headLookRightAnim, typeof(AnimationClip), false);
            character.headLookUpAnim    = (AnimationClip)EditorGUILayout.ObjectField("Head look up:", character.headLookUpAnim, typeof(AnimationClip), false);
            character.headLookDownAnim  = (AnimationClip)EditorGUILayout.ObjectField("Head look down:", character.headLookDownAnim, typeof(AnimationClip), false);
            character.headTurnSpeed     = EditorGUILayout.Slider("Head turn speed:", character.headTurnSpeed, 0.1f, 20f);
            if (character is Player)
            {
                Player player = (Player)character;
                player.jumpAnim = (AnimationClip)EditorGUILayout.ObjectField("Jump:", player.jumpAnim, typeof(AnimationClip), false);
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Bone transforms:", EditorStyles.boldLabel);

            character.upperBodyBone = (Transform)EditorGUILayout.ObjectField("Upper body:", character.upperBodyBone, typeof(Transform), true);
            character.neckBone      = (Transform)EditorGUILayout.ObjectField("Neck bone:", character.neckBone, typeof(Transform), true);
            character.leftArmBone   = (Transform)EditorGUILayout.ObjectField("Left arm:", character.leftArmBone, typeof(Transform), true);
            character.rightArmBone  = (Transform)EditorGUILayout.ObjectField("Right arm:", character.rightArmBone, typeof(Transform), true);
            character.leftHandBone  = (Transform)EditorGUILayout.ObjectField("Left hand:", character.leftHandBone, typeof(Transform), true);
            character.rightHandBone = (Transform)EditorGUILayout.ObjectField("Right hand:", character.rightHandBone, typeof(Transform), true);
            EditorGUILayout.EndVertical();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(character);
            }
                        #endif
        }
Exemplo n.º 15
0
    void OnGUI()
    {
        if (window == null)
        {
            Init();
        }

        Undo.SetSnapshotTarget(this, "ResourceEditor");

        //~ if(towerList.Count%2==0) GUI.color=new Color(.8f, .8f, .8f, 1);
        //~ else GUI.color=Color.white;
        //~ GUI.Box(new Rect(5, 75+towerList.Count*49, window.position.width-10, 50), "");
        //~ GUI.color=Color.white;
        EditorGUI.LabelField(new Rect(5, 10, 150, 17), "Add new creep:");
        newCreep = (UnitCreep)EditorGUI.ObjectField(new Rect(100, 10, 160, 17), newCreep, typeof(UnitCreep), false);
        if (newCreep != null)
        {
            if (!creepList.Contains(newCreep))
            {
                //~ if(!towerIDList.Contains(newTower.specialID)) towerIDList.Add(newTower.specialID);
                //~ else{
                int rand = 0;
                while (creepIDList.Contains(rand))
                {
                    rand += 1;
                }
                creepIDList.Add(rand);
                newCreep.prefabID = rand;
                //~ }
                creepList.Add(newCreep);
                if (onCreepUpdateE != null)
                {
                    onCreepUpdateE();
                }
            }
            newCreep = null;
        }


        //~ if(GUI.Button(new Rect(window.position.width-85, 10, 80, 30), "Save")){
        //~ warning="Refresh ResourceManager in each scene for the new \nchange to take effect!";
        //~ SaveToXML();
        //~ }

        //~ if(GUI.Button(new Rect(10, 10, 100, 30), "New Resource")){
        //~ UpdateWarning();
        //~ towerList.Add(new UnitTower());
        //~ }

        if (creepList.Count > 0)
        {
            GUI.Box(new Rect(5, 40, 50, 20), "ID");
            GUI.Box(new Rect(5 + 50 - 1, 40, 60 + 1, 20), "Icon");
            GUI.Box(new Rect(5 + 110 - 1, 40, 160 + 2, 20), "Name");
            GUI.Box(new Rect(5 + 270, 40, window.position.width - 300, 20), "");
        }

        scrollPos = GUI.BeginScrollView(new Rect(5, 60, window.position.width - 12, window.position.height - 50), scrollPos, new Rect(5, 55, window.position.width - 30, 15 + ((creepList.Count)) * 50));

        int row = 0;

        for (int i = 0; i < creepList.Count; i++)
        {
            if (i % 2 == 0)
            {
                GUI.color = new Color(.8f, .8f, .8f, 1);
            }
            else
            {
                GUI.color = Color.white;
            }
            GUI.Box(new Rect(5, 60 + i * 49, window.position.width - 30, 50), "");
            GUI.color = Color.white;

            //~ GUI.Label(new Rect(22, 15+60+i*49, 50, 20), creepList[i].prefabID.ToString());
            if (currentSwapID == i)
            {
                GUI.color = new Color(.9f, .9f, .0f, 1);
            }
            if (GUI.Button(new Rect(19, 12 + 60 + i * 49, 30, 30), creepList[i].prefabID.ToString()))
            {
                if (currentSwapID == i)
                {
                    currentSwapID = -1;
                }
                else if (currentSwapID == -1)
                {
                    currentSwapID = i;
                }
                else
                {
                    SwapCreep(i);
                }
            }
            if (currentSwapID == i)
            {
                GUI.color = Color.white;
            }

            if (creepList[i] != null)
            {
                creepList[i].icon = (Texture)EditorGUI.ObjectField(new Rect(12 + 50, 3 + 60 + i * 49, 44, 44), creepList[i].icon, typeof(Texture), false);

                creepList[i].unitName = EditorGUI.TextField(new Rect(5 + 120, 6 + 60 + i * 49, 150, 17), creepList[i].unitName);

                //~ EditorGUI.LabelField(new Rect(5+120, 10+60+i*49+18, 150, 17), " - "+creepList[i].type.ToString());
                //~ towerList[i]=(UnitTower)EditorGUI.ObjectField(new Rect(5+120, 10+75+i*49+18, 150, 17), towerList[i], typeof(UnitTower), false);
            }
            else
            {
                //~ towerList[i]=(UnitTower)EditorGUI.ObjectField(new Rect(5+120, 15+75+i*49, 150, 17), towerList[i], typeof(UnitTower), false);
                //~ towerIDList.Remove(towerList[i].specialID);
                //~ towerList.RemoveAt(i);
                //~ delete=-1;
                //~ if(onTowerUpdateE!=null) onTowerUpdateE();
            }

            if (delete != i)
            {
                if (GUI.Button(new Rect(window.position.width - 55, 12 + 60 + i * 49, 25, 25), "X"))
                {
                    delete = i;
                }
            }
            else
            {
                GUI.color = Color.red;
                if (GUI.Button(new Rect(window.position.width - 90, 12 + 60 + i * 49, 60, 25), "Remove"))
                {
                    if (currentSwapID == i)
                    {
                        currentSwapID = -1;
                    }
                    creepIDList.Remove(creepList[i].prefabID);
                    creepList.RemoveAt(i);
                    delete = -1;
                    if (onCreepUpdateE != null)
                    {
                        onCreepUpdateE();
                    }
                }
                GUI.color = Color.white;
            }

            row += 1;
        }


        GUI.EndScrollView();
        //~ GUI.Label(new Rect(5, window.position.height-55, window.position.width-10, 55), warning);

        if (GUI.changed)
        {
            EditorUtility.SetDirty(prefab);
            for (int i = 0; i < creepList.Count; i++)
            {
                EditorUtility.SetDirty(creepList[i]);
            }
        }


        if (GUI.changed)
        {
            //~ EditorUtility.SetDirty(this);
            Undo.CreateSnapshot();
            Undo.RegisterSnapshot();
        }
        Undo.ClearSnapshotTarget();
    }
        protected static void CheckForUpdates()
        {
            const string url = "https://github.com/GlitchEnzo/NuGetForUnity/releases";

#if UNITY_2017_1_OR_NEWER // UnityWebRequest is not available in Unity 5.2, which is the currently the earliest version supported by NuGetForUnity.
            using (UnityWebRequest request = UnityWebRequest.Get(url))
            {
                request.SendWebRequest();
#else
            using (WWW request = new WWW(url))
            {
#endif

                NugetHelper.LogVerbose("HTTP GET {0}", url);
                while (!request.isDone)
                {
                    EditorUtility.DisplayProgressBar("Checking updates", null, 0.0f);
                }
                EditorUtility.ClearProgressBar();

                string latestVersion            = null;
                string latestVersionDownloadUrl = null;

                string response = null;
#if UNITY_2017_1_OR_NEWER
                if (!request.isNetworkError && !request.isHttpError)
                {
                    response = request.downloadHandler.text;
                }
#else
                if (request.error == null)
                {
                    response = request.text;
                }
#endif

                if (response != null)
                {
                    latestVersion = GetLatestVersonFromReleasesHtml(response, out latestVersionDownloadUrl);
                }

                if (latestVersion == null)
                {
                    EditorUtility.DisplayDialog(
                        "Unable to Determine Updates",
                        string.Format("Couldn't find release information at {0}.", url),
                        "OK");
                    return;
                }

                NugetPackageIdentifier current = new NugetPackageIdentifier("NuGetForUnity", NugetPreferences.NuGetForUnityVersion);
                NugetPackageIdentifier latest  = new NugetPackageIdentifier("NuGetForUnity", latestVersion);
                if (current >= latest)
                {
                    EditorUtility.DisplayDialog(
                        "No Updates Available",
                        string.Format("Your version of NuGetForUnity is up to date.\nVersion {0}.", NugetPreferences.NuGetForUnityVersion),
                        "OK");
                    return;
                }

                // New version is available. Give user options for installing it.
                switch (EditorUtility.DisplayDialogComplex(
                            "Update Available",
                            string.Format("Current Version: {0}\nLatest Version: {1}", NugetPreferences.NuGetForUnityVersion, latestVersion),
                            "Install Latest",
                            "Open Releases Page",
                            "Cancel"))
                {
                case 0: Application.OpenURL(latestVersionDownloadUrl); break;

                case 1: Application.OpenURL(url); break;

                case 2: break;
                }
            }
        }
Exemplo n.º 17
0
 private void OnFail(PushStatusError error)
 {
     EditorUtility.DisplayDialog("Error while pushing", error.Message, "Ok");
 }
Exemplo n.º 18
0
        private void Generate()
        {
            var type = types[selectedType].type;

            if (type == null)
            {
                EditorUtility.DisplayDialog("Type not selected", "Type not selected. Please ensure you select a type", "Ok");
                return;
            }

            unsavedChanges = false;

            // Get the serializable fields of this class.
            //var fields = ES3Reflection.GetSerializableES3Fields(type);

            // The string that we suffix to the class name. i.e. UnityEngine_UnityEngine_Transform.
            string es3TypeSuffix = type.Name;
            // The string for the full C#-safe type name. This name must be suitable for going inside typeof().
            string fullType = GetFullTypeName(type);
            // The list of WriteProperty calls to write the properties of this type.
            string writes = GenerateWrites();
            // The list of case statements and Read calls to read the properties of this type.
            string reads = GenerateReads();
            // A comma-seperated string of fields we've supported in this type.
            string propertyNames = "";

            bool first = true;

            for (int i = 0; i < fields.Length; i++)
            {
                if (!fieldSelected[i])
                {
                    continue;
                }

                if (first)
                {
                    first = false;
                }
                else
                {
                    propertyNames += ", ";
                }
                propertyNames += "\"" + fields[i].Name + "\"";
            }

            var easySaveEditorPath = ES3Settings.PathToEasySaveFolder() + "Editor/";

            // Insert the relevant strings into the template.
            string template;

            if (typeof(Component).IsAssignableFrom(type))
            {
                template = File.ReadAllText(easySaveEditorPath + componentTemplateFile);
            }
            else if (ES3Reflection.IsValueType(type))
            {
                template = File.ReadAllText(easySaveEditorPath + valueTemplateFile);
            }
            else if (typeof(ScriptableObject).IsAssignableFrom(type))
            {
                template = File.ReadAllText(easySaveEditorPath + scriptableObjectTemplateFile);
            }
            else
            {
                template = File.ReadAllText(easySaveEditorPath + classTemplateFile);
            }
            template = template.Replace("[es3TypeSuffix]", es3TypeSuffix);
            template = template.Replace("[fullType]", fullType);
            template = template.Replace("[writes]", writes);
            template = template.Replace("[reads]", reads);
            template = template.Replace("[propertyNames]", propertyNames);

            // Create the output file.


            string outputFilePath = GetOutputPath(type);
            var    fileInfo       = new FileInfo(outputFilePath);

            fileInfo.Directory.Create();
            File.WriteAllText(outputFilePath, template);
            AssetDatabase.Refresh();
        }
        //---------------------------------------
        // Sound.
        //---------------------------------------

        #if ENABLE_CRIWARE_ADX
        private void DrawSoundAssetConfigGUI(CriAssetConfig instance)
        {
            var acfAssetSourcePathProperty = serializedObject.FindProperty("acfAssetSourceFullPath");
            var acfAssetExportPathProperty = serializedObject.FindProperty("acfAssetExportPath");

            if (EditorLayoutTools.DrawHeader("Sound", "CriAssetConfigInspector-Sound"))
            {
                using (new ContentsScope())
                {
                    var change = DrawAssetImportInfoGUI(instance.SoundImportInfo);

                    if (change)
                    {
                        UnityEditorUtility.RegisterUndo("CriAssetConfigInspector Undo", instance);
                    }

                    // Style.
                    var pathTextStyle = GUI.skin.GetStyle("TextArea");
                    pathTextStyle.alignment = TextAnchor.MiddleLeft;

                    GUILayout.Label("AcfAssetSourcePath");

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        GUILayout.Label(acfAssetSourcePathProperty.stringValue, pathTextStyle);

                        if (GUILayout.Button("Edit", EditorStyles.miniButton, GUILayout.Width(50f)))
                        {
                            UnityEditorUtility.RegisterUndo("CriAssetConfigInspector Undo", instance);

                            var acfAssetSource = EditorUtility.OpenFilePanel("Select ACF", "", "");

                            var assetFolderUri = new Uri(Application.dataPath);
                            var targetUri      = new Uri(acfAssetSource);
                            acfAssetSourcePathProperty.stringValue = assetFolderUri.MakeRelativeUri(targetUri).ToString();

                            serializedObject.ApplyModifiedProperties();
                        }
                    }

                    GUILayout.Label("AcfAssetExportPath");

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        GUILayout.Label(acfAssetExportPathProperty.stringValue, pathTextStyle);

                        if (GUILayout.Button("Edit", EditorStyles.miniButton, GUILayout.Width(50f)))
                        {
                            UnityEditorUtility.RegisterUndo("CriAssetConfigInspector Undo", instance);

                            var acfAssetDirectory = EditorUtility.OpenFolderPanel("Select CriSetting Folder", "", "");

                            var assetFolderUri = new Uri(Application.dataPath);
                            var targetUri      = new Uri(acfAssetDirectory);
                            acfAssetExportPathProperty.stringValue = assetFolderUri.MakeRelativeUri(targetUri).ToString();

                            serializedObject.ApplyModifiedProperties();
                        }
                    }
                }
            }

            GUILayout.Space(4f);
        }
Exemplo n.º 20
0
    private void DrawObservedComponentsList()
    {
        GUILayout.Space(5);
        SerializedProperty listProperty = serializedObject.FindProperty("ObservedComponents");

        if (listProperty == null)
        {
            return;
        }

        float containerElementHeight = 22;
        float containerHeight        = listProperty.arraySize * containerElementHeight;

        bool isOpen = PhotonGUI.ContainerHeaderFoldout("Observed Components (" + GetObservedComponentsCount() + ")", serializedObject.FindProperty("ObservedComponentsFoldoutOpen").boolValue);

        serializedObject.FindProperty("ObservedComponentsFoldoutOpen").boolValue = isOpen;

        if (isOpen == false)
        {
            containerHeight = 0;
        }

        //Texture2D statsIcon = AssetDatabase.LoadAssetAtPath( "Assets/Photon Unity Networking/Editor/PhotonNetwork/PhotonViewStats.png", typeof( Texture2D ) ) as Texture2D;

        Rect containerRect = PhotonGUI.ContainerBody(containerHeight);
        bool wasObservedComponentsEmpty = this.m_Target.ObservedComponents.FindAll(item => item != null).Count == 0;

        if (isOpen == true)
        {
            for (int i = 0; i < listProperty.arraySize; ++i)
            {
                Rect elementRect = new Rect(containerRect.xMin, containerRect.yMin + containerElementHeight * i, containerRect.width, containerElementHeight);
                {
                    Rect texturePosition = new Rect(elementRect.xMin + 6, elementRect.yMin + elementRect.height / 2f - 1, 9, 5);
                    ReorderableListResources.DrawTexture(texturePosition, ReorderableListResources.texGrabHandle);

                    Rect propertyPosition = new Rect(elementRect.xMin + 20, elementRect.yMin + 3, elementRect.width - 45, 16);
                    EditorGUI.PropertyField(propertyPosition, listProperty.GetArrayElementAtIndex(i), new GUIContent());

                    //Debug.Log( listProperty.GetArrayElementAtIndex( i ).objectReferenceValue.GetType() );
                    //Rect statsPosition = new Rect( propertyPosition.xMax + 7, propertyPosition.yMin, statsIcon.width, statsIcon.height );
                    //ReorderableListResources.DrawTexture( statsPosition, statsIcon );

                    Rect removeButtonRect = new Rect(elementRect.xMax - PhotonGUI.DefaultRemoveButtonStyle.fixedWidth,
                                                     elementRect.yMin + 2,
                                                     PhotonGUI.DefaultRemoveButtonStyle.fixedWidth,
                                                     PhotonGUI.DefaultRemoveButtonStyle.fixedHeight);

                    GUI.enabled = listProperty.arraySize > 1;
                    if (GUI.Button(removeButtonRect, new GUIContent(ReorderableListResources.texRemoveButton), PhotonGUI.DefaultRemoveButtonStyle))
                    {
                        listProperty.DeleteArrayElementAtIndex(i);
                    }
                    GUI.enabled = true;

                    if (i < listProperty.arraySize - 1)
                    {
                        texturePosition = new Rect(elementRect.xMin + 2, elementRect.yMax, elementRect.width - 4, 1);
                        PhotonGUI.DrawSplitter(texturePosition);
                    }
                }
            }
        }

        if (PhotonGUI.AddButton())
        {
            listProperty.InsertArrayElementAtIndex(Mathf.Max(0, listProperty.arraySize - 1));
        }

        serializedObject.ApplyModifiedProperties();

        bool isObservedComponentsEmpty = this.m_Target.ObservedComponents.FindAll(item => item != null).Count == 0;

        if (wasObservedComponentsEmpty == true && isObservedComponentsEmpty == false && this.m_Target.synchronization == ViewSynchronization.Off)
        {
            Undo.RecordObject(this.m_Target, "Change PhotonView");
            this.m_Target.synchronization = ViewSynchronization.UnreliableOnChange;
            #if !UNITY_MIN_5_3
            EditorUtility.SetDirty(this.m_Target);
            #endif
            serializedObject.Update();
        }

        if (wasObservedComponentsEmpty == false && isObservedComponentsEmpty == true)
        {
            Undo.RecordObject(this.m_Target, "Change PhotonView");
            this.m_Target.synchronization = ViewSynchronization.Off;
            #if !UNITY_MIN_5_3
            EditorUtility.SetDirty(this.m_Target);
            #endif
            serializedObject.Update();
        }
    }
        protected override void OnInspectorDefaultGUI()
        {
            base.OnInspectorDefaultGUI();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Step Number: " + Target.Content.Count);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Export Step Data To .txt"))
            {
                string path = EditorUtility.SaveFilePanel("保存数据文件", Application.dataPath, Target.name, "txt");
                if (path != "")
                {
                    for (int i = 0; i < Target.Content.Count; i++)
                    {
                        EditorUtility.DisplayProgressBar("Export......", i + "/" + Target.Content.Count, (float)i / Target.Content.Count);
                        if (Target.Content[i].Ancillary != "")
                        {
                            File.AppendAllText(path, "【" + Target.Content[i].Ancillary + "】\r\n");
                        }
                        File.AppendAllText(path, (i + 1) + "、" + Target.Content[i].Name + "\r\n" + Target.Content[i].Prompt + "\r\n");
                    }
                    EditorUtility.ClearProgressBar();
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Export Step Name To .txt"))
            {
                string path = EditorUtility.SaveFilePanel("保存数据文件", Application.dataPath, Target.name, "txt");
                if (path != "")
                {
                    for (int i = 0; i < Target.Content.Count; i++)
                    {
                        EditorUtility.DisplayProgressBar("Export......", i + "/" + Target.Content.Count, (float)i / Target.Content.Count);
                        if (Target.Content[i].Ancillary != "")
                        {
                            File.AppendAllText(path, "【" + Target.Content[i].Ancillary + "】\r\n");
                        }
                        File.AppendAllText(path, Target.Content[i].Name + "\r\n");
                    }
                    EditorUtility.ClearProgressBar();
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Export Step Prompt To .txt"))
            {
                string path = EditorUtility.SaveFilePanel("保存数据文件", Application.dataPath, Target.name, "txt");
                if (path != "")
                {
                    for (int i = 0; i < Target.Content.Count; i++)
                    {
                        EditorUtility.DisplayProgressBar("Export......", i + "/" + Target.Content.Count, (float)i / Target.Content.Count);
                        File.AppendAllText(path, Target.Content[i].Prompt + "\r\n");
                    }
                    EditorUtility.ClearProgressBar();
                }
            }
            GUILayout.EndHorizontal();

            _scroll = GUILayout.BeginScrollView(_scroll);
            for (int i = 0; i < Target.Content.Count; i++)
            {
                if (Target.Content[i].Ancillary != "")
                {
                    GUILayout.BeginHorizontal();
                    GUI.color = Color.yellow;
                    GUILayout.Label("【" + Target.Content[i].Ancillary + "】");
                    GUI.color = Color.white;
                    GUILayout.EndHorizontal();
                }

                GUILayout.BeginHorizontal();
                GUILayout.Label(i + "." + Target.Content[i].Name);
                GUILayout.FlexibleSpace();
                GUILayout.Label("[" + Target.Content[i].Trigger + "]");
                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();
        }
Exemplo n.º 22
0
    public override void OnInspectorGUI()
    {
        this.m_Target = (PhotonView)target;
        bool isProjectPrefab = EditorUtility.IsPersistent(this.m_Target.gameObject);

        if (this.m_Target.ObservedComponents == null)
        {
            this.m_Target.ObservedComponents = new System.Collections.Generic.List <Component>();
        }

        if (this.m_Target.ObservedComponents.Count == 0)
        {
            this.m_Target.ObservedComponents.Add(null);
        }

        EditorGUILayout.BeginHorizontal();
        // Owner
        if (isProjectPrefab)
        {
            EditorGUILayout.LabelField("Owner:", "Set at runtime");
        }
        else if (!this.m_Target.isOwnerActive)
        {
            EditorGUILayout.LabelField("Owner", "Scene");
        }
        else
        {
            PhotonPlayer owner     = this.m_Target.owner;
            string       ownerInfo = (owner != null) ? owner.NickName : "<no PhotonPlayer found>";

            if (string.IsNullOrEmpty(ownerInfo))
            {
                ownerInfo = "<no playername set>";
            }

            EditorGUILayout.LabelField("Owner", "[" + this.m_Target.ownerId + "] " + ownerInfo);
        }

        // ownership requests
        EditorGUI.BeginDisabledGroup(Application.isPlaying);
        OwnershipOption own = (OwnershipOption)EditorGUILayout.EnumPopup(this.m_Target.ownershipTransfer, GUILayout.Width(100));

        if (own != this.m_Target.ownershipTransfer)
        {
            // jf: fixed 5 and up prefab not accepting changes if you quit Unity straight after change.
            // not touching the define nor the rest of the code to avoid bringing more problem than solving.
            EditorUtility.SetDirty(this.m_Target);

            Undo.RecordObject(this.m_Target, "Change PhotonView Ownership Transfer");
            this.m_Target.ownershipTransfer = own;
        }
        EditorGUI.EndDisabledGroup();

        EditorGUILayout.EndHorizontal();


        // View ID
        if (isProjectPrefab)
        {
            EditorGUILayout.LabelField("View ID", "Set at runtime");
        }
        else if (EditorApplication.isPlaying)
        {
            EditorGUILayout.LabelField("View ID", this.m_Target.viewID.ToString());
        }
        else
        {
            int idValue = EditorGUILayout.IntField("View ID [1.." + (PhotonNetwork.MAX_VIEW_IDS - 1) + "]", this.m_Target.viewID);
            if (this.m_Target.viewID != idValue)
            {
                Undo.RecordObject(this.m_Target, "Change PhotonView viewID");
                this.m_Target.viewID = idValue;
            }
        }

        // Locally Controlled
        if (EditorApplication.isPlaying)
        {
            string masterClientHint = PhotonNetwork.isMasterClient ? "(master)" : "";
            EditorGUILayout.Toggle("Controlled locally: " + masterClientHint, this.m_Target.isMine);
        }

        // ViewSynchronization (reliability)
        if (this.m_Target.synchronization == ViewSynchronization.Off)
        {
            GUI.color = Color.grey;
        }

        EditorGUILayout.PropertyField(serializedObject.FindProperty("synchronization"), new GUIContent("Observe option:"));

        if (this.m_Target.synchronization != ViewSynchronization.Off && this.m_Target.ObservedComponents.FindAll(item => item != null).Count == 0)
        {
            GUILayout.BeginVertical(GUI.skin.box);
            GUILayout.Label("Warning", EditorStyles.boldLabel);
            GUILayout.Label("Setting the synchronization option only makes sense if you observe something.");
            GUILayout.EndVertical();
        }

        DrawSpecificTypeSerializationOptions();

        GUI.color = Color.white;
        DrawObservedComponentsList();

        // Cleanup: save and fix look
        if (GUI.changed)
        {
            #if !UNITY_MIN_5_3
            EditorUtility.SetDirty(this.m_Target);
            #endif
            PhotonViewHandler.HierarchyChange(); // TODO: check if needed
        }

        GUI.color = Color.white;
        #if !UNITY_MIN_5_3
        EditorGUIUtility.LookLikeControls();
        #endif
    }
Exemplo n.º 23
0
        private void DrawSideWindow()
        {
            GUILayout.Label(new GUIContent("Node Editor (" + canvasCache.nodeCanvas.name + ")", "Opened Canvas path: " + canvasCache.openedCanvasPath), NodeEditorGUI.nodeLabelBold);

//			EditorGUILayout.ObjectField ("Loaded Canvas", canvasCache.nodeCanvas, typeof(NodeCanvas), false);
//			EditorGUILayout.ObjectField ("Loaded State", canvasCache.editorState, typeof(NodeEditorState), false);

            if (GUILayout.Button(new GUIContent("New Canvas", "Loads an Specified Empty CanvasType")))
            {
                NodeEditorFramework.Utilities.GenericMenu menu = new NodeEditorFramework.Utilities.GenericMenu();
                NodeCanvasManager.FillCanvasTypeMenu(ref menu, canvasCache.NewNodeCanvas);
                menu.Show(createCanvasUIPos.position, createCanvasUIPos.width);
            }
            if (Event.current.type == EventType.Repaint)
            {
                Rect popupPos = GUILayoutUtility.GetLastRect();
                createCanvasUIPos = new Rect(popupPos.x + 2, popupPos.yMax + 2, popupPos.width - 4, 0);
            }

            GUILayout.Space(6);

            if (GUILayout.Button(new GUIContent("Save Canvas", "Saves the Canvas to a Canvas Save File in the Assets Folder")))
            {
                string path = EditorUtility.SaveFilePanelInProject("Save Node Canvas", "Node Canvas", "asset", "", NodeEditor.editorPath + "Resources/Saves/");
                if (!string.IsNullOrEmpty(path))
                {
                    canvasCache.SaveNodeCanvas(path);
                }
            }

            if (GUILayout.Button(new GUIContent("Load Canvas", "Loads the Canvas from a Canvas Save File in the Assets Folder")))
            {
                string path = EditorUtility.OpenFilePanel("Load Node Canvas", NodeEditor.editorPath + "Resources/Saves/", "asset");
                if (!path.Contains(Application.dataPath))
                {
                    if (!string.IsNullOrEmpty(path))
                    {
                        ShowNotification(new GUIContent("You should select an asset inside your project folder!"));
                    }
                }
                else
                {
                    canvasCache.LoadNodeCanvas(path);
                }
            }

            GUILayout.Space(6);

            GUILayout.BeginHorizontal();
            sceneCanvasName = GUILayout.TextField(sceneCanvasName, GUILayout.ExpandWidth(true));
            if (GUILayout.Button(new GUIContent("Save to Scene", "Saves the Canvas to the Scene"), GUILayout.ExpandWidth(false)))
            {
                canvasCache.SaveSceneNodeCanvas(sceneCanvasName);
            }
            GUILayout.EndHorizontal();

            if (GUILayout.Button(new GUIContent("Load from Scene", "Loads the Canvas from the Scene")))
            {
                NodeEditorFramework.Utilities.GenericMenu menu = new NodeEditorFramework.Utilities.GenericMenu();
                foreach (string sceneSave in NodeEditorSaveManager.GetSceneSaves())
                {
                    menu.AddItem(new GUIContent(sceneSave), false, LoadSceneCanvasCallback, (object)sceneSave);
                }
                menu.Show(loadSceneUIPos.position, loadSceneUIPos.width);
            }
            if (Event.current.type == EventType.Repaint)
            {
                Rect popupPos = GUILayoutUtility.GetLastRect();
                loadSceneUIPos = new Rect(popupPos.x + 2, popupPos.yMax + 2, popupPos.width - 4, 0);
            }

            GUILayout.Space(6);

            if (GUILayout.Button(new GUIContent("Recalculate All", "Initiates complete recalculate. Usually does not need to be triggered manually.")))
            {
                NodeEditor.RecalculateAll(canvasCache.nodeCanvas);
            }

            if (GUILayout.Button("Force Re-Init"))
            {
                NodeEditor.ReInit(true);
            }

            NodeEditorGUI.knobSize       = EditorGUILayout.IntSlider(new GUIContent("Handle Size", "The size of the Node Input/Output handles"), NodeEditorGUI.knobSize, 12, 20);
            canvasCache.editorState.zoom = EditorGUILayout.Slider(new GUIContent("Zoom", "Use the Mousewheel. Seriously."), canvasCache.editorState.zoom, 0.6f, 2);

            if (canvasCache.editorState.selectedNode != null && Event.current.type != EventType.Ignore)
            {
                canvasCache.editorState.selectedNode.DrawNodePropertyEditor();
            }
        }
Exemplo n.º 24
0
    /// This method creates the inspector when the program is NOT running. In this mode we
    /// allow initialization but do not show any running information
    protected void InitInspector()
    {
        // for easy access to the object
        NITEHandsManager handsManagerObject = target as NITEHandsManager;

        // using hands control
        if (m_initializedFromBefore == false)
        {
            InitFromTarget();
            m_initializedFromBefore = true;
        }
        // choose gestures.
        m_myContent.text    = "Use basic gesture list";
        m_myContent.tooltip = "The basic gesture list is supported by all implementation, If false this uses the values available on the local machine";
        bool useBasicGestureList = EditorGUILayout.Toggle(m_myContent, m_useBasicGestureList);

        string[] gestures = m_defaultVersionGestureList;
        if (useBasicGestureList == false)
        {
            // if we are here we need to make sure m_currentVersionGestureList holds the current list
            // of gestures.
            if (InitGestures())
            {
                gestures = m_currentVersionGestureList;
            }
            else
            {
                Debug.Log("Can't initialize current version!!!!!, defaulting to regular version!");
                m_useBasicGestureList = false;
            }
        }
        // we changed the gesture list so we need to find the new index which corresponds to
        // the previous choices
        if (m_useBasicGestureList != useBasicGestureList)
        {
            m_focusGestureChoice   = FindIndexInList(gestures, handsManagerObject.m_focusGesture);
            m_useFocus             = m_focusGestureChoice >= 0;
            m_refocusGestureChoice = FindIndexInList(gestures, handsManagerObject.m_refocusGesture);
            m_useRefocus           = m_refocusGestureChoice >= 0;
            m_useBasicGestureList  = useBasicGestureList;
        }

        bool useFocus = EditorGUILayout.Toggle("Use Focus?", m_useFocus);

        if (useFocus != m_useFocus)
        {
            if (useFocus == false)
            {
                handsManagerObject.m_focusGesture = "";
                m_focusGestureChoice = -1;
            }
            else
            {
                m_focusGestureChoice = 0;
            }
        }
        m_useFocus = useFocus;
        if (m_useFocus)
        {
            EditorGUI.indentLevel            += 2;
            m_focusGestureChoice              = EditorGUILayout.Popup("Gesture to use", m_focusGestureChoice, gestures);
            EditorGUI.indentLevel            -= 2;
            handsManagerObject.m_focusGesture = gestures[m_focusGestureChoice];
        }

        // we might not want to use refocus (which will make it into "").

        bool useRefocus = EditorGUILayout.Toggle("Use refocus?", m_useRefocus);

        if (useRefocus != m_useRefocus)
        {
            if (useRefocus == false)
            {
                handsManagerObject.m_refocusGesture = "";
                m_refocusGestureChoice = -1;
            }
            else
            {
                m_refocusGestureChoice = 0;
            }
        }
        m_useRefocus = useRefocus;
        if (m_useRefocus)
        {
            EditorGUI.indentLevel += 2;
            m_refocusGestureChoice = EditorGUILayout.Popup("Gesture to use", m_refocusGestureChoice, gestures);
            EditorGUI.indentLevel -= 2;
            handsManagerObject.m_refocusGesture = gestures[m_refocusGestureChoice];
        }
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
Exemplo n.º 25
0
        public static void OnHierarchyGUI(int instanceId, Rect selectionRect)
        {
            // if(buttonStyle == null)
            {
                buttonStyle         = new GUIStyle(GUI.skin.label);
                buttonStyle.padding = new RectOffset();
                buttonStyle.border  = new RectOffset();
            }
            buttonDim = EditorGUIUtility.singleLineHeight - 2;
            Event e   = Event.current;
            var   obj = EditorUtility.InstanceIDToObject(instanceId);

            // if obj is null, then the item is a Scene (the header for each loaded scene)
            if (obj)
            {
                GameObject g          = obj as GameObject;
                Rect       buttonRect = new Rect(selectionRect);
                buttonRect.x       = buttonRect.xMax - buttonDim;
                buttonRect.width   = buttonDim;
                buttonRect.height -= 2;
                buttonRect.y      += 1;

                GUI.DrawTexture(buttonRect, g.activeSelf
                    ? AssetDatabase.LoadAssetAtPath <Texture2D>(packagePath + "Icons/IconEnabled.png")
                    : AssetDatabase.LoadAssetAtPath <Texture2D>(packagePath + "Icons/IconDisabled.png"));

                if (e.isMouse && e.type == EventType.MouseDown && buttonRect.Contains(e.mousePosition))
                {
                    switch (e.button)
                    {
                    case 0:
                        string prefix = g.activeSelf ? "Dis" : "En";
                        Undo.RecordObject(g, $"{prefix}able {g.name}");
                        g.SetActive(!g.activeSelf);
                        EditorUtility.SetDirty(g);
                        break;

                    case 1:
                        GenericMenu menu = new GenericMenu();
                        menu.AddItem(new GUIContent("Show Component Icons", ""), EditorPrefs.GetBool(showComponentIconsKey, true), () =>
                        {
                            EditorPrefs.SetBool(showComponentIconsKey, !EditorPrefs.GetBool(showComponentIconsKey, true));
                        });
                        menu.AddItem(new GUIContent("Show Indent Rainbow", ""), EditorPrefs.GetBool(showIndentRainbowKey, true), () =>
                        {
                            EditorPrefs.SetBool(showIndentRainbowKey, !EditorPrefs.GetBool(showIndentRainbowKey, true));
                        });
                        menu.ShowAsContext();
                        break;
                    }
                    e.Use();
                }
                if (!EditorPrefs.GetBool(showComponentIconsKey, true))
                {
                    return;
                }
                buttonRect.x    -= 3;
                buttonRect.width = 1;
                GUI.color        = Color.black * 0.5f;
                GUI.DrawTexture(buttonRect, EditorGUIUtility.whiteTexture);
                GUI.color        = Color.white;
                buttonRect.x    -= 3;
                buttonRect.width = buttonDim;
                Component[] components = g.GetComponents <Component>();
                foreach (var component in components)
                {
                    if (component == null || component.GetType() == typeof(Transform))
                    {
                        continue;
                    }
                    buttonRect.x -= buttonDim + padding;
                    GUI.color     = new Color(1, 1, 1, 0.5f);
                    GUI.Box(buttonRect, "");
                    GUI.color = Color.white;
                    Type type = component.GetType();
                    GUI.Label(buttonRect, new GUIContent(EditorGUIUtility.ObjectContent(component, type).image, type.ToString()), buttonStyle);
                    var b = component as Behaviour;
                    if (b)
                    {
                        if (!b.enabled)
                        {
                            GUI.DrawTexture(new RectOffset(-(int)(buttonDim * 0.4f), 0, -(int)(buttonDim * 0.4f), 0).Add(buttonRect), AssetDatabase.LoadAssetAtPath <Texture2D>(packagePath + "Icons/IconRemove.png"));
                            EditorGUI.DrawRect(buttonRect, new Color(1, 0, 0, 0.25f));
                        }
                    }
                    else
                    {
                        Type t = component.GetType();
                        if (t.GetMember("get_enabled", BindingFlags.Public | BindingFlags.Instance).Length > 0)
                        {
                            if (!(bool)t.InvokeMember("get_enabled", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, component, null))
                            {
                                GUI.DrawTexture(new RectOffset(-(int)(buttonDim * 0.4f), 0, -(int)(buttonDim * 0.4f), 0).Add(buttonRect), AssetDatabase.LoadAssetAtPath <Texture2D>(packagePath + "Icons/IconRemove.png"));
                                EditorGUI.DrawRect(buttonRect, new Color(1, 0, 0, 0.25f));
                            }
                        }
                    }
                }
                if (!g.activeInHierarchy)
                {
                    GUI.color = new Color(1, 0, 0, 1f);
                    GUI.Box(selectionRect, "");
                    GUI.color = Color.white;
                }
                if (!EditorPrefs.GetBool(showIndentRainbowKey))
                {
                    return;
                }
                float   opacity    = 0.25f;
                float   luminosity = 0.666f;
                Color[] colors     = new Color[] { new Color(luminosity * 1.5f, 0, luminosity / 3, opacity), new Color(luminosity, luminosity * 2 / 3, 0, opacity), new Color(luminosity / 4, luminosity, 0, opacity), new Color(0, luminosity, luminosity, opacity), new Color(0, luminosity / 2, luminosity * 1.5f, opacity), new Color(luminosity, 0, luminosity * 1.5f, opacity) };
                int     pos        = (int)(selectionRect.xMin - 2) / 14 - 2;
                for (int i = 0; i <= pos; i++)
                {
                    GUI.color = colors[(i) % colors.Length];
                    // EditorGUI.DrawRect(new Rect(1 + (i + 1) * 14 + (14 - width), selectionRect.yMin, width, selectionRect.height), colors[(i) % colors.Length] / opacity);
                    GUI.DrawTexture(new Rect(1 + (i + 1) * 14, selectionRect.yMin, 14, selectionRect.height), AssetDatabase.LoadAssetAtPath <Texture>(packagePath + "Icons/IconGradient.psd"));
                    GUI.color = Color.white;
                }
                return;
            }
            Scene scene = GetSceneFromInstanceID(instanceId);

            buttonStyle         = new GUIStyle(GUI.skin.button);
            buttonStyle.padding = new RectOffset();
            selectionRect.x     = selectionRect.xMax - 35;
            selectionRect.width = buttonDim;
            using (new EditorGUI.DisabledScope(EditorSceneManager.sceneCount <= 1))
            {
                if (GUI.Button(selectionRect, new GUIContent(AssetDatabase.LoadAssetAtPath <Texture2D>(packagePath + "Icons/IconRemove.png"), "Remove scene"), buttonStyle))
                {
                    GenericMenu menu = new GenericMenu();
                    menu.AddItem(new GUIContent("Remove Scene"), false, () =>
                    {
                        if (scene.isDirty)
                        {
                            if (EditorUtility.DisplayDialog("Save modified scene?", string.Format("{0} has been modified. Save before removing scene?", scene.name), "Save", "Don't Save"))
                            {
                                EditorSceneManager.SaveScene(scene);
                            }
                        }
                        EditorSceneManager.UnloadSceneAsync(scene);
                    });
                    menu.ShowAsContext();
                }
                if (EditorSceneManager.sceneCount <= 1)
                {
                    GUI.color = disabledColor;
                    GUI.DrawTexture(selectionRect, EditorGUIUtility.whiteTexture);
                    GUI.color = Color.white;
                }
                selectionRect.x -= buttonDim + padding * 4;
            }
            using (new EditorGUI.DisabledScope(scene.isLoaded && EditorSceneManager.loadedSceneCount == 1))
            {
                if (GUI.Button(selectionRect, scene.isLoaded ? new GUIContent(AssetDatabase.LoadAssetAtPath <Texture2D>(packagePath + "Icons/IconEnabled.png"), "Unload Scene") : new GUIContent(AssetDatabase.LoadAssetAtPath <Texture2D>(packagePath + "Icons/IconDisabled.png"), "Load Scene"), buttonStyle))
                {
                    if (scene.isLoaded)
                    {
                        if (scene.isDirty)
                        {
                            if (EditorUtility.DisplayDialog("Save modified scene?", string.Format("{0} has been modified. Save before unloading scene?", scene.name), "Save", "Don't Save"))
                            {
                                EditorSceneManager.SaveScene(scene);
                            }
                        }
                        EditorSceneManager.CloseScene(scene, false);
                    }
                    else
                    {
                        EditorSceneManager.OpenScene(scene.path, OpenSceneMode.Additive);
                        SceneView.RepaintAll();
                    }
                }
                if (scene.isLoaded && EditorSceneManager.loadedSceneCount == 1)
                {
                    GUI.color = disabledColor;
                    GUI.DrawTexture(selectionRect, EditorGUIUtility.whiteTexture);
                    GUI.color = Color.white;
                }
            }
            // selectionRect.x -= buttonDim + padding;
            // using (new EditorGUI.DisabledScope(!scene.isLoaded))
            // {
            //     if (GUI.Button(selectionRect, new GUIContent("R", "Select root GameObjects in scene"), buttonStyle))
            //     {
            //         Selection.objects = scene.GetRootGameObjects();
            //     }
            //     if (!scene.isLoaded)
            //     {
            //         GUI.color = disabledColor;
            //         GUI.DrawTexture(selectionRect, EditorGUIUtility.whiteTexture);
            //         GUI.color = Color.white;
            //     }
            // }
            selectionRect.x -= buttonDim + padding;
            using (new EditorGUI.DisabledScope(!scene.isDirty))
            {
                if (GUI.Button(selectionRect, new GUIContent(AssetDatabase.LoadAssetAtPath <Texture2D>(packagePath + "Icons/IconSave.png"), "Save this scene"), buttonStyle))
                {
                    EditorSceneManager.SaveScene(scene, scene.path);
                }
                if (!scene.isDirty)
                {
                    GUI.color = disabledColor;
                    GUI.DrawTexture(selectionRect, EditorGUIUtility.whiteTexture);
                    GUI.color = Color.white;
                }
            }
            if (!string.IsNullOrEmpty(scene.path))
            {
                selectionRect.x -= buttonDim + padding;
                if (GUI.Button(selectionRect, new GUIContent(AssetDatabase.LoadAssetAtPath <Texture2D>(packagePath + "Icons/IconFind.png"), "Locate Scene Asset"), buttonStyle))
                {
                    EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(scene.path));
                }
            }
        }
Exemplo n.º 26
0
	void OnGUI () {
		
		#region fonts variables
		var bold = new GUIStyle ("label");
		var boldFold = new GUIStyle ("foldout");
		bold.fontStyle = FontStyle.Bold;
		bold.fontSize = 14;
		boldFold.fontStyle = FontStyle.Bold;
		var Slim = new GUIStyle ("label");
		Slim.fontStyle = FontStyle.Normal;
		Slim.fontSize = 10;	
		var style = new GUIStyle ("label");
		style.wordWrap = true;
		#endregion fonts variables
		
		using (new Horizontal()) {
			GUILayout.Label ( "Races List", "toolbarbutton", GUILayout.ExpandWidth (true));
		}
		tmpObj = (Selection.activeObject as GameObject);
		if ( Selection.activeObject && Selection.activeObject.GetType().ToString() == "DKRaceData"){ 
			GUI.color = Color.yellow;
			GUILayout.Label ( "Selection is a Race. Select a Slot or an Overlay.", GUILayout.ExpandWidth (false));
		
		}
		GUI.color = Color.white;
		if ( EditorVariables.AutoDetLib == false 
		    && Selection.activeObject
		    && Selection.activeObject.GetType().ToString() != "DKRaceData"
		    && ( Selection.activeObject.GetType().ToString() == "DKSlotData" 
		    || Selection.activeObject.GetType().ToString() == "DKOverlayData"
		    || ( tmpObj && tmpObj.GetComponent<DK_SlotsAnatomyElement>() != null)))
		{
			SelectedElemObj =  ( Selection.activeObject as GameObject);
			using (new Horizontal()) {
				GUILayout.Label ( "Element :", GUILayout.ExpandWidth (false));
				if ( Selection.activeObject.GetType().ToString() == "DKSlotData" ) {
					SelectedElemName = Selection.activeObject.name;
					SelectedElemType = "DKSlotData";
				}
				else
				if ( Selection.activeObject.GetType().ToString() == "DKOverlayData" ) {
					SelectedElemName = Selection.activeObject.name;
					SelectedElemType = "DKOverlayData";
				}
				else{

					if ( tmpObj.GetComponent<DK_SlotsAnatomyElement>() != null ) {
						SelectedElemName = Selection.activeObject.name;
						SelectedElemType = "Anatomy Part";
					}
				}
				GUILayout.Label ( SelectedElemName, GUILayout.Width (120));
				GUILayout.Label ( "Type :", GUILayout.ExpandWidth (false));
				GUILayout.Label ( SelectedElemType, GUILayout.Width (120));
			}
		
			using (new Horizontal()) {
				GUILayout.Label ( "Element's Races List", "toolbarbutton", GUILayout.ExpandWidth (true));
			}
			// Slots Only
			if ( (Selection.activeObject.GetType().ToString() == "DKSlotData")){
				DKSlotData _SlotData = (Selection.activeObject as DKSlotData);
				// clear
				using (new Horizontal()) {
					if ( GUILayout.Button ( "clear Element's list",  GUILayout.ExpandWidth (true))) {
						_SlotData.Race.Clear();
					}
					if ( GUILayout.Button ( "clear Races list", GUILayout.ExpandWidth (true))) {
						RaceDataList.Clear();
					}
					if ( RaceDataList.Count != 0 
						&& _SlotData.Race.Count == 00 
						&& GUILayout.Button ( "Add All", GUILayout.ExpandWidth (true))) 
					{
						if ( RaceDataList.Count != 0 && _SlotData.Race.Count == 00 ) _SlotData.Race = RaceDataList;
					}
				}
				for(int i = 0; i < EditorVariables._RaceLibrary.raceElementList.Length; i ++){
					if ( RaceDataList.Contains(EditorVariables._RaceLibrary.raceElementList[i].Race) ) {
						
						
					}
					else RaceDataList.Add(EditorVariables._RaceLibrary.raceElementList[i].Race);
				}	
				using (new Horizontal()) {
					if (_SlotData.Race.Count > 0 )using (new ScrollView(ref scroll1)) 
					{
							
						for(int i = 0; i < _SlotData.Race.Count; i ++){
							using (new Horizontal()) {
								GUI.color = new Color (0.9f, 0.5f, 0.5f);
								if ( GUILayout.Button ( "X", "toolbarbutton", GUILayout.ExpandWidth (false))) {
									_SlotData.Race.Remove(_SlotData.Race[i]);
									EditorUtility.SetDirty(_SlotData);
									AssetDatabase.SaveAssets();
								}
								GUI.color = Color.white;
								if ( i < _SlotData.Race.Count ) if ( GUILayout.Button ( _SlotData.Race[i], Slim, GUILayout.ExpandWidth (true))) {
									
								}
							}
						}
					}

					if (RaceDataList.Count > 0 )using (new ScrollView(ref scroll)) 
					{
							
						for(int i = 0; i < RaceDataList.Count; i ++){
							using (new Horizontal()) {
								if ( _SlotData.Race.Contains(RaceDataList[i]) ) GUI.color = Color.gray;
								else GUI.color = new Color (0.8f, 1f, 0.8f, 1);
								if ( GUILayout.Button ( "<", "toolbarbutton", GUILayout.ExpandWidth (false))) {
									_SlotData.Race.Add(RaceDataList[i]);
									EditorUtility.SetDirty(_SlotData);
									AssetDatabase.SaveAssets();
								}
								if ( _SlotData.Race.Contains(RaceDataList[i]) ) GUI.color = Color.gray;
								else GUI.color = Color.white;
								if ( GUILayout.Button ( RaceDataList[i], Slim, GUILayout.ExpandWidth (true))) {
									
								}
							}
						}
					}
				}
			}
			// Overlays Only
			if ( (Selection.activeObject.GetType().ToString() == "DKOverlayData")){
				DKOverlayData _DKOverlayData = (Selection.activeObject as DKOverlayData);
				// clear
				using (new Horizontal()) {
					if ( GUILayout.Button ( "clear Element's list",  GUILayout.ExpandWidth (true))) {
						_DKOverlayData.Race.Clear();
					}
					if ( GUILayout.Button ( "clear Races list", GUILayout.ExpandWidth (true))) {
						RaceDataList.Clear();
					}
					if ( RaceDataList.Count != 0 
						&& _DKOverlayData.Race.Count == 00 
						&& GUILayout.Button ( "Add All", GUILayout.ExpandWidth (true))) 
					{
						if ( RaceDataList.Count != 0 && _DKOverlayData.Race.Count == 00 ) _DKOverlayData.Race = RaceDataList;
					}
				}
				for(int i = 0; i < EditorVariables._RaceLibrary.raceElementList.Length; i ++){
					if ( RaceDataList.Contains(EditorVariables._RaceLibrary.raceElementList[i].Race) ) {
						
						
					}
					else
					 RaceDataList.Add(EditorVariables._RaceLibrary.raceElementList[i].Race);
				}	
				using (new Horizontal()) {
					if (_DKOverlayData.Race.Count > 0 )using (new ScrollView(ref scroll1)) 
					{
							
						for(int i = 0; i < _DKOverlayData.Race.Count; i ++){
							using (new Horizontal()) {
								GUI.color = new Color (0.9f, 0.5f, 0.5f);
								if ( GUILayout.Button ( "X", "toolbarbutton", GUILayout.ExpandWidth (false))) {
									_DKOverlayData.Race.Remove(_DKOverlayData.Race[i]);
									EditorUtility.SetDirty(_DKOverlayData);
									AssetDatabase.SaveAssets();
								}
								GUI.color = Color.white;
								if ( i < _DKOverlayData.Race.Count ) if ( GUILayout.Button ( _DKOverlayData.Race[i], Slim, GUILayout.ExpandWidth (true))) {
									
								}
							}
						}
					}
					if (RaceDataList.Count > 0 )using (new ScrollView(ref scroll)) 
					{
							
						for(int i = 0; i < RaceDataList.Count; i ++){
							using (new Horizontal()) {
								if ( _DKOverlayData.Race.Contains(RaceDataList[i]) ) GUI.color = Color.gray;
								else GUI.color = new Color (0.8f, 1f, 0.8f, 1);
								if ( GUILayout.Button ( "<", "toolbarbutton", GUILayout.ExpandWidth (false))) {
									_DKOverlayData.Race.Add(RaceDataList[i]);
									EditorUtility.SetDirty(_DKOverlayData);
									AssetDatabase.SaveAssets();
								}
								if ( _DKOverlayData.Race.Contains(RaceDataList[i]) ) GUI.color = Color.gray;
								else GUI.color = Color.white;
								if ( GUILayout.Button ( RaceDataList[i], Slim, GUILayout.ExpandWidth (true))) {
									
								}
							}
						}
					}
				}
			}
		}
		// Anatomy Only
		if ( EditorVariables.AutoDetLib == false && Selection.activeObject as GameObject && ((Selection.activeObject as GameObject).GetComponent<DK_Race>() != null)){
			DK_Race _DK_Race = (Selection.activeObject as GameObject).GetComponent<DK_Race>();

			// clear
			using (new Horizontal()) {
				if ( GUILayout.Button ( "clear Element's list",  GUILayout.ExpandWidth (true))) {
					_DK_Race.Race.Clear();
				}
				if ( GUILayout.Button ( "clear Races list", GUILayout.ExpandWidth (true))) {
					RaceDataList.Clear();
				}
				if ( RaceDataList.Count != 0 
					&& _DK_Race.Race.Count == 00 
					&& GUILayout.Button ( "Add All", GUILayout.ExpandWidth (true))) 
				{
					if ( RaceDataList.Count != 0 && _DK_Race.Race.Count == 00 ) _DK_Race.Race = RaceDataList;
				}
			}
			for(int i = 0; i < EditorVariables._RaceLibrary.raceElementList.Length; i ++){
				if ( RaceDataList.Contains(EditorVariables._RaceLibrary.raceElementList[i].Race) ) {
					
					
				}
				else
				 RaceDataList.Add(EditorVariables._RaceLibrary.raceElementList[i].Race);
			}	
			using (new Horizontal()) {
				if (_DK_Race.Race.Count > 0 )using (new ScrollView(ref scroll1)) 
				{
						
					for(int i = 0; i < _DK_Race.Race.Count; i ++){
						using (new Horizontal()) {
							GUI.color = new Color (0.9f, 0.5f, 0.5f);
							if ( GUILayout.Button ( "X", "toolbarbutton", GUILayout.ExpandWidth (false))) {
								_DK_Race.Race.Remove(_DK_Race.Race[i]);
								EditorUtility.SetDirty(_DK_Race);
								AssetDatabase.SaveAssets();
							}
							GUI.color = Color.white;
							if ( i < _DK_Race.Race.Count ) if ( GUILayout.Button ( _DK_Race.Race[i], Slim, GUILayout.ExpandWidth (true))) {
								
							}
						}
					}
				}
				if (RaceDataList.Count > 0 )using (new ScrollView(ref scroll)) 
				{
						
					for(int i = 0; i < RaceDataList.Count; i ++){
						using (new Horizontal()) {
							if ( _DK_Race.Race.Contains(RaceDataList[i]) ) GUI.color = Color.gray;
							else GUI.color = new Color (0.8f, 1f, 0.8f, 1);
							if ( GUILayout.Button ( "<", "toolbarbutton", GUILayout.ExpandWidth (false))) {
								_DK_Race.Race.Add(RaceDataList[i]);
								EditorUtility.SetDirty(_DK_Race);
								AssetDatabase.SaveAssets();
							}
							if ( _DK_Race.Race.Contains(RaceDataList[i]) ) GUI.color = Color.gray;
							else GUI.color = Color.white;
							if ( GUILayout.Button ( RaceDataList[i], Slim, GUILayout.ExpandWidth (true))) {
								
							}
						}
					}
				}
			}
		}
		// AutoDetectLib Only
		if ( EditorVariables.AutoDetLib == true ) {
			GUILayout.Label("AutoDetect Process Race's Section", GUILayout.ExpandWidth (true));
			if ( GUILayout.Button ( "Done",  GUILayout.ExpandWidth (true))) {
				EditorVariables.NewRaceName = "";
				for(int i = 0; i < EditorVariables.RaceToApplyList.Count; i ++){
					EditorVariables.NewRaceName = EditorVariables.NewRaceName+" -"+EditorVariables.RaceToApplyList[i];
				}
				this.Close();
			}
			// clear
			try{
			using (new Horizontal()) {
				if ( GUILayout.Button ( "clear Destination's list",  GUILayout.ExpandWidth (true))) {
				EditorVariables.RaceToApplyList.Clear();
				}
				if ( GUILayout.Button ( "clear Races list", GUILayout.ExpandWidth (true))) {
					RaceDataList.Clear();
				}
				if ( RaceDataList.Count != 0 
			 	   && EditorVariables.RaceToApplyList.Count == 00 
				    && GUILayout.Button ( "Add All", GUILayout.ExpandWidth (true))) 
				{
				if ( RaceDataList.Count != 0 && EditorVariables.RaceToApplyList.Count == 00 ) EditorVariables.RaceToApplyList = RaceDataList;
				}
			}
			}catch(ArgumentException){}
			for(int i = 0; i < EditorVariables._RaceLibrary.raceElementList.Length; i ++){
				if ( RaceDataList.Contains(EditorVariables._RaceLibrary.raceElementList[i].Race) ) {
					
				}
				else RaceDataList.Add(EditorVariables._RaceLibrary.raceElementList[i].Race);
			}	
			using (new Horizontal()) {
			
				if (EditorVariables.RaceToApplyList.Count > 0 )using (new ScrollView(ref scroll1)) 
			
				{
					for(int i = 0; i < EditorVariables.RaceToApplyList.Count; i ++){
						using (new Horizontal()) {
							GUI.color = new Color (0.9f, 0.5f, 0.5f);
							if ( GUILayout.Button ( "X", "toolbarbutton", GUILayout.ExpandWidth (false))) {
							EditorVariables.RaceToApplyList.Remove(EditorVariables.RaceToApplyList[i]);

							}
							GUI.color = Color.white;
						if ( i < EditorVariables.RaceToApplyList.Count ) if ( GUILayout.Button ( EditorVariables.RaceToApplyList[i], Slim, GUILayout.ExpandWidth (true))) {
								
							}
						}
					}
				}
				if (RaceDataList.Count > 0 )using (new ScrollView(ref scroll)) 
				{
					for(int i = 0; i < RaceDataList.Count; i ++){
						using (new Horizontal()) {
							if ( EditorVariables.RaceToApplyList.Contains(RaceDataList[i]) ) GUI.color = Color.gray;
							else GUI.color = new Color (0.8f, 1f, 0.8f, 1);
							if ( GUILayout.Button ( "<", "toolbarbutton", GUILayout.ExpandWidth (false))) {
									EditorVariables.RaceToApplyList.Add(RaceDataList[i]);
							}
							if ( EditorVariables.RaceToApplyList.Contains(RaceDataList[i]) ) GUI.color = Color.gray;
							else GUI.color = Color.white;
							if ( GUILayout.Button ( RaceDataList[i], Slim, GUILayout.ExpandWidth (true))) {
							
							}
						}
					}
				}
			}
		}
	}
        private void DrawDebugSection()
        {
            if (InspectorUIUtility.DrawSectionFoldoutWithKey("Debug Options", ShowDebugOptionsPrefKey, MixedRealityStylesUtility.BoldFoldoutStyle))
            {
                using (new EditorGUI.IndentLevelScope())
                {
                    using (var check = new EditorGUI.ChangeCheckScope())
                    {
                        EditorGUILayout.PropertyField(maskEnabled);
                        if (check.changed)
                        {
                            scrollView.MaskEnabled = maskEnabled.boolValue;
                            EditorUtility.SetDirty(target);
                        }
                    }

                    using (new EditorGUI.DisabledGroupScope(EditorApplication.isPlaying))
                    {
                        visibleDebugPlanes = EditorGUILayout.Toggle("Show Threshold Planes", visibleDebugPlanes);
                        EditorGUILayout.Space();
                    }
                }

                using (new EditorGUI.IndentLevelScope())
                {
                    using (new EditorGUI.DisabledGroupScope(!EditorApplication.isPlaying))
                    {
                        if (ShowDebugPagination = EditorGUILayout.Foldout(ShowDebugPagination, new GUIContent("Debug Pagination", "Pagination is only available during playmode."), MixedRealityStylesUtility.BoldFoldoutStyle))
                        {
                            using (new EditorGUI.IndentLevelScope())
                            {
                                animateTransition = EditorGUILayout.Toggle(new GUIContent("Animate", "Toggling will use animation to move scroller to new position."), animateTransition);

                                using (new EditorGUILayout.HorizontalScope())
                                {
                                    debugPaginationMode  = (PaginationMode)EditorGUILayout.EnumPopup(new GUIContent("Pagination Mode"), debugPaginationMode, GUILayout.Width(400.0f));
                                    paginationMoveNumber = EditorGUILayout.IntField(paginationMoveNumber);

                                    if (GUILayout.Button("Move"))
                                    {
                                        switch (debugPaginationMode)
                                        {
                                        case PaginationMode.ByTier:
                                        default:
                                            scrollView.MoveByTiers(paginationMoveNumber, animateTransition);
                                            break;

                                        case PaginationMode.ByPage:
                                            scrollView.MoveByPages(paginationMoveNumber, animateTransition);
                                            break;

                                        case PaginationMode.ToCellIndex:
                                            scrollView.MoveToIndex(paginationMoveNumber, animateTransition);
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 28
0
        private static void LoadPrimaryDefinitionSubset <T>(TEXPreference pref, List <TexAsset> fontList, string folderPath, string typeStr, TexAssetType typeEnum, int mode) where T : TexAsset
        {
            if (!AssetDatabase.IsValidFolder(folderPath))
            {
                return;
            }
            string[] customF = AssetDatabase.FindAssets(typeStr, new string[] { folderPath });
            for (int i = 0; i < customF.Length; i++)
            {
                if (fontList.Count >= 31)
                {
                    Debug.LogWarning("Font/Sprite database count are beyond 31, ignoring any assets after " + fontList[fontList.Count - 1].id);
                    break;
                }
                string realPath = AssetDatabase.GUIDToAssetPath(customF[i]);
                string id       = Path.GetFileNameWithoutExtension(realPath).ToLower();

                if (fontList.Any((x) => x.id == id))
                {
                    continue;
                }

                if (!isNameValid(id))
                {
                    // We show this for information purpose, since *-Regular or *_ is very common mistake
                    // We are not showing this for frequent update, since this behavior is 'intended' for giving an alternative styling
                    if (id.Contains("-Regular") || id.Substring(id.Length - 1) == "_")
                    {
                        Debug.LogWarning("File " + id + " is ignored since it has invalid character(s) in its name");
                    }
                    continue;
                }

                UpdateProgress(mode, id, i, customF.Length);

                string   json     = null;
                var      metaPath = pref.MainFolderPath + resourceFontMetaPath + id + ".asset";
                TexAsset metadata = AssetDatabase.LoadAssetAtPath <T>(metaPath);

#if TEXDRAW_TMP
                string sdfPath = pref.MainFolderPath + "/Fonts/TMPro/" + id + ".asset";
                if (typeEnum == TexAssetType.Font && File.Exists(sdfPath))
                {
                    metadata = AssetDatabase.LoadAssetAtPath <TexFontSigned>(metaPath);
                    if (!metadata)
                    {
                        metadata = CreateAndRecover <TexFontSigned>(metaPath);
                        ((TexFontSigned)metadata).rawpath = realPath;
                        AssetDatabase.CreateAsset(metadata, metaPath);
                    }
                    realPath = sdfPath;
                }
#endif
                if (!metadata)
                {
                    metadata = CreateAndRecover <T>(metaPath);
                    AssetDatabase.CreateAsset(metadata, metaPath);
                }
                else
                {
                    json = JsonUtility.ToJson(metadata);
                }

                metadata.id    = id;
                metadata.index = fontList.Count;
                metadata.ImportAsset(realPath);
                metadata.ImportDictionary();

                if (json != JsonUtility.ToJson(metadata))
                {
                    // this is necessary to avoid messing with Git version control
                    EditorUtility.SetDirty(metadata);
                }

                fontList.Add(metadata);
            }
        }
Exemplo n.º 29
0
 static void ToggleIgnore()
 {
     _ignoreNewSelections = !_ignoreNewSelections;
     EditorUtility.SetDirty(EditorWindow.GetWindow <SelectionHistory>(false, "Selection History", true));
 }
Exemplo n.º 30
0
 internal void Changed(ReorderableList list) {
     EditorUtility.SetDirty(target);
 }