Пример #1
0
    void OnEnable()
    {
        // fetch the serialized props
        hasBeenInitialized = serializedObject.FindProperty("HasBeenInitialized");
        rayMask            = serializedObject.FindProperty("RayMask");
        objectGroups       = serializedObject.FindProperty("ObjectGroups");
        selectedObjectId   = serializedObject.FindProperty("SelectedObjectId");
        offset             = serializedObject.FindProperty("Offset");
        scale    = serializedObject.FindProperty("Scale");
        rotation = serializedObject.FindProperty("Rotation");
        snapX    = serializedObject.FindProperty("SnapX");
        snapY    = serializedObject.FindProperty("SnapY");
        snapZ    = serializedObject.FindProperty("SnapZ");
        autoSetX = serializedObject.FindProperty("AutoSetX");
        autoSetY = serializedObject.FindProperty("AutoSetY");
        autoSetZ = serializedObject.FindProperty("AutoSetZ");
        autoXPos = serializedObject.FindProperty("AutoXPos");
        autoYPos = serializedObject.FindProperty("AutoYPos");
        autoZPos = serializedObject.FindProperty("AutoZPos");
        gridSize = serializedObject.FindProperty("GridSize");
        drawXY   = serializedObject.FindProperty("DrawXY");
        drawXZ   = serializedObject.FindProperty("DrawXZ");
        drawYZ   = serializedObject.FindProperty("DrawYZ");


        currentButtonString = PressToStart;

        serializedObject.Update();

        QuickSetObjectPlacer qop = target as QuickSetObjectPlacer;

        if (hasBeenInitialized.boolValue == false)
        {
            hasBeenInitialized.boolValue = true;
            rayMask.intValue             = 0;
            rayMask.intValue             = ~rayMask.intValue;
        }


        serializedObject.ApplyModifiedProperties();


        lastTool      = Tools.current;
        Tools.current = Tool.None;

        qop.transform.position  = new Vector3(0, 0, 0);
        qop.transform.rotation  = Quaternion.Euler(Vector3.zero);
        qop.transform.hideFlags = HideFlags.NotEditable;
    }
Пример #2
0
    public static void AddObjectPlacer()
    {
        GameObject go = GameObject.Instantiate(AssetDatabase.LoadAssetAtPath <GameObject>("Assets/QuickSetObjectPlacer/_QuickSet.prefab"), Vector3.zero, Quaternion.identity) as GameObject;

        go.name = QuickSetObjectPlacer.QSName;

        QuickSetObjectPlacer objPlacer = go.GetComponent <QuickSetObjectPlacer>();

        if (objPlacer == null)
        {
            go.AddComponent <QuickSetObjectPlacer>();
        }

        Selection.activeGameObject = go;
    }