public override void OnInspectorGUI()
    {
        serializedObject.Update();
        ToggleScript script = (ToggleScript)target;

        script.action = (ToggleScript.Actions)EditorGUILayout.EnumPopup("Action", script.action);

        switch (script.action)
        {
        case ToggleScript.Actions.Animation:
            EditorGUILayout.PropertyField(anim_Prop, new GUIContent("Animator"));
            EditorGUILayout.PropertyField(animParameter_Prop, new GUIContent("Animation Parameter"));
            EditorGUILayout.PropertyField(animDelay_Prop, new GUIContent("Animation Delay"));
            break;

        case ToggleScript.Actions.BoolChange:
            EditorGUILayout.PropertyField(targetScript_Prop, new GUIContent("Target Script"));
            EditorGUILayout.PropertyField(methodName_Prop, new GUIContent("Method Name"));
            EditorGUILayout.PropertyField(boolDelay_Prop, new GUIContent("Bool Change Delay"));
            break;

        case ToggleScript.Actions.Instantiate:
            EditorGUILayout.PropertyField(spawnable_Prop, new GUIContent("Spawnable"));
            EditorGUILayout.PropertyField(position_Prop, new GUIContent("Position"));
            EditorGUILayout.PropertyField(rotation_Prop, new GUIContent("Rotation"));
            EditorGUILayout.PropertyField(spawnDelay_Prop, new GUIContent("Spawn Delay"));
            break;
        }

        serializedObject.ApplyModifiedProperties();
    }
    public void ToggleOff(ToggleScript s)
    {
        int i = s.object_num;

        toggle_bool[i]           = false;
        toggle_light[i].material = mats[4];
        temp_mats[i + 1]         = mats[4];
        mesh.materials           = temp_mats;

        chime.pitch = 0.80f;
        chime.Play();

        float newheight = 0;

        rotatespeed = 0f;
        foreach (bool b in toggle_bool)
        {
            if (b)
            {
                newheight   += heightmod;
                rotatespeed += rotatemod;
            }
        }
        StopAllCoroutines();
        StartCoroutine(MoveSphere(newheight));
    }
Exemple #3
0
    // TODO to remove a component, it has to be removed from the generic component list but also from the more specific list (for example currentTogglesList)

    public bool getToggleValue(int ComponentId)
    {
        ToggleScript component = getToggleById(ComponentId);

        if (component == null)
        {
            Debug.Log("Can not find Component!");
            return(false);
        }
        return(component.isActivated());
    }
Exemple #4
0
    protected override void OnLeftClickOnTargetEventAction()
    {
        ToggleScript mainToggle = gameObject.GetComponentInParent <ToggleScript>();

        if (mainToggle != null)
        {
            mainToggle.toggle();
        }
        else
        {
            Debug.Log("Can not found main toggle script!");
        }
    }
Exemple #5
0
    public int addToggle(string name, IMenueComponentListener listener)
    {
        ToggleScript newToggle   = Instantiate(togglePrefab);
        int          componentId = getUnusedId();

        newToggle.initMe(componentId, name);
        newToggle.transform.parent = elementList.transform;
        //TODO: Create a scrollable List for elements.
        newToggle.transform.localPosition = new Vector3(0f, (0.5f - (currentComponentList.Count * 0.1f)), -0.005f);
        newToggle.transform.localScale    = new Vector3(1f, 1f, 1f);
        currentComponentList.Add(newToggle);
        currentTogglesList.Add(newToggle);
        if (listener != null)
        {
            addListener(componentId, listener);
        }
        return(componentId);
    }
    // Update is called once per frame
    void Update()
    {
        rotation_z += Mathf.Clamp((-Input.GetAxis("Mouse Y")) * mouse_sensitivity, -5.0f, 5.0f);
        rotation_z  = Mathf.Clamp(rotation_z, -90.0f, 90.0f);
        transform.localRotation = Quaternion.Euler(rotation_z, 0, 0);

        if (Input.GetMouseButtonDown(0))
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                if (hit.transform.tag == "Button")
                {
                    ToggleScript button = hit.transform.GetComponent <ToggleScript>();
                    button.ToggleButton();
                    Debug.Log(button);
                }
            }
        }
    }
 // Use this for initialization
 void Start()
 {
     toggleScript   = GameObject.FindGameObjectWithTag("GameManager").GetComponent <ToggleScript>();
     spriteRenderer = transform.FindChild("segmentOn").GetComponent <SpriteRenderer>();
     state          = true;
 }
Exemple #8
0
 // Use this for initialization
 void Start()
 {
     toggleScript = GetComponent <ToggleScript>();
 }