Ejemplo n.º 1
0
    public override void DoEvent()
    {
        if (GameTimer.Within(farther.startTime, this.StartTime))
        {
            return;
        }
        Active    = false;
        isDoEvent = true;
        bornTime  = GameTimer.time;
        if (IsDo)
        {
            return;
        }
        IsDo = true;
        GameObject obj  = AssetDatabase.LoadAssetAtPath <GameObject>(string.Format("Assets/res_sourcefile/role/{0}.prefab", config.CallApprid));
        Role       role = obj.GetComponent <Role>();

        xpModel = ModelLoader.CreateRole(role, false);
        for (int i = 0; i < parent.Skins.Count; i++)
        {
            if (parent.Skins[i])
            {
                parent.Skins[i].SetActive(false);
            }
        }
    }
Ejemplo n.º 2
0
    private IEnumerator LoadRoleObject(string path, Action <RoleObject> loadFinish)
    {
        UnityEngine.Object role    = null;
        TLEditorWww        roleWww = null;

        if (!roleAssetsWww.TryGetValue(path, out roleWww))
        {
            roleWww = TLEditorWww.Create(path);
            roleAssetsWww.Add(path, roleWww);
        }

        while (!roleWww.Finished)
        {
            yield return(null);
        }

        if (!roleAssets.TryGetValue(path, out role))
        {
            role = roleWww.GetCachedAsset() as GameObject;
            GameManager.ReplaceShader(role, string.Empty);
            roleAssets.Add(path, role);
        }

        if (role == null)
        {
            Debug.LogError("Error, Load role Failed: " + path);
        }
        else
        {
            Role roleConfig = (role as GameObject).GetComponent <Role>();
            if (roleConfig == null)
            {
                Debug.Log("config==null");
            }
            GameObject roleGo    = ModelLoader.CreateRole(roleConfig).gameObject;
            var        performer = roleGo.GetComponent <ActionPerformer>();
            RoleObject roleObj   = roleGo.GetComponent <RoleObject>();
            roleObj.needAnimationButtonGui = false;
            roleObj.CheckAnimator();
            roleObj.enabled = true;
            //roleWww.Unload();
            loadFinish(roleObj);
        }
    }
Ejemplo n.º 3
0
        public IEnumerator LoadRoleObject(string path, System.Action <MPObject> loadFinish)
        {
            TLEditorWww roleWww = TLEditorWww.Create(path);

            while (!roleWww.Finished)
            {
                yield return(null);
            }
            GameObject role = null;

            role = roleWww.GetAsset() as GameObject;
            ReplaceShader(role, string.Empty);
            if (role == null)
            {
                Debug.LogError("Error, Load role Failed: " + path);
                roleWww.Unload();
            }
            else
            {
                Role roleConfig = role.GetComponent <Role>();
                if (roleConfig == null)
                {
                    Debug.Log("Error,can't find role component");
                }
                GameObject roleGo = ModelLoader.CreateRole(roleConfig).gameObject;
                roleGo.gameObject.GetComponent <ActionPerformer>().enabled = false;
                roleGo.gameObject.GetComponent <RoleObject>().enabled      = false;
                roleWww.Unload();
                this.mapGO      = roleGo;
                this.mapGO.name = sn.ToString();
                BoxCollider bc = this.mapGO.AddComponent <BoxCollider>();
                bc.size   = new Vector3(1, 2, 1);
                bc.center = new Vector3(0, 1, 0);
                XYClientCommon.ChangeLayer(this.mapGO, XYDefines.Layer.Player, true);
                loadFinish(this);
            }
        }
Ejemplo n.º 4
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        GUILayout.Space(50);

        //if (!Role.Skin && Role.BaseLook.Length == 0)
        //    Role.Skin = Role.GetComponentInChildren<SkinnedMeshRenderer>();

        if (GUILayout.Button("Save"))
        {
            AssetDatabase.SaveAssets();
        }

        if (GUILayout.Button("Build"))
        {
            AssetExporter.GetShaders();
            AssetExporter.GetPublicAssets();
            AssetExporter.BuildAssetBundles(this.Role.gameObject);
            Selection.activeObject = this.serializedObject.targetObject;
        }

        if (GUILayout.Button("生成控制器"))
        {
            if (Selection.activeObject != this.Role.gameObject)
            {
                return;
            }
            string rootpath = Path.GetDirectoryName(AssetDatabase.GetAssetPath(Selection.activeObject));
            Selection.activeObject = AssetDatabase.LoadAssetAtPath(rootpath, typeof(Object));

            Object[] clips    = Selection.GetFiltered(typeof(AnimationClip), SelectionMode.DeepAssets);
            Animator animator = this.Role.gameObject.GetComponent <Animator>();
            animator.runtimeAnimatorController = AssetExporter.CreateOverrideController(string.Format("{0}.controller", this.Role.gameObject.name), rootpath, clips);
        }

        if (GUILayout.Button("生成骨骼数据"))
        {
            if (Selection.activeObject != this.Role.gameObject)
            {
                return;
            }
            Transform[]       bones  = this.Role.gameObject.GetComponentsInChildren <Transform>(true);
            List <GameObject> golist = new List <GameObject>();
            for (int i = 0; i < bones.Length; i++)
            {
                golist.Add(bones[i].gameObject);
            }

            this.Role.Bones = golist.ToArray();
        }

        if (GUILayout.Button("复制动画"))
        {
            if (Role != null)
            {
                List <OverrideAnimiClip> list = new List <OverrideAnimiClip>();
                Animator roleAnimator         = Role.GetComponent <Animator>();
                if (roleAnimator == null || !(roleAnimator.runtimeAnimatorController is AnimatorOverrideController) || roleAnimator.avatar == null)
                {
                    return;
                }
                AnimatorOverrideController Controller = roleAnimator.runtimeAnimatorController as AnimatorOverrideController;
                List <KeyValuePair <AnimationClip, AnimationClip> > overrides = new List <KeyValuePair <AnimationClip, AnimationClip> >();
                Controller.GetOverrides(overrides);

                for (int i = 0; i < overrides.Count; i++)
                {
                    KeyValuePair <AnimationClip, AnimationClip> kvp = overrides[i];
                    if (kvp.Value == null)
                    {
                        continue;
                    }
                    list.Add(new OverrideAnimiClip(kvp.Key.name, kvp.Value));
                }
                Role.AnimiClips = list.ToArray();
            }
        }

        if (GUILayout.Button("添加目标"))
        {
            if (!ModelLoader.self)
            {
                return;
            }
            RoleObject target = ModelLoader.CreateRole(this.Role, false);
            target.transform.position = new Vector3(Random.Range(-5, 5), 0, Random.Range(10, 15));
            target.transform.LookAt(ModelLoader.self.transform);
            target.tag     = "target";
            target.enabled = false;

            ModelLoader.targetList.Add(target);
        }

        if (GUILayout.Button("预览低模"))
        {
            if (!EditorApplication.isPlaying)
            {
                EditorUtility.DisplayDialog("Error", "需要在运行状态下才能进行该操作", "OK");
                return;
            }

            ModelLoader.ResetPreviewingObject();

            roleObject = ModelLoader.CreateRole(this.Role, false);

            roleObject.tag               = "self";
            ModelLoader.self             = roleObject;
            ModelLoader.PreviewingObject = roleObject.gameObject;
            ModelLoader.SetupCamera(ModelLoader.PreviewingObject.transform);
            TriangleArea ta = roleObject.gameObject.AddComponent <TriangleArea>();
        }

        if (GUILayout.Button("预览高模"))
        {
            if (!EditorApplication.isPlaying)
            {
                EditorUtility.DisplayDialog("Error", "需要在运行状态下才能进行该操作", "OK");
                return;
            }

            ModelLoader.ResetPreviewingObject();

            roleObject = ModelLoader.CreateRole(this.Role, true);

            roleObject.tag               = "self";
            ModelLoader.self             = roleObject;
            ModelLoader.PreviewingObject = roleObject.gameObject;
            ModelLoader.SetupCamera(ModelLoader.PreviewingObject.transform);
            TriangleArea ta = roleObject.gameObject.AddComponent <TriangleArea>();
        }

        //当Inspector 面板发生变化时保存数据
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }