Beispiel #1
0
    public GameObject AddEffectPoint(MapEffectPoint effectPoint, Vector3 pos)
    {
        if (effectPoint.res == "" || effectPoint.res == null)
        {
            effectPoint.res = "fx/scene_anquanquhouqiu";
        }
        Object prefab = EditorTool.LoadAssetBundle(effectPoint.res + ".unity3d");

        //Object prefab = EditorTool.LoadAssetBundle("fx/scene_anquanquhouqiu.unity3d");
        if (prefab == null)
        {
            Debug.LogError("传送门 资源找不到:" + effectPoint.res);
            //Debug.LogError("传送门 资源找不到:fx/scene_anquanquhouqiu.unity3d");
            return(null);
        }

        string    subpath     = "effectPoint";
        Transform parentTrans = getRoot().FindChild(subpath);

        if (parentTrans == null)
        {
            GameObject subroot = new GameObject(subpath);
            subroot.transform.SetParent(getRoot());
            parentTrans = subroot.transform;
        }
        string nodeName = "effect_" + effectPoint.id;



        GameObject npcObj = (GameObject)GameObject.Instantiate(prefab);

        npcObj.name = nodeName;


        npcObj.transform.SetParent(parentTrans);
        npcObj.transform.localPosition = pos;
        if (effectPoint.eulerangles != null)
        {
            string[] arr = effectPoint.eulerangles.Split(',');
            if (arr.Length == 3)
            {
                //npcObj.transform.Rotate(float.Parse(arr[0]), float.Parse(arr[1]), float.Parse(arr[2]));
                npcObj.transform.localRotation = Quaternion.Euler(float.Parse(arr[0]), float.Parse(arr[1]), float.Parse(arr[2]));
            }
        }


        MapEffectPointView view = npcObj.AddComponent <MapEffectPointView>();

        view.data = effectPoint;
        foreach (ParticleSystem ps in npcObj.GetComponentsInChildren <ParticleSystem>())
        {
            ps.Play(true);
        }
        effectPoint.target = npcObj;
        return(npcObj);
    }
Beispiel #2
0
    void updateMesh(int width, int height)
    {
        MapEffectPointView view = (MapEffectPointView)target;
        MeshFilter         mf   = view.gameObject.GetComponent <MeshFilter>();
        Mesh mesh = mf.sharedMesh;

        float          x     = PathUtilEdit.Logic2RealLen(width / 2f);
        float          z     = PathUtilEdit.Logic2RealLen(height / 2f);
        List <Vector3> verts = new List <Vector3>();

        verts.Add(new Vector3(-x, 0, z));
        verts.Add(new Vector3(x, 0, z));
        verts.Add(new Vector3(x, 0, -z));
        verts.Add(new Vector3(-x, 0, -z));

        mesh.vertices = verts.ToArray();
    }
Beispiel #3
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        EditorGUILayout.PropertyField(effectId, new GUIContent("特效ID"));
        EditorGUILayout.PropertyField(propType, new GUIContent("特效类型"));
        EditorGUILayout.PropertyField(propRes, new GUIContent("资源名"));
        int origWidth  = propWidth.intValue;
        int origHeight = propHeight.intValue;

        EditorGUILayout.PropertyField(propWidth, new GUIContent("宽"));
        EditorGUILayout.PropertyField(propHeight, new GUIContent("高"));
        if (origHeight != propWidth.intValue || origWidth != propHeight.intValue)
        {
            //Debug.Log("width or height changed:" + propWidth.intValue + ",height:" + propHeight.intValue);
            updateMesh(propWidth.intValue, propHeight.intValue);
        }

        MapEffectPointView view  = (MapEffectPointView)target;
        Quaternion         rotat = view.gameObject.transform.localRotation;

        if (view.gameObject.transform.hasChanged)
        {
            Vector3  pos   = view.gameObject.transform.localPosition;
            IntPoint logic = PathUtilEdit.Real2Logic(pos);
            if (logic.x != propX.intValue || logic.y != propY.intValue)
            {
                pos = PathUtilEdit.LogicCenter2Real(logic);
                //Debug.Log("npc pos changed:" + logic.x + " != " + propX.intValue + "," + logic.y+" != "+propY.intValue);
                if (EditorData.terrainMan != null)
                {
                    pos.y = EditorData.terrainMan.GetHeight(pos.x, pos.z);
                    view.gameObject.transform.localPosition = pos;
                }
            }
            propX.intValue = logic.x;
            propY.intValue = logic.y;
            propEulerangles.stringValue = rotat.eulerAngles.x.ToString() + "," + rotat.eulerAngles.y.ToString() + "," + rotat.eulerAngles.z.ToString();
        }
        EditorGUILayout.LabelField("X:\t" + propX.intValue);
        EditorGUILayout.LabelField("Y:\t" + propY.intValue);

        serializedObject.ApplyModifiedProperties();
    }