public void SetAssetInterface(AssetInterface asset)
        {
            // Assign the new asset
            if (asset == null)
            {
                m_assetInterface = null;

                m_actorInterface.SetAsset(HVR.Interface.Types.INVALID_HANDLE);
            }
            else
            {
                m_assetInterface = asset;

                m_actorInterface.SetAsset(m_assetInterface.handle);

                // Always update the transform after setting a new asset - Tom
                UpdateTransform();
            }

            // If the suborutinestack has any shaders, we need to set them again after the asset has changed
            if (m_subroutineStack.GetShaderArray().Length > 0)
            {
                m_forceUpdateSubroutines = true;
            }
        }
        private void EditorValidate()
        {
            // In the case that this component is a prefab,
            // don't allow interface objects to be created
            if (PrefabUtility.GetPrefabType(this) == PrefabType.Prefab)
            {
                return;
            }

            // Don't allow these checks to occur while the application is playing
            if (EditorApplication.isPlaying ||
                EditorApplication.isPaused)
            {
                return;
            }

            // If the actorInterface is null, then the code has likely just been
            // hot reloaded and we don't need to run the below checks
            if (m_actorInterface == null)
            {
                return;
            }

            // Check if the rendermethod type has changed
            if (m_renderMethodInterface != null &&
                m_renderMethodInterface.type != m_renderMethodType)
            {
                CreateRenderMethod(m_renderMethodType);
            }

            // Check if the data has changed and whether the asset needs to be recreated
            string path = GetDataPath(data, dataMode);

            if (string.IsNullOrEmpty(path))
            {
                if (m_assetInterface != null)
                {
                    m_assetInterface.Delete();
                    m_assetInterface = null;

                    SetAssetInterface(null);
                }
            }
            else
            {
                if (m_assetInterface == null)
                {
                    CreateAsset(data, dataMode);
                }
                else
                {
                    if (m_assetInterface.assetCreationInfo.assetPath != path)
                    {
                        CreateAsset(data, dataMode);
                    }
                }
            }
        }
Exemplo n.º 3
0
 void EnsureLocalAssetDirectory()
 {
     #region create asset directory
     localAUInfo   = EditTimeAssetUtils.AUInfoRemoteToLocal(baseAssetUnitInfo);
     assetRootPath = Path.GetDirectoryName(localAUInfo.localref);
     if (!Directory.Exists(assetRootPath))
     {
         Directory.CreateDirectory(assetRootPath);
     }
     if (localAssetInterface == null)
     {
         var customItfc = parent.customAssetInterfaceGiver[AssetUtils.GetPrimalType(localAUInfo)];
         localAssetInterface = customItfc.PickBestElement(new StdEditTimeUnityAssetIO {
             assetUnitInfo = localAUInfo
         });
     }
     #endregion
 }
        public void CreateAsset(string data, eDataMode dataMode)
        {
            // Ensure any asset interfaces are deleted and not attached to this HvrActor's actor
            if (m_assetInterface != null)
            {
                m_assetInterface.Delete();
                m_assetInterface = null;
            }

            m_data     = data;
            m_dataMode = dataMode;

            string path = GetDataPath(m_data, m_dataMode);

            if (!string.IsNullOrEmpty(path))
            {
                AssetInterface assetInterface = new AssetInterface();
                assetInterface.Create(path);
                SetAssetInterface(assetInterface);
            }
        }
        private void Destruct()
        {
            if (m_actorInterface != null)
            {
                m_actorInterface.Delete();
                m_actorInterface = null;
            }

            if (m_assetInterface != null)
            {
                m_assetInterface.Delete();
                m_assetInterface = null;
            }

            if (m_renderMethodInterface != null)
            {
                m_renderMethodInterface.Delete();
                m_renderMethodInterface = null;
            }

            HvrScene.Remove(this);
        }
Exemplo n.º 6
0
 void AssetReferenceListener.OnInterfaceObtained(AssetInterface assetInterface)
 {
     localAssetInterface = assetInterface;
 }