Example #1
0
    public static GameObject GetPlayerComponent(PlayerComponent.ComponentTypes component)
    {
        string path = "";

        switch (component)
        {
        case PlayerComponent.ComponentTypes.Walk:
            path = "Prefabs/PlayerComponents/Walk.prefab";
            break;

        case PlayerComponent.ComponentTypes.Teleport:
            NoPathError(component);
            //path = "Prefabs/PlayerComponents/.prefab";
            break;

        case PlayerComponent.ComponentTypes.Rotate:
            path = "Prefabs/PlayerComponents/Rotate.prefab";
            break;

        case PlayerComponent.ComponentTypes.Climb:
            path = "Prefabs/PlayerComponents/Climb 2.0.prefab";
            break;

        case PlayerComponent.ComponentTypes.PhysicalBody:
            path = "Prefabs/PlayerComponents/PlayerBody.prefab";
            break;
        }

        if (path == "")
        {
            return(null);
        }

        return((GameObject)AssetDatabase.LoadAssetAtPath(genericPath + path, typeof(GameObject)));
    }
    public static PlayerComponent CreateComponent(PlayerComponent.ComponentTypes _type, PlayerRig _rig)
    {
        var tempObject = PrefabsXR.GetPlayerComponent(_type);

        if (!tempObject)
        {
            return(null);
        }
        var instantiatedObject = Instantiate(tempObject, _rig.transform).GetComponent <PlayerComponent>();

        //var instantiatedObject = ((GameObject)PrefabUtility.InstantiatePrefab());
        instantiatedObject.Setup(_rig);
        Undo.RegisterCreatedObjectUndo(instantiatedObject.gameObject, $"Added {_type} Component");
        return(instantiatedObject);
    }
Example #3
0
    public PlayerComponent GetActivePlayerComponent(PlayerComponent.ComponentTypes type)
    {
        switch (type)
        {
        case PlayerComponent.ComponentTypes.Walk:
            return(walk);

        case PlayerComponent.ComponentTypes.Teleport:
            return(teleport);

        case PlayerComponent.ComponentTypes.Rotate:
            return(rotate);

        case PlayerComponent.ComponentTypes.Climb:
            return(climb);

        case PlayerComponent.ComponentTypes.PhysicalBody:
            return(physicalBody);
        }

        return(null);
    }