Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripting examples needed! #737

Open
programmatoroSeduto opened this issue Jul 1, 2023 · 0 comments
Open

Scripting examples needed! #737

programmatoroSeduto opened this issue Jul 1, 2023 · 0 comments

Comments

@programmatoroSeduto
Copy link

Hello there,

First of all, great documentation! I'd like to provide some hints to improve it.

it would be great if this page also contained scripting examples, since, from what is reported here, I think it is unclear how to deal with setting up such a feature dynamically. It would be wonderful to have some information about how to implement custom constrains as well.

For instance, I created this example, but I spent a lot of time to understad how, since the reference API is not so helpful (some comments are missing in this link I think: API reference )

    // root of the minimap asset
    private GameObject GoAssetRoot = null;
    // minimap gameobject
    private GameObject goMinimap = null;
    // minimap structure component in the minimap
    private MinimapStructure coMinimapStruct = null;
    // tools root for the minimap
    private GameObject goTools = null;

    private void CreatePlaneTool()
    {
        GameObject goPlaneTool = GameObject.CreatePrimitive(PrimitiveType.Cube);
        goPlaneTool.name = "MinimapSliderTool";
        goPlaneTool.transform.SetParent(goTools.transform);
        goPlaneTool.transform.localPosition = new Vector3(0.5f, 0.0f, 0.5f);
        goPlaneTool.transform.localScale = new Vector3(1.2f, 0.1f, 1.2f);
        goPlaneTool.GetComponent<Renderer>().material = ToolMaterial;

        goPlaneTool.AddComponent<NearInteractionGrabbable>();
        goPlaneTool.AddComponent<ObjectManipulator>();

        ConstraintManager coConstraints = goPlaneTool.GetComponent<ConstraintManager>();

        MoveAxisConstraint coConstraintX = goPlaneTool.AddComponent<MoveAxisConstraint>();
        coConstraintX.ConstraintOnMovement = AxisFlags.XAxis;
        coConstraintX.UseLocalSpaceForConstraint = true;

        MoveAxisConstraint coConstraintZ = goPlaneTool.AddComponent<MoveAxisConstraint>();
        coConstraintZ.ConstraintOnMovement = AxisFlags.ZAxis;
        coConstraintZ.UseLocalSpaceForConstraint = true;
    }

Thank you, have a nice day!


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant