コード例 #1
0
    void Awake()
    {
        Debug.Log("TODO: Complete switch to arrays.");

        // Create a string called regex to fill with keywords
        string regex = "";
        // Find the assembly of the Color property in Unity
        Assembly assembly = typeof(Color).Assembly;

        // Loop through the types in that assembly & add them to the regex string
        foreach (Type type in assembly.GetTypes())
        {
            string formattedLine = type.Name;
            regex += formattedLine + "|";
        }

        // If custom keywords are referenced, loop through them and add them to a static array
        if (customKeywords != null)
        {
            int arrayLength = customKeywords.Length;
            CustomKeywords = new CustomKeyword[arrayLength];
            for (int i = 0; i < arrayLength; i++)
            {
                CustomKeywords[i]          = new CustomKeyword();
                CustomKeywords[i].keywords = ExtractKeywordArrayFromTxt(customKeywords[i].keywordsAsset);
                CustomKeywords[i].color    = customKeywords[i].color;
                // Also add them to the final regex.
                // The array is used to compare the regex with the array to create different colors.
                regex += ExtractKeywordsFromTxt(customKeywords[i].keywordsAsset);
                //Debug.Log(ExtractKeywordsFromTxt (customKeywords[i].keywordsAsset));
            }
        }

        // Add the extra keywords
        regex += ExtractKeywordsFromTxt(extraKeywords);

        // Assign the regex to a static Regex called APIKeywords.
        APIKeywords      = new Regex(regex);
        APIKeywordsArray = ExtractKeywordArrayFromString(regex);
    }
コード例 #2
0
ファイル: KeywordAPI.cs プロジェクト: NotYours180/Codium
	void Awake () {

		Debug.Log ("TODO: Complete switch to arrays.");

		// Create a string called regex to fill with keywords
		string regex = "";
		// Find the assembly of the Color property in Unity
		Assembly assembly = typeof(Color).Assembly;
		// Loop through the types in that assembly & add them to the regex string
		foreach (Type type in assembly.GetTypes())
		{
			string formattedLine = type.Name;
			regex += formattedLine + "|";
		}
		
		// If custom keywords are referenced, loop through them and add them to a static array
		if (customKeywords != null) {
			int arrayLength = customKeywords.Length;
			CustomKeywords = new CustomKeyword[arrayLength];
			for (int i = 0; i < arrayLength; i++) {
				CustomKeywords[i] = new CustomKeyword();
				CustomKeywords[i].keywords = ExtractKeywordArrayFromTxt (customKeywords[i].keywordsAsset);
				CustomKeywords[i].color = customKeywords[i].color;
				// Also add them to the final regex.
				// The array is used to compare the regex with the array to create different colors.
				regex += ExtractKeywordsFromTxt (customKeywords[i].keywordsAsset);
				//Debug.Log(ExtractKeywordsFromTxt (customKeywords[i].keywordsAsset));
			}
		}

		// Add the extra keywords
		regex += ExtractKeywordsFromTxt(extraKeywords);
		
		// Assign the regex to a static Regex called APIKeywords.
		APIKeywords = new Regex(regex);
		APIKeywordsArray = ExtractKeywordArrayFromString (regex);
	}