コード例 #1
0
    public bool modoReferencia;//Modo onde não é utilizado o valor da célula e sim um no qual é possivél digitar

    //Construtor
    public CelulaReference(PlanilhaDoGoogle planilha, int linha, int coluna)
    {
        this.planilha  = planilha;
        this.linha     = linha;
        this.coluna    = coluna;
        modoReferencia = true;
        valor          = Valor;
    }
コード例 #2
0
 private void OnEnable()
 {
     myTarget = target as PlanilhaDoGoogle;
     // Link the properties
     sheetID = serializedObject.FindProperty("sheetID");
     pageID  = serializedObject.FindProperty("pageID");
     if (OnMomentosDataUpdate == null)
     {
         OnMomentosDataUpdate = new UnityEvent();
     }
 }
コード例 #3
0
    public static void GerarMomentos()
    {
        //Gera uma nova lista de momentos
        momentos = new List <MomentoInteracao>();

        //Carrega a planilha baseado no endereço fornecido
        PlanilhaDoGoogle planilha = AssetDatabase.LoadAssetAtPath <PlanilhaDoGoogle>(planilhaPath);

        //Gera os momentos e salva eles
        for (int linha = 2; linha < planilha.quantidadeDeLinhas; linha++)
        {
            MomentoInteracao momento = ScriptableObject.CreateInstance <MomentoInteracao>();

            //Configura a pagina do aluno
            PaginaInteracao paginaDoAluno = new PaginaInteracao();
            paginaDoAluno.professorFalando = false;
            paginaDoAluno.texto            = new CelulaReference(planilha, linha, 0);

            //Configura a pagina do professor
            PaginaInteracao paginaProfessor = new PaginaInteracao();
            paginaProfessor.professorFalando = true;
            paginaProfessor.texto            = new CelulaReference(planilha, linha, 1);

            //Adiciona as paginas configuradas
            momento.paginas = new PaginaInteracao[] { paginaDoAluno, paginaProfessor };

            //Configura selecao
            momento.opcoesDeEscolha  = new CelulaReference(planilha, linha, 2);
            momento.paginaDoDropdown = -1;//Sempre utiliza a ultima pagina
            //Salva o momento na lista
            momentos.Add(momento);
        }

        //Salva o momento na pasta
        AssetDatabase.DeleteAsset(momentosParentFolderPath + "/" + momentosFoldername);
        AssetDatabase.CreateFolder(momentosParentFolderPath, momentosFoldername);
        int index = 0;

        foreach (MomentoInteracao momento in momentos)
        {
            AssetDatabase.CreateAsset(momento, momentosParentFolderPath + "/" + momentosFoldername + "/MomentoPlanilha " + index + ".asset");
            index++;
        }

        AssetDatabase.SaveAssets();
    }
コード例 #4
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        float propertyHeight = 0f;

        if (popupStyle == null)
        {
            popupStyle = new GUIStyle(GUI.skin.GetStyle("PaneOptions"));
            popupStyle.imagePosition = ImagePosition.ImageOnly;
        }

        // Get properties
        SerializedProperty modoReferencia = property.FindPropertyRelative("modoReferencia");

        SerializedProperty valor             = property.FindPropertyRelative("valor");
        SerializedProperty linha             = property.FindPropertyRelative("linha");
        SerializedProperty coluna            = property.FindPropertyRelative("coluna");
        SerializedProperty planilha          = property.FindPropertyRelative("planilha");
        SerializedProperty propertyDrawerAux = property.FindPropertyRelative("propertyDrawerAux");

        EditorGUI.BeginChangeCheck();
        PlanilhaDoGoogle planilhaObj = planilha.objectReferenceValue as PlanilhaDoGoogle;

        EditorGUI.BeginProperty(position, label, property);

        position.height = EditorGUIUtility.singleLineHeight;

        //Popup
        Rect popUpRect = new Rect(EditorGUIUtility.labelWidth - ((EditorGUI.indentLevel - 1) * 15) - 20, position.y, 50, position.height);

        int result = EditorGUI.Popup(popUpRect, "", modoReferencia.boolValue ? 0 : 1, popupOptions, popupStyle);

        if (result == 0)
        {
            modoReferencia.boolValue = true;
        }
        else
        {
            modoReferencia.boolValue = false;
        }


        string foldoutLabel = property.displayName;

        if (modoReferencia.boolValue)
        {
            Rect foldoutRect = new Rect(position.x, position.y, EditorGUIUtility.labelWidth - ((EditorGUI.indentLevel - 1) * 15) - 100, position.height);
            property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, foldoutLabel, true);

            if (planilhaObj != null)
            {
                valor.stringValue = planilhaObj.GetDataAt(linha.intValue, coluna.intValue);
            }
            else
            {
                valor.stringValue = "null reference";
            }
        }
        else
        {
            EditorGUI.LabelField(position, foldoutLabel);
            property.isExpanded = false;
        }

        EditorGUI.indentLevel++;
        // draw next PropertyField, and so on
        if (property.isExpanded)
        {
            propertyHeight += position.height + EditorGUIUtility.standardVerticalSpacing;
            position.y     += position.height + EditorGUIUtility.standardVerticalSpacing;
            //Propriedade da planilha
            Rect planilhaRect = new Rect(position.x, position.y, position.width, position.height);
            EditorGUI.PropertyField(planilhaRect, planilha);
            propertyHeight += position.height + EditorGUIUtility.standardVerticalSpacing;
            if (planilhaObj != null)
            {
                //Linha
                propertyHeight += position.height + EditorGUIUtility.standardVerticalSpacing;
                position.y     += position.height + EditorGUIUtility.standardVerticalSpacing;
                EditorGUI.LabelField(position, "Linha: ");

                Rect linhaRect = new Rect(EditorGUIUtility.labelWidth - ((EditorGUI.indentLevel - 1) * 15) + 5, position.y, position.width - (EditorGUIUtility.labelWidth - ((EditorGUI.indentLevel - 1) * 15 + 13)), position.height);
                linha.intValue = EditorGUI.IntSlider(linhaRect, linha.intValue, 0, planilhaObj.quantidadeDeLinhas - 1);

                //Coluna
                propertyHeight += position.height + EditorGUIUtility.standardVerticalSpacing;
                position.y     += position.height + EditorGUIUtility.standardVerticalSpacing;
                EditorGUI.LabelField(position, "Coluna: ");

                Rect colunaRect = new Rect(EditorGUIUtility.labelWidth - ((EditorGUI.indentLevel - 1) * 15) + 5, position.y, position.width - (EditorGUIUtility.labelWidth - ((EditorGUI.indentLevel - 1) * 15 + 13)), position.height);
                coluna.intValue = EditorGUI.IntSlider(colunaRect, coluna.intValue, 0, planilhaObj.quantidadeDeColunas - 1);

                //Label Valor
                position.y     += position.height + EditorGUIUtility.standardVerticalSpacing;
                propertyHeight += position.height + EditorGUIUtility.standardVerticalSpacing;
                EditorGUI.LabelField(position, "Valor: ");

                //TextAreaValor
                float positionX = EditorGUIUtility.labelWidth - ((EditorGUI.indentLevel - 1) * 15) + 5;

                float alturaDoValor = position.height * quantidadeDeLinhasEm(valor.stringValue);
                propertyHeight += alturaDoValor + EditorGUIUtility.standardVerticalSpacing;

                Rect valorRect = new Rect(positionX, position.y, position.width - positionX + 18, alturaDoValor);

                EditorGUI.BeginDisabledGroup(modoReferencia.boolValue);
                valor.stringValue = EditorGUI.TextArea(valorRect, valor.stringValue);
                EditorGUI.EndDisabledGroup();
            }
        }
        else
        {
            float alturaDoValor = position.height * quantidadeDeLinhasEm(valor.stringValue);
            propertyHeight += alturaDoValor + EditorGUIUtility.standardVerticalSpacing;
            if (planilhaObj != null || !modoReferencia.boolValue)
            {
                float positionX = EditorGUIUtility.labelWidth - ((EditorGUI.indentLevel - 1) * 15) + 5;

                Rect valorRect = new Rect(positionX, position.y, position.width - positionX + 18, alturaDoValor);

                EditorGUI.BeginDisabledGroup(modoReferencia.boolValue);
                valor.stringValue = EditorGUI.TextArea(valorRect, valor.stringValue);
                EditorGUI.EndDisabledGroup();
            }
        }


        propertyDrawerAux.floatValue = propertyHeight;
        if (EditorGUI.EndChangeCheck())
        {
            property.serializedObject.ApplyModifiedProperties();
        }

        EditorGUI.EndProperty();
    }