public TC_RawImage AddRawFile(string fullPath, bool isResourcesFolder) { for (int i = 0; i < rawFiles.Count; i++) { if (rawFiles[i] == null) { rawFiles.RemoveAt(i); i--; continue; } if (rawFiles[i].path == fullPath) { ++rawFiles[i].referenceCount; if (rawFiles[i].tex == null) rawFiles[i].LoadRawImage(fullPath); return rawFiles[i]; } } string label = TC.GetFileName(fullPath); GameObject go = new GameObject(label); go.transform.parent = transform; TC_RawImage rawImage = go.AddComponent<TC_RawImage>(); // Debug.Log(fullPath); rawImage.isResourcesFolder = isResourcesFolder; rawImage.LoadRawImage(fullPath); rawImage.referenceCount = 1; rawFiles.Add(rawImage); return rawImage; }
void DrawCustomInspector() { TC_RawImage rawImage = (TC_RawImage)target; TD.DrawSpacer(); TD.DrawLabelWidthUnderline("Loaded stamp texture for GPU", 14); GUILayout.Space(25); Rect rect = GUILayoutUtility.GetLastRect(); float width = TC_NodeWindow.window.position.width - (rect.x * 2); if (width > 768) { width = 768; } float min = (768 - width); if (min > 50) { min = 50; } TD.DrawTexture(new Rect(rect.x, rect.y + width, width, -width), rawImage.tex, Color.white); GUILayout.Space(width - min); TD.DrawSpacer(); TD.DrawLabelWidthUnderline("Path", 14); EditorGUILayout.BeginVertical("Box"); EditorGUILayout.LabelField(rawImage.path); EditorGUILayout.EndVertical(); GUILayout.Space(10); TD.DrawLabelWidthUnderline("Details", 14); EditorGUILayout.BeginVertical("Box"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Resolution"); EditorGUILayout.LabelField(rawImage.resolution.ToString()); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Node References"); EditorGUILayout.LabelField(rawImage.referenceCount.ToString()); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); TD.DrawSpacer(); }
public bool DropTextureEditor(Texture tex) { #if UNITY_EDITOR if (tex != null) { pathTexStamp = UnityEditor.AssetDatabase.GetAssetPath(tex); string path = pathTexStamp; int index = path.LastIndexOf("/"); path = path.Insert(index, "/RawFiles"); index = path.IndexOf("/Resources/"); isStampInResourcesFolder = (index != -1); if (isStampInResourcesFolder) { path = path.Substring(index + 11); path = path.Remove(path.Length - 4); resourcesFolder = path; // Debug.Log(path); } else { path = path.Remove(path.Length - 3) + "raw"; if (!TC.FileExistsPath(path)) { path = path.Remove(path.Length - 3) + "r16"; } if (!TC.FileExistsPath(path)) { // TC.AddMessage("Cannot find the file " + path.Remove(path.Length - 3, 3) + "\n\nThe file extension needs to be .raw or .r16"); if (rawImage != null) { rawImage.UnregisterReference(); } inputFile = InputFile.Image; stampTex = tex; TC.AutoGenerate(); return(false); } } TC_RawImage oldRawImage = rawImage; if (oldRawImage) { oldRawImage.UnregisterReference(); } // Debug.Log(path); rawImage = TC_Settings.instance.AddRawFile(path, isStampInResourcesFolder); } #else if (isStampInResourcesFolder) { rawImage = TC_Settings.instance.AddRawFile(resourcesFolder, isStampInResourcesFolder); } #endif if (rawImage != null) { stampTex = tex; TC.RefreshOutputReferences(outputId, true); // TC_Reporter.Log(path); TC_Reporter.Log("Node index " + rawImage.name); return(true); } else { TC.AddMessage("This is not a stamp preview image.\n\nThe raw heightmap file needs to be placed in a 'RawFiles' folder, then TC2 will automatically make a preview image one folder before it.\nThis image needs to be used for dropping on the node.", 0, 4); } return(false); }