Beispiel #1
0
        //		private int IndexOf (string[] array, string target)
        //		{
        //			int length = array.Length;
        //			for (var i = 0; i < length; i++) {
        //				if (array [i] == target)
        //					return i;
        //			}
        //			return 0;
        //		}


        public void DrawInspectorBase(Node node)
        {
            ECLEditorUtl.BeginContents();
            {
                EditorGUILayout.LabelField("State values");
                EditorGUILayout.TextField(new GUIContent("Conditon"), node.condition);
                EditorGUILayout.TextField(new GUIContent("Result1"), node.result1);
                EditorGUILayout.TextField(new GUIContent("Result2"), node.result2);
            }
            ECLEditorUtl.EndContents();
        }
Beispiel #2
0
        public void DrawInspector(Root node)
        {
            EditorGUILayout.LabelField(new GUIContent("Root"), TitleStyle);
            EditorGUILayout.Space();

            node.begainIndex = EditorGUILayout.IntField(new GUIContent("Begain Index"), node.begainIndex);

            node.monoScript = (MonoScript)EditorGUILayout.ObjectField("Root Script", node.monoScript, typeof(MonoScript), false);
            if (node.monoScript != null)
            {
                if (!node.monoScript.GetClass().IsSubclassOf(typeof(ActionBase)))
                {
                    EditorGUILayout.HelpBox(string.Format("{0} is not a subclass of Hivemind.ActionBase", node.monoScript.GetClass().ToString()), MessageType.Warning);
                    //					action.monoScript = null;
                }
                else
                {
                }
            }
            if (node.attr != null)
            {
                ECLEditorUtl.BeginContents();
                {
                    EditorGUILayout.LabelField("Event Content");
                    node.attr.DrawInspector(node);
                }
                ECLEditorUtl.EndContents();
            }
            EditorGUILayout.Space();

            if (GUILayout.Button("Refresh Nodes Index"))
            {
                node.index    = 0;
                node.maxIndex = 0;
                foreach (Node n in node.behaviorTree.nodes)
                {
                    if (n != node)
                    {
                        node.maxIndex++;
                        n.index = node.begainIndex + node.maxIndex;
                    }
                }
            }
        }
Beispiel #3
0
 void OnGUI()
 {
     if (GUILayout.Button("Gen C#"))
     {
         Debug.Log(getCode());
     }
     if (GUILayout.Button("Gen Lua"))
     {
         Debug.Log(getCodeLua());
     }
     GUILayout.Space(5);
     ECLEditorUtl.BeginContents();
     {
         EditorGUILayout.BeginHorizontal();
         {
             curve = EditorGUILayout.CurveField("Curve", curve, GUILayout.Height(200));
         }
         EditorGUILayout.EndHorizontal();
     }
     ECLEditorUtl.EndContents();
 }
Beispiel #4
0
        public void DrawInspector(NodeAction node)
        {
            EditorGUILayout.LabelField(new GUIContent("Action"), TitleStyle);

            EditorGUILayout.Space();
            node.desc         = EditorGUILayout.TextField(new GUIContent("Desc"), node.desc);
            node.canMultTimes = EditorGUILayout.Toggle("Run MultTimes", node.canMultTimes);

            // MonoScript selection field
            NodeAction action = (NodeAction)serializedObject.targetObject;

            action.monoScript = (MonoScript)EditorGUILayout.ObjectField("Action Script", action.monoScript, typeof(MonoScript), false);
            if (action.monoScript != null)
            {
                if (!action.monoScript.GetClass().IsSubclassOf(typeof(ActionBase)))
                {
                    EditorGUILayout.HelpBox(string.Format("{0} is not a subclass of Hivemind.ActionBase", action.monoScript.GetClass().ToString()), MessageType.Warning);
//					action.monoScript = null;
                }
                else
                {
                }
            }
            if (action.action != null)
            {
                ECLEditorUtl.BeginContents();
                {
                    EditorGUILayout.LabelField("Event Content");
                    action.action.DrawInspector(node);
                }
                ECLEditorUtl.EndContents();
            }
            EditorGUILayout.Space();

            DrawInspectorBase(node);

            serializedObject.ApplyModifiedProperties();
        }
Beispiel #5
0
    public void drawLuaInfor()
    {
        instance = target as CLBaseLua;
        ECLEditorUtl.BeginContents();
        {
            GUILayout.BeginHorizontal();
            {
                EditorGUILayout.LabelField("Lua Text", GUILayout.Width(100));
                luaAsset = EditorGUILayout.ObjectField(luaAsset, typeof(UnityEngine.Object), GUILayout.Width(125));
            }
            GUILayout.EndHorizontal();
            string luaPath = AssetDatabase.GetAssetPath(luaAsset);
            //              if(!string.IsNullOrEmpty(luaPath)) {
            instance.luaPath = Utl.filterPath(luaPath);
            //              }
            EditorUtility.SetDirty(instance);

            GUI.contentColor = Color.yellow;
            EditorGUILayout.LabelField("注意:绑定的lua要求返回luatable");
            GUI.contentColor = Color.white;
        }
        ECLEditorUtl.EndContents();
    }
Beispiel #6
0
    public override void OnInspectorGUI()
    {
        instance = target as CLSeekerByRay;
        //DrawDefaultInspector();
        ECLEditorUtl.BeginContents();
        {
            EditorGUILayout.HelpBox(
                "通过射线寻路\n" +
                "【注意注意注意】\n" +
                "  1.不需要A星;\n" +
                "  2.只能处理简单的寻路,最好是每个目标点都是可到达的;\n" +
                "  3.如果某个点不能到达,则肯定会寻设置的最大的寻路次数;\n" +
                "主要方法:\n" +
                "  .init();//初始化回调:寻路完成的回调,移动过程中的回调,到达目的地的回调\n" +
                "  .seek();//寻路,完成后会调用在init里设置的回调函数,第一个参数是路径,第二个参数为能否到达目的地\n" +
                "  .seekTarget();//寻路,会定时重新寻目标对象的路径\n" +
                "  .cancelSeekTarget();//取消对目标对象的定时寻路\n" +
                "  .startMove();//开始移动,只能通过此方法,不能直接改变canMove变量\n" +
                "  .stopMove();//停止移动\n"
                , MessageType.None, true);
        }
        ECLEditorUtl.EndContents();

        ECLEditorUtl.BeginContents();
        {
            GUI.color = Color.yellow;
            GUILayout.Label("*鼠标悬停在字段上有解释");
            GUI.color = Color.white;

            GUIContent uicontnt = null;

            ECLEditorUtl.BeginContents();
            {
                uicontnt = new GUIContent("Obstruct Mask", "障碍物的layer");
                instance.obstructMask = ECLEditorUtl.drawMaskField(uicontnt, instance.obstructMask);
                uicontnt                = new GUIContent("Ray Distance", "每次寻路发射的射线长度用于检测障碍物");
                instance.rayDistance    = EditorGUILayout.FloatField(uicontnt, instance.rayDistance);
                uicontnt                = new GUIContent("Ray Height", "每次寻路发射的射线高度用于检测障碍物");
                instance.rayHeight      = EditorGUILayout.FloatField(uicontnt, instance.rayHeight);
                uicontnt                = new GUIContent("Ray Dirs", "4方向、8方向、16方向发射线寻路");
                instance.rayDirs        = (CLSeekerByRay.SearchDirs)EditorGUILayout.EnumPopup(uicontnt, instance.rayDirs);
                uicontnt                = new GUIContent("Max Search Times", "最大寻路次数,防止死循环");
                instance.maxSearchTimes = EditorGUILayout.IntField(uicontnt, instance.maxSearchTimes);
            }
            ECLEditorUtl.EndContents();

            uicontnt                      = new GUIContent("Target", "目标对象");
            instance.target               = (Transform)EditorGUILayout.ObjectField(uicontnt, instance.target, typeof(Transform));
            uicontnt                      = new GUIContent("Move Speed", "移动速度");
            instance.speed                = EditorGUILayout.FloatField(uicontnt, instance.speed);
            uicontnt                      = new GUIContent("Turning Speed", "转动速度,【注意】当为负数时表示立即转到目标方向,大于0时则会慢慢转向目标方向");
            instance.turningSpeed         = EditorGUILayout.FloatField(uicontnt, instance.turningSpeed);
            uicontnt                      = new GUIContent("EndReached Distance", "离目标到一定距离后结束移动");
            instance.endReachedDistance   = EditorGUILayout.FloatField(uicontnt, instance.endReachedDistance);
            uicontnt                      = new GUIContent("Auto Move After Seek", "当寻路完成后就移动过去");
            instance.autoMoveOnFinishSeek = EditorGUILayout.Toggle(uicontnt, instance.autoMoveOnFinishSeek);
            uicontnt                      = new GUIContent("Moving By", "能哪种update移动");
            instance.movingBy             = (CLSeeker.MovingBy)EditorGUILayout.EnumPopup(uicontnt, instance.movingBy);
            uicontnt                      = new GUIContent("Moving Unscaled Time", "移动时忽略时间的缩放");
            instance.unscaledTime         = EditorGUILayout.Toggle(uicontnt, instance.unscaledTime);
            ECLEditorUtl.BeginContents();
            {
                uicontnt = new GUIContent("Soften Path", "柔化路径");
                instance.isSoftenPath = EditorGUILayout.Toggle(uicontnt, instance.isSoftenPath);
                if (instance.isSoftenPath)
                {
                    uicontnt = new GUIContent("Soften Type", "柔化路径的方式,line:直接把路径分段的接点处分成两个点进行柔;sler:在路径分段的接点处加入曲面插值");
                    instance.softenPathType = (CLAIPathUtl.SoftenPathType)EditorGUILayout.EnumPopup(uicontnt, instance.softenPathType);
                    if (instance.softenPathType == CLAIPathUtl.SoftenPathType.Slerp)
                    {
                        uicontnt = new GUIContent("Soften Slerp Factor", "曲面插值的个数,【注意】不能太大");
                        instance.softenFactor = EditorGUILayout.IntField(uicontnt, instance.softenFactor);
                    }
                }
            }
            ECLEditorUtl.EndContents();

            uicontnt          = new GUIContent("Debug Show Path", "显示路径");
            instance.showPath = EditorGUILayout.Toggle(uicontnt, instance.showPath);
        }
        ECLEditorUtl.EndContents();

        ECLEditorUtl.BeginContents();
        {
            if (GUILayout.Button("Search"))
            {
                instance.seek(instance.target.position);
            }

            if (GUILayout.Button("SearchTarget"))
            {
                instance.seekTarget(instance.target);
            }
            if (GUILayout.Button("Cancel SearchTarget"))
            {
                instance.cancelSeekTarget();
            }

            if (GUILayout.Button("Begain Move"))
            {
                instance.startMove();
            }

            if (GUILayout.Button("Stop Move"))
            {
                instance.stopMove();
            }
        }
        ECLEditorUtl.EndContents();
    }
Beispiel #7
0
    public override void OnInspectorGUI()
    {
        instance = target as CLSeeker;
        //DrawDefaultInspector();
        ECLEditorUtl.BeginContents();
        {
            EditorGUILayout.HelpBox(
                "配合A星使用的seeker。\n" +
                "主要方法:\n" +
                "  .init();//初始化回调:寻路完成的回调,移动过程中的回调,到达目的地的回调\n" +
                "  .seek();//寻路,完成后会调用在init里设置的回调函数,第一个参数是路径,第二个参数为能否到达目的地\n" +
                "  .seekTarget();//寻路,会定时重新寻目标对象的路径\n" +
                "  .cancelSeekTarget();//取消对目标对象的定时寻路\n" +
                "  .startMove();//开始移动,只能通过此方法,不能直接改变canMove变量\n" +
                "  .stopMove();//停止移动\n"
                , MessageType.None, true);
        }
        ECLEditorUtl.EndContents();

        ECLEditorUtl.BeginContents();
        {
            GUI.color = Color.yellow;
            GUILayout.Label("*鼠标悬停在字段上有解释");
            GUI.color = Color.white;

            GUIContent uicontnt = null;
            uicontnt = new GUIContent("AStar Instance", "A星寻路实例,如果不设值,在运行时自动使用CLAStarPathSearch.current");
            instance.mAStarPathSearch = (CLAStarPathSearch)EditorGUILayout.ObjectField(uicontnt, instance.mAStarPathSearch, typeof(CLAStarPathSearch));
            uicontnt                      = new GUIContent("Target", "目标对象");
            instance.target               = (Transform)EditorGUILayout.ObjectField(uicontnt, instance.target, typeof(Transform));
            uicontnt                      = new GUIContent("Move Speed", "移动速度");
            instance.speed                = EditorGUILayout.FloatField(uicontnt, instance.speed);
            uicontnt                      = new GUIContent("Turning Speed", "转动速度,【注意】当为负数时表示立即转到目标方向,大于0时则会慢慢转向目标方向");
            instance.turningSpeed         = EditorGUILayout.FloatField(uicontnt, instance.turningSpeed);
            uicontnt                      = new GUIContent("EndReached Distance", "离目标到一定距离后结束移动");
            instance.endReachedDistance   = EditorGUILayout.FloatField(uicontnt, instance.endReachedDistance);
            uicontnt                      = new GUIContent("Auto Move After Seek", "当寻路完成后就移动过去");
            instance.autoMoveOnFinishSeek = EditorGUILayout.Toggle(uicontnt, instance.autoMoveOnFinishSeek);
            uicontnt                      = new GUIContent("Moving By", "能哪种update移动");
            instance.movingBy             = (CLSeeker.MovingBy)EditorGUILayout.EnumPopup(uicontnt, instance.movingBy);
            uicontnt                      = new GUIContent("Moving Unscaled Time", "移动时忽略时间的缩放");
            instance.unscaledTime         = EditorGUILayout.Toggle(uicontnt, instance.unscaledTime);
            uicontnt                      = new GUIContent("Debug Show Path", "显示路径");
            instance.showPath             = EditorGUILayout.Toggle(uicontnt, instance.showPath);
        }
        ECLEditorUtl.EndContents();

        ECLEditorUtl.BeginContents();
        {
            if (GUILayout.Button("Search"))
            {
                instance.seek(instance.target.position);
            }

            if (GUILayout.Button("SearchTarget"))
            {
                instance.seekTarget(instance.target);
            }
            if (GUILayout.Button("Cancel SearchTarget"))
            {
                instance.cancelSeekTarget();
            }

            if (GUILayout.Button("Begain Move"))
            {
                instance.startMove();
            }

            if (GUILayout.Button("Stop Move"))
            {
                instance.stopMove();
            }
        }
        ECLEditorUtl.EndContents();
    }
Beispiel #8
0
    void OnGUI()
    {
        if (!ECLProjectSetting.isProjectExit(ECLProjectManager.self))
        {
            GUIStyle style = new GUIStyle();
            style.fontSize         = 20;
            style.normal.textColor = Color.yellow;
            GUILayout.Label("The scene is not ready, create it now?", style);
            if (GUILayout.Button("Show Project Manager"))
            {
                EditorWindow.GetWindow <ECLProjectManager> (false, "CoolapeProject", true);
            }
            Close();
            return;
        }

        if (ECLProjectManager.data.hotUpgradeServers.Count > 0)
        {
            ECLEditorUtl.BeginContents();
            {
                List <string> toolbarNames = new List <string> ();
                for (int i = 0; i < ECLProjectManager.data.hotUpgradeServers.Count; i++)
                {
                    HotUpgradeServerInfor dd = ECLProjectManager.data.hotUpgradeServers [i] as HotUpgradeServerInfor;
                    toolbarNames.Add(dd.name);
                }
                selectedServerIndex = GUILayout.Toolbar(selectedServerIndex, toolbarNames.ToArray());
                HotUpgradeServerInfor hsi = ECLProjectManager.data.hotUpgradeServers [selectedServerIndex] as HotUpgradeServerInfor;
                selectedServer = hsi;
//						ECLProjectSetting.cellServerInor (hsi, false);
                //===================================================
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label("Key:", ECLEditorUtl.width200);
                    GUILayout.TextField(selectedServer.key);
                }
                GUILayout.EndHorizontal();
                //===================================================
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label("Hot Upgrade Base Url:", ECLEditorUtl.width200);
                    GUILayout.TextField(selectedServer.hotUpgradeBaseUrl);
                }
                GUILayout.EndHorizontal();
                //===================================================
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label("Host 4 Upload Upgrade Package:", ECLEditorUtl.width200);
                    GUILayout.TextField(selectedServer.host4UploadUpgradePackage);
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label("Port 4 Upload Upgrade Package:", ECLEditorUtl.width200);
                    EditorGUILayout.IntField(selectedServer.port4UploadUpgradePackage);
                }
                GUILayout.EndHorizontal();
            }
            ECLEditorUtl.EndContents();
        }

        if (selectedServer == null)
        {
            GUILayout.Label("Please select a server!");
            return;
        }

        EditorGUILayout.BeginHorizontal();
        {
            GUI.color = Color.green;
            if (GUILayout.Button("Refresh", GUILayout.Height(40f)))
            {
                setData();
            }
            GUI.color = Color.white;
            if (!isSelectMod)
            {
                if (GUILayout.Button("Save", GUILayout.Height(40f)))
                {
                    if (mList == null || mList.Count == 0)
                    {
                        Debug.LogWarning("Nothing need to save!");
                        return;
                    }
                    string str = JSON.JsonEncode(mList);
                    File.WriteAllText(Application.dataPath + "/" + cfgPath, str);
                }
            }
        }
        EditorGUILayout.EndHorizontal();

        ECLEditorUtl.BeginContents();
        {
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.LabelField("Package Name", GUILayout.Width(160));
                EditorGUILayout.LabelField("MD5", GUILayout.Width(250));
                EditorGUILayout.LabelField("Exist?", GUILayout.Width(40));
                EditorGUILayout.LabelField("Upload?", GUILayout.Width(60));
                EditorGUILayout.LabelField("...", GUILayout.Width(60));
                EditorGUILayout.LabelField("Notes");
            }
            EditorGUILayout.EndHorizontal();
            if (mList == null)
            {
                return;
            }
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(position.width), GUILayout.Height(position.height - 75));
            {
                for (int i = mList.Count - 1; i >= 0; i--)
                {
                    item = ListEx.getMap(mList, i);

                    EditorGUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.TextField(MapEx.getString(item, "name"), GUILayout.Width(160));
                        EditorGUILayout.TextField(MapEx.getString(item, "md5"), GUILayout.Width(250));

                        if (!MapEx.getBool(item, "exist"))
                        {
                            GUI.color = Color.red;
                        }
                        EditorGUILayout.TextField(MapEx.getBool(item, "exist") ? "Yes" : "No", GUILayout.Width(40));
                        GUI.color = Color.white;
                        if (!isUploaded(item))
                        {
                            GUI.color = Color.red;
                        }
                        EditorGUILayout.TextField(isUploaded(item) ? "Yes" : "No", GUILayout.Width(60));
                        GUI.color = Color.white;
                        if (MapEx.getBool(item, "exist"))
                        {
                            GUI.enabled = true;
                        }
                        else
                        {
                            GUI.enabled = false;
                        }
                        GUI.color = Color.yellow;
                        if (isSelectMod)
                        {
                            if (GUILayout.Button("select", GUILayout.Width(60f)))
                            {
                                Close();
                                Utl.doCallback(onSelectedCallback, item, selectedCallbackParams);
                            }
                        }
                        else
                        {
                            if (GUILayout.Button("upload", GUILayout.Width(60f)))
                            {
                                if (EditorUtility.DisplayDialog("Alert", "Really want to upload the upgrade package?", "Okey", "cancel"))
                                {
                                    selectedPackageName = MapEx.getString(item, "name");
                                    uploadUpgradePackage(MapEx.getString(item, "name"));
                                }
                            }
                            if (GUILayout.Button("同步OSS", GUILayout.Width(60f)))
                            {
                                if (EditorUtility.DisplayDialog("Alert", "Really want to upload the upgrade package?", "Okey", "cancel"))
                                {
                                    uploadOss(MapEx.getString(item, "name"));
                                }
                            }
                        }

                        GUI.color       = Color.white;
                        GUI.enabled     = true;
                        item ["remark"] = EditorGUILayout.TextArea(MapEx.getString(item, "remark"));

                        GUILayout.Space(5);
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
            EditorGUILayout.EndScrollView();
        }
        ECLEditorUtl.EndContents();
    }
Beispiel #9
0
    public override void OnInspectorGUI()
    {
        avata = (CLRoleAvata)target;
        ECLEditorUtl.BeginContents();
        {
            if (isAddBones || isShowBones)
            {
                GUILayout.BeginHorizontal();
                {
                    EditorGUILayout.LabelField("Bone Name", GUILayout.Width(100));
                    EditorGUILayout.LabelField("Bone Transform", GUILayout.Width(150));
                }
                GUILayout.EndHorizontal();
            }

            if (isShowBones)
            {
                for (int i = 0; i < avata.bonesNames.Count; i++)
                {
                    GUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.TextField(avata.bonesNames [i], GUILayout.Width(100));
                        EditorGUILayout.ObjectField(avata.bonesList [i], typeof(Transform), GUILayout.Width(150));
                        if (GUILayout.Button("-"))
                        {
                            if (EditorUtility.DisplayDialog("Confirm", "确定要删除?", "Okay", "Cancel"))
                            {
                                avata.bonesNames.RemoveAt(i);
                                avata.bonesList.RemoveAt(i);
                                EditorUtility.SetDirty(avata);
                                break;
                            }
                        }
                    }
                    GUILayout.EndHorizontal();
                }
            }

            if (isAddBones)
            {
                GUILayout.BeginHorizontal();
                {
                    addBoneName = EditorGUILayout.TextField(addBoneName, GUILayout.Width(100));
                    addBone     = (Transform)(EditorGUILayout.ObjectField(addBone, typeof(Transform), GUILayout.Width(150)));
                    if (GUILayout.Button("+"))
                    {
                        if (string.IsNullOrEmpty(addBoneName))
                        {
                            EditorUtility.DisplayDialog("Confirm", "Bone Name can not null?", "Okay");
                            return;
                        }
                        if (avata.bonesMap.ContainsKey(addBoneName))
                        {
                            EditorUtility.DisplayDialog("Confirm", "Bone Name allready exsit, please check then name Uniqueness?", "Okay");
                            return;
                        }
                        if (addBone == null)
                        {
                            EditorUtility.DisplayDialog("Confirm", "Bone can not null?", "Okay");
                            return;
                        }
                        avata.bonesNames.Add(addBoneName);
                        avata.bonesList.Add(addBone);
                        avata.bonesMap [addBoneName] = addBone;
                        EditorUtility.SetDirty(avata);
                        addBone     = null;
                        addBoneName = "";
                    }
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.BeginHorizontal();
            {
                if (GUILayout.Button(isShowBones ? "Hide Bones" : "Show Bones"))
                {
                    isShowBones = !isShowBones;
                }
                if (GUILayout.Button("Add Bones"))
                {
                    isAddBones = true;
                }
            }
            GUILayout.EndHorizontal();
        }
        ECLEditorUtl.EndContents();

        ECLEditorUtl.BeginContents();
        {
            if (avata.bodyPartNames != null)
            {
                for (int i = 0; i < avata.bodyPartNames.Count; i++)
                {
                    GUILayout.BeginHorizontal();
                    {
                        if (selectedPartindex == i)
                        {
                            GUI.color = Color.yellow;
                        }
                        if (GUILayout.Button(avata.bodyPartNames [i]))
                        {
                            selectedPartindex = i;
                            isShowNewBodyPart = false;
                        }
                        GUI.color = Color.white;
                        if (GUILayout.Button("-", GUILayout.Width(30)))
                        {
                            if (EditorUtility.DisplayDialog("Confirm", "确定要删除?", "Okay", "Cancel"))
                            {
                                avata.bodyPartNames.RemoveAt(i);
                                break;
                            }
                        }
                    }
                    GUILayout.EndHorizontal();
                    if (selectedPartindex == i)
                    {
                        avata.bodyParts [i] = showOnePart(avata.bodyParts [i], false);
                    }
                }
            }
            if (isShowNewBodyPart)
            {
                newBodyPart = newBodyPart == null ? new CLBodyPart() : newBodyPart;
                newBodyPart = showOnePart(newBodyPart, true);
                GUILayout.BeginHorizontal();
                {
                    if (GUILayout.Button("Clean"))
                    {
                        newBodyPart.cellNames.Clear();
//                        newBodyPart.materials.Clear ();
                        newBodyPart.materialNames.Clear();
                        newBodyPart.partObjs.Clear();
                        newBodyPart.animatorControllers.Clear();
                        cellName   = "";
                        onePartObj = null;
                    }
                    if (GUILayout.Button("Save Body Part"))
                    {
                        doAddBodyPart();
                    }
                }
                GUILayout.EndHorizontal();
            }

            if (GUILayout.Button("Add Body Part"))
            {
                selectedPartindex = -1;
                newBodyPart       = new CLBodyPart();
                isShowNewBodyPart = true;
            }
        }
        ECLEditorUtl.EndContents();
        testPartName = EditorGUILayout.TextField("Part Name", testPartName);
        testCellName = EditorGUILayout.TextField("Cell Name", testCellName);
        if (GUILayout.Button("test"))
        {
            avata.setMapindex();
            avata.switch2xx(testPartName, testCellName);
        }

        if (GUILayout.Button("clean Material"))
        {
            avata.cleanMaterial();
        }
        if (GUILayout.Button("set Default Material"))
        {
            avata.setDefaultMaterial();
        }
    }
Beispiel #10
0
    void showSpriteInfor()
    {
        if (currSelectSprite == null)
        {
            return;
        }
        Hashtable d             = MapEx.getMap(currSelectSprite, "data");
        int       times         = MapEx.getInt(currSelectSprite, "times");
        string    name          = MapEx.getString(d, "name");
        string    path          = MapEx.getString(d, "path");
        int       x             = MapEx.getInt(d, "x");
        int       y             = MapEx.getInt(d, "y");
        int       width         = MapEx.getInt(d, "width");
        int       height        = MapEx.getInt(d, "height");
        int       borderLeft    = MapEx.getInt(d, "borderLeft");
        int       borderRight   = MapEx.getInt(d, "borderRight");
        int       borderTop     = MapEx.getInt(d, "borderTop");
        int       borderBottom  = MapEx.getInt(d, "borderBottom");
        int       paddingLeft   = MapEx.getInt(d, "paddingLeft");
        int       paddingRight  = MapEx.getInt(d, "paddingRight");
        int       paddingTop    = MapEx.getInt(d, "paddingTop");
        int       paddingBottom = MapEx.getInt(d, "paddingBottom");
        Hashtable atlas         = MapEx.getMap(currSelectSprite, "atlas");
        string    atlasStr      = "";

        foreach (DictionaryEntry item in atlas)
        {
            atlasStr = PStr.b().a(atlasStr).a(",").a(item.Key.ToString()).e();
        }
        Texture tex = ECLEditorUtl.getObjectByPath(path) as Texture;
        Rect    r   = Rect.zero;

        if (tex != null)
        {
            float h    = 0;
            float w    = position.width - 160;
            float rate = w / tex.width;
            if (rate < 1)
            {
                h = tex.height * rate;
            }
            else
            {
                h = tex.height;
            }
            h = h > 200 ? h : 200;
            r = new Rect(0, 0, NumEx.getIntPart(w), NumEx.getIntPart(h));
            GUI.DrawTexture(r, tex, ScaleMode.ScaleToFit);
            GUILayout.Space(r.height + r.y);                    //这句主要目的是为了可以滑动
        }
        else
        {
            r = new Rect(0, 0, position.width - 160, 100);
            GUILayout.Space(r.height + r.y);                    //这句主要目的是为了可以滑动
        }

        GUILayout.Space(10);
        ECLEditorUtl.BeginContents();
        {
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.TextField("name", name);
                EditorGUILayout.IntField("times", times);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.IntField("x", x);
                EditorGUILayout.IntField("y", y);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.IntField("width", width);
                EditorGUILayout.IntField("height", height);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.IntField("borderLeft", borderLeft);
                EditorGUILayout.IntField("borderRight", borderRight);
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.IntField("borderTop", borderTop);
                EditorGUILayout.IntField("borderBottom", borderBottom);
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.IntField("paddingLeft", paddingLeft);
                EditorGUILayout.IntField("paddingRight", paddingRight);
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.IntField("paddingTop", paddingTop);
                EditorGUILayout.IntField("paddingBottom", paddingBottom);
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.TextField("path", path);
            EditorGUILayout.TextField("Atlas", atlasStr);
        }
        ECLEditorUtl.EndContents();
    }
Beispiel #11
0
    void OnGUI()
    {
        GUILayout.Space(5);
        ECLEditorUtl.BeginContents();
        {
            EditorGUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Sprites Borrow Infor File", ECLEditorUtl.width150))
                {
                    string _mSpritesBorrowInforFile = EditorUtility.OpenFilePanel("Select Infor File", Application.dataPath + "/KOK/xRes/spriteBorrow", "json");
                    if (!mSpritesBorrowInforFile.Equals(_mSpritesBorrowInforFile))
                    {
                        mSpritesBorrowInforFile = _mSpritesBorrowInforFile;
                        initData();
                    }
                }
                if (GUILayout.Button("Refresh", ECLEditorUtl.width80))
                {
                    initData();
                }
                GUILayout.TextField(mSpritesBorrowInforFile);
            }
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(5);
            EditorGUILayout.BeginHorizontal();
            {
                packerSize = (PackerSize)EditorGUILayout.EnumPopup("", packerSize);
                GUI.color  = Color.yellow;
                if (GUILayout.Button("Packer View"))
                {
                    isShowParckerView = true;
                    currSelectSprite  = null;
                }
                GUI.color = Color.white;
            }
            EditorGUILayout.EndHorizontal();
        }
        ECLEditorUtl.EndContents();
        GUILayout.Space(5);

        EditorGUILayout.BeginHorizontal();
        {
            EditorGUILayout.BeginVertical();
            {
                bool _isSelectedAll = EditorGUILayout.ToggleLeft("All", isSelectedAll, ECLEditorUtl.width150);
                if (isSelectedAll != _isSelectedAll)
                {
                    isSelectedAll = _isSelectedAll;
                    for (int i = 0; i < mSpriteList.Count && i < (int)packerSize; i++)
                    {
                        item = mSpriteList [i] as Hashtable;
                        item ["selected"] = isSelectedAll;
                    }
                    refreshSelectedCount();
                }
                scrollPos = EditorGUILayout.BeginScrollView(scrollPos, ECLEditorUtl.width150);
                {
                    rect.y = 0;
                    ECLEditorUtl.BeginContents();
                    {
//						GUILayout.Space (10);
                        for (int i = 0; i < mSpriteList.Count && i < (int)packerSize; i++)
                        {
                            item = mSpriteList [i] as Hashtable;
                            bool selected = GUI.Toggle(new Rect(5, rect.y, 50, cellSize + 30), MapEx.getBool(item, "selected"), (i + 1).ToString());
                            if (selected != MapEx.getBool(item, "selected"))
                            {
                                item ["selected"] = selected;
                                refreshSelectedCount();
                            }
                            showCellSprite(item);
                        }
                    }
                    ECLEditorUtl.EndContents();
                }
                EditorGUILayout.EndScrollView();
            }
            EditorGUILayout.EndVertical();
            //=========================================
            //=========================================
            EditorGUILayout.BeginVertical();
            {
                GUILayout.Label(PStr.b().a("Selected: ").a(selectedCount).a("/").a(allSpriteCount).e());
                scrollPos2 = EditorGUILayout.BeginScrollView(scrollPos2, GUILayout.Width(position.width - 150));
                {
                    ECLEditorUtl.BeginContents();
                    {
                        if (isShowParckerView)
                        {
                            showPackerView();
                        }
                        else
                        {
                            showSpriteInfor();
                        }
                    }
                    ECLEditorUtl.EndContents();
                }
                EditorGUILayout.EndScrollView();
            }
            EditorGUILayout.EndVertical();
        }
        EditorGUILayout.EndHorizontal();
    }
Beispiel #12
0
    void showPackerView()
    {
        if (packTex != null)
        {
            //=================
            float h    = 0;
            float w    = position.width - 160;
            float rate = w / packTex.width;
            if (rate < 1)
            {
                h = packTex.height * rate;
            }
            else
            {
                h = packTex.height;
            }
            h = h > 512 ? h : 512;
            Rect r = new Rect(0, 0, NumEx.getIntPart(w), NumEx.getIntPart(h));
            NGUIEditorTools.DrawTiledTexture(r, NGUIEditorTools.backdropTexture);
            if (isShowParckerTextureBg)
            {
                GUI.DrawTexture(r, _empty, ScaleMode.ScaleToFit, false);
            }
            GUI.DrawTexture(r, packTex, ScaleMode.ScaleToFit);
            GUILayout.Space(r.height + r.y);                    //这句主要目的是为了可以滑动

            ECLEditorUtl.BeginContents();
            {
                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUILayout.IntField("width", packTex.width);
                    EditorGUILayout.IntField("height", packTex.height);
                }
                EditorGUILayout.EndHorizontal();
                if (GUILayout.Button("Show/Hide Detail"))
                {
                    showDeltail = !showDeltail;
                }
                if (showDeltail)
                {
                    if (packSprites != null)
                    {
                        Hashtable m = null;
                        Hashtable d = null;
                        Rect      _rect;
                        for (int i = 0; i < packSprites.Count; i++)
                        {
                            _rect = packRects [i];
                            m     = packSprites [i] as Hashtable;
                            d     = MapEx.getMap(m, "data");
                            EditorGUILayout.BeginHorizontal();
                            {
                                EditorGUILayout.LabelField(MapEx.getString(d, "name"));
                                EditorGUILayout.LabelField(Mathf.RoundToInt(_rect.x) + "x" + Mathf.RoundToInt(_rect.y));
                                EditorGUILayout.LabelField(Mathf.RoundToInt(_rect.width) + "x" + Mathf.RoundToInt(_rect.height));
                            }
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                }
            }
            ECLEditorUtl.EndContents();
        }

        isShowParckerTextureBg = EditorGUILayout.ToggleLeft("Show Background", isShowParckerTextureBg);
        textureSize            = (PackerTextureSize)EditorGUILayout.EnumPopup("", textureSize);
        isUseUnityPacking      = EditorGUILayout.ToggleLeft("UnityPacking", isUseUnityPacking);
        sortSprite             = (SortSprite)EditorGUILayout.EnumPopup("", sortSprite);
        GUILayout.Space(5);
        GUI.color = Color.yellow;
        if (GUILayout.Button("Review Pack Texture"))
        {
            if (!packTextures((int)textureSize, isUseUnityPacking))
            {
                Debug.LogError("Some errors happened!");
            }
        }
        GUI.color = Color.white;
        GUILayout.Space(10);

        ECLEditorUtl.BeginContents();
        {
            packedName       = EditorGUILayout.TextField("Packed Texture Name", string.IsNullOrEmpty(packedName) ? "Packed" + (int)packerSize : packedName);
            GUI.color        = Color.red;
            removePublishRes = EditorGUILayout.ToggleLeft("Remove Publish AssetsBundle", removePublishRes);
            if (GUILayout.Button("Apply Pack Texture"))
            {
                applyPackTexture((int)textureSize, isUseUnityPacking);
            }
            GUI.color = Color.white;
        }
        ECLEditorUtl.EndContents();
    }
    public override void OnInspectorGUI()
    {
        instance = target as CLSharedAssets;
        ECLEditorUtl.BeginContents();
        {
            GUI.color = Color.yellow;
            instance.isDonnotResetAssets = EditorGUILayout.Toggle("is Donnot Reset Assets", instance.isDonnotResetAssets);
            instance.isSkipModel         = EditorGUILayout.Toggle("is Skip Manage Model", instance.isSkipModel);
            GUI.color = Color.white;
        }
        ECLEditorUtl.EndContents();

        if (state1)
        {
            tabName = "Click Close Materials";
        }
        else
        {
            tabName = "Click Open Materials";
        }
        using (new FoldableBlock(ref state1, tabName, null)) {
            if (state1)
            {
                for (int i = 0; i < instance.materials.Count; i++)
                {
                    ECLEditorUtl.BeginContents();
                    {
                        GUILayout.BeginHorizontal();
                        {
                            EditorGUILayout.ObjectField("Render", (Object)(instance.materials [i].render), typeof(Renderer), true);
                            GUI.color = Color.red;
                            if (GUILayout.Button("Delete", GUILayout.Width(60)))
                            {
                                if (EditorUtility.DisplayDialog("Alert", "Really want to delete?", "Okay", "Cancel"))
                                {
                                    instance.materials.RemoveAt(i);
                                    break;
                                }
                            }
                            GUI.color = Color.white;
                        }
                        GUILayout.EndHorizontal();
//				EditorGUILayout.IntField ("Index", instance.materials [i].index);
                        EditorGUILayout.TextField("Material Name", instance.materials [i].materialName);
                        EditorGUILayout.ObjectField("Material", (Object)(getMaterial(instance.materials [i].materialName)), typeof(Material), true);
                    }
                    ECLEditorUtl.EndContents();
                }
            }
        }


        if (state2)
        {
            tabName = "Click Close Meshs";
        }
        else
        {
            tabName = "Click Open Meshs";
        }
        using (new FoldableBlock(ref state2, tabName, null)) {
            if (state2)
            {
                for (int i = 0; i < instance.meshs.Count; i++)
                {
                    ECLEditorUtl.BeginContents();
                    {
                        GUILayout.BeginHorizontal();
                        {
                            if (instance.meshs [i].meshFilter != null)
                            {
                                EditorGUILayout.ObjectField("Mesh Fiter", (Object)(instance.meshs [i].meshFilter), typeof(MeshFilter), true);
                            }
                            else if (instance.meshs[i].skinnedMesh != null)
                            {
                                EditorGUILayout.ObjectField("Skinned Mesh", (Object)(instance.meshs [i].skinnedMesh), typeof(SkinnedMeshRenderer), true);
                            }
                            else if (instance.meshs[i].animator != null)
                            {
                                EditorGUILayout.ObjectField("Animator", (Object)(instance.meshs[i].animator), typeof(Animator), true);
                            }

                            GUI.color = Color.red;
                            if (GUILayout.Button("Delete", GUILayout.Width(60)))
                            {
                                if (EditorUtility.DisplayDialog("Alert", "Really want to delete?", "Okay", "Cancel"))
                                {
                                    instance.meshs.RemoveAt(i);
                                    break;
                                }
                            }
                            GUI.color = Color.white;
                        }
                        GUILayout.EndHorizontal();

                        if (instance.meshs [i].animator != null)
                        {
                            EditorGUILayout.ObjectField("Avatar", (Object)(getAvatar(instance.meshs [i].modelName)), typeof(Avatar), true);
                        }
                        EditorGUILayout.TextField("Model Name", instance.meshs [i].modelName);
                        EditorGUILayout.ObjectField("Mesh", (Object)(getMesh(instance.meshs [i].modelName, instance.meshs [i].meshName)), typeof(Mesh), true);
                    }
                    ECLEditorUtl.EndContents();
                }
            }
        }

        GUILayout.BeginHorizontal();
        {
            if (GUILayout.Button("Get"))
            {
                getAssets(instance, instance.transform);
                EditorUtility.SetDirty(instance);
                EditorUtility.DisplayDialog("Success", "Finish get Assets", "Okay");
            }

            if (GUILayout.Button("Clean"))
            {
                cleanMaterialInfor();
                EditorUtility.DisplayDialog("Success", "Finish clean Assets", "Okay");
            }

            if (GUILayout.Button("Reset"))
            {
                instance.reset();
                instance.resetAssets();
                EditorUtility.DisplayDialog("Success", "Finish reset Assets", "Okay");
            }
        }
        GUILayout.EndHorizontal();

//		base.OnInspectorGUI ();

        GUILayout.Space(3f);
        NGUIEditorTools.SetLabelWidth(80f);
        bool minimalistic = NGUISettings.minimalisticLook;

        DrawEvents("CLS0", "On Finish Load", instance.onFinshLoad, minimalistic);
    }
    void OnGUI()
    {
        if (!ECLProjectSetting.isProjectExit(ECLProjectManager.self))
        {
            GUIStyle style = new GUIStyle();
            style.fontSize         = 20;
            style.normal.textColor = Color.yellow;
            GUILayout.Label("The scene is not ready, create it now?", style);
            if (GUILayout.Button("Show Project Manager"))
            {
                EditorWindow.GetWindow <ECLProjectManager> (false, "CoolapeProject", true);
            }
            Close();
            return;
        }

        if (ECLProjectManager.data.hotUpgradeServers.Count <= 0)
        {
            GUI.color = Color.red;
            GUILayout.Label("There is no server");
            GUI.color = Color.white;
            return;
        }
        if (ECLProjectManager.data.hotUpgradeServers.Count > 0)
        {
            ECLEditorUtl.BeginContents();
            {
                List <string> toolbarNames = new List <string> ();
                for (int i = 0; i < ECLProjectManager.data.hotUpgradeServers.Count; i++)
                {
                    HotUpgradeServerInfor dd = ECLProjectManager.data.hotUpgradeServers [i] as HotUpgradeServerInfor;
                    toolbarNames.Add(dd.name);
                }
                int index = GUILayout.Toolbar(selectedServerIndex, toolbarNames.ToArray());
                HotUpgradeServerInfor hsi = ECLProjectManager.data.hotUpgradeServers [index] as HotUpgradeServerInfor;
                selectedServer = hsi;

                if (selectedServerIndex != index)
                {
                    selectedServerIndex = index;
                    refreshData();
                }
                //===================================================
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label("Key:", ECLEditorUtl.width200);
                    GUILayout.TextField(selectedServer.key);
                }
                GUILayout.EndHorizontal();
                //===================================================
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label("URL of get server list:", ECLEditorUtl.width200);
                    GUILayout.TextField(selectedServer.getServerListUrl);
                }
                GUILayout.EndHorizontal();
                //===================================================
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label("URL of set upgrade pkg md5:", ECLEditorUtl.width200);
                    GUILayout.TextField(selectedServer.setServerPkgMd5Url);
                }
                GUILayout.EndHorizontal();
            }
            ECLEditorUtl.EndContents();
        }

        GUI.color = Color.green;
        if (GUILayout.Button("Refresh"))
        {
            refreshData();
        }
        GUI.color = Color.white;
        if (servers == null || servers.Count == 0)
        {
            return;
        }
        GUILayout.Space(5);
        EditorGUILayout.BeginHorizontal();
        {
            if (GUILayout.Button("All", GUILayout.Width(30)))
            {
                isSelectAll = !isSelectAll;
                foreach (DictionaryEntry cell in servers)
                {
                    server = (Hashtable)(cell.Value);
                    server ["selected"] = isSelectAll;
                }
            }
            EditorGUILayout.LabelField("SID", GUILayout.Width(80));
            EditorGUILayout.LabelField("SName", GUILayout.Width(100));
            GUI.color = Color.yellow;
#if UNITY_ANDROID
            EditorGUILayout.LabelField("UpgradeMd5Ver(Android)", GUILayout.Width(250));
#elif UNITY_IPHONE || UNITY_IOS
            EditorGUILayout.LabelField("UpgradeMd5Ver(ios)", GUILayout.Width(250));
#elif UNITY_STANDALONE_WIN
            EditorGUILayout.LabelField("UpgradeMd5Ver(win)", GUILayout.Width(250));
#elif UNITY_STANDALONE_OSX
            EditorGUILayout.LabelField("UpgradeMd5Ver(osx)", GUILayout.Width(250));
#elif UNITY_WEBGL
            EditorGUILayout.LabelField("UpgradeMd5Ver(webgl)", GUILayout.Width(250));
#endif
            EditorGUILayout.LabelField("UpgradePkg Name", GUILayout.Width(160));
            EditorGUILayout.LabelField("UpgradePkg Mark", GUILayout.Width(250));
            GUI.color = Color.white;
#if UNITY_ANDROID
            if (GUILayout.Button("Select Md5(Android)"))
            {
                setUpgradePkgMutlMode("Android");
            }
#elif UNITY_IPHONE || UNITY_IOS
            if (GUILayout.Button("Select Md5(ios)"))
            {
                setUpgradePkgMutlMode("ios");
            }
#elif UNITY_STANDALONE_WIN
            if (GUILayout.Button("Select Md5(win)"))
            {
                setUpgradePkgMutlMode("win");
            }
#elif UNITY_STANDALONE_OSX
            if (GUILayout.Button("Select Md5(osx)"))
            {
                setUpgradePkgMutlMode("osx");
            }
#elif UNITY_WEBGL
            if (GUILayout.Button("Select Md5(webgl)"))
            {
                setUpgradePkgMutlMode("webgl");
            }
#endif
        }
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(5);
        ECLEditorUtl.BeginContents();
        {
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(position.width), GUILayout.Height(position.height - 50));
            {
                foreach (DictionaryEntry cell in servers)
                {
                    server = (Hashtable)(cell.Value);
                    EditorGUILayout.BeginHorizontal();
                    {
                        server ["selected"] = EditorGUILayout.Toggle(MapEx.getBool(server, "selected"), GUILayout.Width(30));
                        if (MapEx.getBool(server, "selected"))
                        {
                            GUI.color = Color.cyan;
                        }
                        else
                        {
                            GUI.color = Color.white;
                        }
                        EditorGUILayout.TextField(MapEx.getString(server, "idx"), GUILayout.Width(80));
                        EditorGUILayout.TextField(MapEx.getString(server, "servername"), GUILayout.Width(100));
                        GUI.color = Color.yellow;
#if UNITY_ANDROID
                        EditorGUILayout.TextField(MapEx.getString(server, "androidversion"), GUILayout.Width(250));
#elif UNITY_IPHONE || UNITY_IOS
                        EditorGUILayout.TextField(MapEx.getString(server, "iosversion"), GUILayout.Width(250));
#elif UNITY_STANDALONE_WIN
                        EditorGUILayout.TextField(MapEx.getString(server, "winversion"), GUILayout.Width(250));
#elif UNITY_STANDALONE_OSX
                        EditorGUILayout.TextField(MapEx.getString(server, "osxversion"), GUILayout.Width(250));
#elif UNITY_WEBGL
                        EditorGUILayout.TextField(MapEx.getString(server, "webglversion"), GUILayout.Width(250));
#endif
                        EditorGUILayout.TextField(MapEx.getString(server, "pkgName"), GUILayout.Width(160));
                        EditorGUILayout.TextArea(MapEx.getString(server, "pkgRemark"), GUILayout.Width(250));
                        GUI.color = Color.white;
#if UNITY_ANDROID
                        if (GUILayout.Button("Select Md5(Android)"))
                        {
                            ECLUpgradeListProc.popup4Select((Callback)onGetUpgradePkg, ListEx.builder().Add(cell.Key).Add("Android").ToList());
                        }
#elif UNITY_IPHONE || UNITY_IOS
                        if (GUILayout.Button("Select Md5(ios)"))
                        {
                            ECLUpgradeListProc.popup4Select((Callback)onGetUpgradePkg, ListEx.builder().Add(cell.Key).Add("ios").ToList());
                        }
#elif UNITY_STANDALONE_WIN
                        if (GUILayout.Button("Select Md5(win)"))
                        {
                            ECLUpgradeListProc.popup4Select((Callback)onGetUpgradePkg, ListEx.builder().Add(cell.Key).Add("win").ToList());
                        }
#elif UNITY_STANDALONE_OSX
                        if (GUILayout.Button("Select Md5(osx)"))
                        {
                            ECLUpgradeListProc.popup4Select((Callback)onGetUpgradePkg, ListEx.builder().Add(cell.Key).Add("osx").ToList());
                        }
#elif UNITY_WEBGL
                        if (GUILayout.Button("Select Md5(webgl)"))
                        {
                            ECLUpgradeListProc.popup4Select((Callback)onGetUpgradePkg, ListEx.builder().Add(cell.Key).Add("wegbl").ToList());
                        }
#endif
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
            EditorGUILayout.EndScrollView();
        }
        ECLEditorUtl.EndContents();
    }
Beispiel #15
0
    void showAttrs()
    {
        if (editorCfg == null)
        {
            isInited = false;
            init();
        }
        GUILayout.BeginHorizontal();
        {
            GUILayout.Label("地图大小", ECLEditorUtl.width200);
            editorCfg.size = EditorGUILayout.IntField(editorCfg.size);
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        {
            GUILayout.Label("一屏的大小", ECLEditorUtl.width200);
            editorCfg.pageSize = EditorGUILayout.IntField(editorCfg.pageSize);
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        {
            GUILayout.Label("地图分区的色块图", ECLEditorUtl.width200);

            editorCfg.oceanGidTexture =
                EditorGUILayout.ObjectField(
                    editorCfg.oceanGidTexture,
                    typeof(Texture2D), false) as Texture2D;
            if (GUILayout.Button("Reset Mode"))
            {
                resetTextrueMode();
            }
        }
        GUILayout.EndHorizontal();
        GUILayout.Label("颜色值与地图分区值的对应", ECLEditorUtl.width200);
        ECLEditorUtl.BeginContents();
        {
            GUILayout.BeginVertical();
            {
                foreach (var cell in editorCfg.colors4MapArea)
                {
                    GUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.ColorField(cell.Key);
                        EditorGUILayout.IntField(cell.Value);
                        if (GUILayout.Button("-"))
                        {
                            editorCfg.colors4MapArea.Remove(cell.Key);
                            break;
                        }
                    }
                    GUILayout.EndHorizontal();
                }
                GUI.color = Color.yellow;
                GUILayout.BeginHorizontal();
                {
                    tmpColor    = EditorGUILayout.ColorField(tmpColor);
                    tmpOceanGid = EditorGUILayout.IntField(tmpOceanGid);
                    if (GUILayout.Button("+"))
                    {
                        editorCfg.colors4MapArea[tmpColor] = tmpOceanGid;
                        tmpOceanGid = 0;
                    }
                }
                GUILayout.EndHorizontal();
                GUI.color = Color.white;
            }
            GUILayout.EndVertical();
        }
        ECLEditorUtl.EndContents();
    }
    public override void OnInspectorGUI()
    {
        instance = target as CLAStarPathSearch;
        //DrawDefaultInspector();
        ECLEditorUtl.BeginContents();
        {
            EditorGUILayout.HelpBox(
                "简单的A星寻路,目前只支持y轴朝上的情况,不支持有高度的寻路。\n" +
                "主要方法:\n" +
                "  CLAStarPathSearch.current. //当前A星的实例\n" +
                "  .init();//初始化网格\n" +
                "  .scan();//扫描网格,就是设置哪些格子是不可通过的\n" +
                "  .scanRange(center, r);//刷新坐标center,半径为r的网格的障碍状态\n" +
                "  .searchPath(from, to, out vectorList);//寻路"
                , MessageType.None, true);
        }
        ECLEditorUtl.EndContents();

        ECLEditorUtl.BeginContents();
        {
            GUI.color = Color.yellow;
            GUILayout.Label("*鼠标悬停在字段上有解释");
            GUI.color = Color.white;

            GUIContent uicontnt = null;
            uicontnt               = new GUIContent("Row", "行(网格的长)");
            instance.numRows       = EditorGUILayout.IntField(uicontnt, instance.numRows);
            uicontnt               = new GUIContent("Column", "列(网格的宽)");
            instance.numCols       = EditorGUILayout.IntField(uicontnt, instance.numCols);
            uicontnt               = new GUIContent("Cell Size", "网格单元的大小");
            instance.cellSize      = EditorGUILayout.FloatField(uicontnt, instance.cellSize);
            uicontnt               = new GUIContent("Neighbours", "一个单元格的寻路方向数量。(4方向/8方向)");
            instance.numNeighbours = (CLAStarPathSearch.NumNeighbours)(EditorGUILayout.EnumPopup(uicontnt, instance.numNeighbours));
            uicontnt               = new GUIContent("Scan Type", "扫描类型.ObstructNode:扫描障碍层设置不可通行的格子;PassableNode:扫描设置可通行的节点;");
            instance.scanType      = (CLAStarPathSearch.ScanType)EditorGUILayout.EnumPopup(uicontnt, instance.scanType);
            //if (instance.scanType == CLAStarPathSearch.ScanType.PassableNode)
            //{
            //    GUI.enabled = false;
            //}
            uicontnt = new GUIContent("Obstruct Mask", "障碍物的layer");
            instance.obstructMask = ECLEditorUtl.drawMaskField(uicontnt, instance.obstructMask);

            GUI.enabled = true;
            if (instance.scanType == CLAStarPathSearch.ScanType.ObstructNode)
            {
                GUI.enabled = false;
            }
            uicontnt = new GUIContent("Passable Mask", "可通行节点的layer");
            instance.passableMask = ECLEditorUtl.drawMaskField(uicontnt, instance.passableMask);
            GUI.enabled           = true;

            uicontnt = new GUIContent("Scan Ray Direction", "射线检测障碍的发射方向");
            instance.rayDirection = (CLAStarPathSearch.RayDirection)(EditorGUILayout.EnumPopup(uicontnt, instance.rayDirection));
            uicontnt                = new GUIContent("Scan Ray Distance", "射线检测障碍的和射线长度");
            instance.rayDis4Scan    = EditorGUILayout.FloatField(uicontnt, instance.rayDis4Scan);
            uicontnt                = new GUIContent("Auto Scan", "自动扫描网格的障碍,其实就是在Start方法中自动调用init和Scan方法");
            instance.isAutoScan     = EditorGUILayout.Toggle(uicontnt, instance.isAutoScan);
            uicontnt                = new GUIContent("Need Cache Paths", "把寻路得到的数据缓存起来,可以重复使用");
            instance.needCachePaths = EditorGUILayout.Toggle(uicontnt, instance.needCachePaths);
            ECLEditorUtl.BeginContents();
            {
                uicontnt = new GUIContent("Filter Path By Ray", "通过射线检测障碍来过滤掉冗余的点,因此要注意障碍物的collider的高度及大小,以免射线检测不到");
                instance.isFilterPathByRay = EditorGUILayout.Toggle(uicontnt, instance.isFilterPathByRay);

                uicontnt = new GUIContent("Soften Path", "柔化路径");
                instance.isSoftenPath = EditorGUILayout.Toggle(uicontnt, instance.isSoftenPath);
                if (instance.isSoftenPath)
                {
                    uicontnt = new GUIContent("Soften Type", "柔化路径的方式,line:直接把路径分段的接点处分成两个点进行柔;sler:在路径分段的接点处加入曲面插值");
                    instance.softenPathType = (CLAIPathUtl.SoftenPathType)EditorGUILayout.EnumPopup(uicontnt, instance.softenPathType);
                    if (instance.softenPathType == CLAIPathUtl.SoftenPathType.Slerp)
                    {
                        uicontnt = new GUIContent("Soften Slerp Factor", "曲面插值的个数,【注意】不能太大");
                        instance.softenFactor = EditorGUILayout.IntField(uicontnt, instance.softenFactor);
                    }
                }
            }
            ECLEditorUtl.EndContents();
            uicontnt              = new GUIContent("Debug Show Grid", "显示网格");
            instance.showGrid     = EditorGUILayout.Toggle(uicontnt, instance.showGrid);
            uicontnt              = new GUIContent("Debug Show Obstruct", "显示网格障碍");
            instance.showObstruct = EditorGUILayout.Toggle(uicontnt, instance.showObstruct);
        }
        ECLEditorUtl.EndContents();

        ECLEditorUtl.BeginContents();
        {
            if (GUILayout.Button("init"))
            {
                instance.init();
            }
            if (GUILayout.Button("Scan"))
            {
                instance.scan();
            }
        }
        ECLEditorUtl.EndContents();
        EditorUtility.SetDirty(target);
    }