Esempio n. 1
0
 public virtual void OnTransformChildrenChanged()
 {
     // Debug.Log("Children " + name + " has changed "+TC.outputNames[outputId]);
     TC.RefreshOutputReferences(outputId, true);
     // GetItems(this);
     // TC_Generate.AutoGenerate();
 }
Esempio n. 2
0
 void OnDestroy()
 {
     if (!callDestroy)
     {
         TC.RefreshOutputReferences(TC.allOutput);
     }
 }
Esempio n. 3
0
 void UndoRedoPerformed()
 {
     // Debug.Log("Perform undo");
     if (TD.SelectionContainsItemBehaviour())
     {
         TC.RefreshOutputReferences(TC.allOutput);
         TC.AutoGenerate();
     }
 }
Esempio n. 4
0
        void OnEnable()
        {
            autoRepaintOnSceneChange = true;
            TD.scale = 2;

            Undo.undoRedoPerformed += UndoRedoPerformed;

            // Debug.Log("Node Window OnEnable");
            TC.RefreshOutputReferences(6);
        }
Esempio n. 5
0
 void OnDestroy()
 {
     TC_Compute.DisposeTexture(ref tex);
                 #if UNITY_EDITOR
     if (!UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode && !callDestroy)
     {
         TC.RefreshOutputReferences(TC.allOutput);
     }
                 #else
     if (!callDestroy)
     {
         TC.RefreshOutputReferences(TC.allOutput);
     }
                 #endif
 }
Esempio n. 6
0
 void Awake()
 {
     if (isDestroyed)
     {
         // LoadRawImage(fullPath);
         TC_Settings.instance.imageList.Add(this);
     }
     if (!callDestroy)
     {
         TC.RefreshOutputReferences(TC.allOutput); referenceCount = 0;
     }
     else
     {
         callDestroy = false;
     }
 }
        void Update()
        {
            if (target == null)
            {
                return;
            }

            if (followPosition)
            {
                t.position = target.position + offset;
            }
            if (followRotation)
            {
                t.rotation = target.rotation;
            }
            if (followScale)
            {
                float scaleY;
                if (followScaleY)
                {
                    scaleY = t.localScale.y;
                }
                else
                {
                    scaleY = target.lossyScale.y;
                }
                t.localScale = new Vector3(target.lossyScale.x, scaleY, target.lossyScale.z);
            }

            if (targetItem != null && item != null)
            {
                if (item.visible != targetItem.visible)
                {
                    item.visible = targetItem.visible;
                    TC.RefreshOutputReferences(item.outputId);
                }
            }

            if (refresh)
            {
                TC.repaintNodeWindow = true;
                TC.AutoGenerate();
            }
        }
Esempio n. 8
0
        void ClickMenuMain(object obj)
        {
            string cmd = obj.ToString();

            if (cmd == "New")
            {
                New();
            }
            if (cmd == "Open")
            {
                Open();
            }
            if (cmd == "Save")
            {
                Save();
            }
            else if (cmd == "Settings")
            {
                Selection.activeTransform = TC_Settings.instance.transform;
            }
            else if (cmd == "Generate")
            {
                TC_Generate.instance.Generate(false);
            }
            else if (cmd == "Auto Generate")
            {
                TC_Generate.instance.autoGenerate = !TC_Generate.instance.autoGenerate;
            }
            else if (cmd == "Show Fps")
            {
                TC_Settings.instance.showFps = !TC_Settings.instance.showFps;
            }
            else if (cmd == "Hide Menu Bar")
            {
                TC_Settings.instance.hideMenuBar = !TC_Settings.instance.hideMenuBar;
                if (!TC_Settings.instance.hideMenuBar)
                {
                    TC.AddMessage("The menu bar can be unhided by the popup menu, this can be shown by right clicking in the empty area where the Height/Splat/Color... buttons are.");
                }
            }
            else if (cmd == "Refresh")
            {
                TC_Generate.instance.RefreshOutputReferences(6, true);
                if (TC_Generate.instance.autoGenerate)
                {
                    TC_Generate.instance.Generate(false);
                }
            }
            else if (cmd == "ResetTextures")
            {
                TC.RefreshOutputReferences(7);
            }
            else if (cmd == "Documentation")
            {
                Application.OpenURL("http://www.terraincomposer.com/terraincomposer2-documentation/");
            }
            else if (cmd == "Tooltip")
            {
                TC_Settings.instance.global.tooltip = !TC_Settings.instance.global.tooltip;
            }
            else if (cmd == "About...")
            {
                TC.AddMessage("TerrainComposer version " + TC.GetVersionNumber().ToString(), 0, 4);
            }
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        static public void ClickMenuInput(object obj)
        {
            int    instanceID;
            string command = TD.ObjectToCommandAndInstanceID(obj, out instanceID);

            TC_Node node = EditorUtility.InstanceIDToObject(instanceID) as TC_Node;

            if (node != null)
            {
                int    index     = command.IndexOf("/");
                string inputKind = command.Substring(0, index);
                string input     = command.Substring(index + 1);
                bool   changed   = false;

                InputKind oldInputKind = node.inputKind;
                node.inputKind = (InputKind)Enum.Parse(typeof(InputKind), inputKind);

                if (node.inputKind != oldInputKind)
                {
                    changed = true;
                }

                if (inputKind == "Terrain")
                {
                    InputTerrain oldInputTerrain = node.inputTerrain;
                    node.inputTerrain = (InputTerrain)Enum.Parse(typeof(InputTerrain), input);
                    if (node.inputTerrain != oldInputTerrain)
                    {
                        changed = true;
                    }
                }
                else if (inputKind == "Noise")
                {
                    InputNoise oldInputNoise = node.inputNoise;
                    node.inputNoise = (InputNoise)Enum.Parse(typeof(InputNoise), input);
                    if (node.inputNoise != oldInputNoise)
                    {
                        changed = true;
                    }
                }
                else if (inputKind == "Shape")
                {
                    InputShape oldInputShape = node.inputShape;
                    node.inputShape = (InputShape)Enum.Parse(typeof(InputShape), input);
                    if (node.inputShape != oldInputShape)
                    {
                        changed = true;
                    }
                }
                else if (inputKind == "File")
                {
                    InputFile oldInputFile = node.inputFile;
                    node.inputFile = (InputFile)Enum.Parse(typeof(InputFile), input);
                    if (node.inputFile != oldInputFile)
                    {
                        changed = true;
                    }
                }
                else if (inputKind == "Current")
                {
                    InputCurrent oldInputCurrent = node.inputCurrent;
                    node.inputCurrent = (InputCurrent)Enum.Parse(typeof(InputCurrent), input);
                    if (node.inputCurrent != oldInputCurrent)
                    {
                        changed = true;
                    }
                }

                if (changed)
                {
                    node.Init();
                    EditorUtility.SetDirty(node);
                    TC.RefreshOutputReferences(node.outputId, true);
                }
            }
        }